babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Represents an Dual Shock controller
  12300. */
  12301. static DUALSHOCK: number;
  12302. /**
  12303. * Specifies whether the left control stick should be Y-inverted
  12304. */
  12305. protected _invertLeftStickY: boolean;
  12306. /**
  12307. * Specifies if the gamepad has been connected
  12308. */
  12309. readonly isConnected: boolean;
  12310. /**
  12311. * Initializes the gamepad
  12312. * @param id The id of the gamepad
  12313. * @param index The index of the gamepad
  12314. * @param browserGamepad The browser gamepad
  12315. * @param leftStickX The x component of the left joystick
  12316. * @param leftStickY The y component of the left joystick
  12317. * @param rightStickX The x component of the right joystick
  12318. * @param rightStickY The y component of the right joystick
  12319. */
  12320. constructor(
  12321. /**
  12322. * The id of the gamepad
  12323. */
  12324. id: string,
  12325. /**
  12326. * The index of the gamepad
  12327. */
  12328. index: number,
  12329. /**
  12330. * The browser gamepad
  12331. */
  12332. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12333. /**
  12334. * Callback triggered when the left joystick has changed
  12335. * @param callback
  12336. */
  12337. onleftstickchanged(callback: (values: StickValues) => void): void;
  12338. /**
  12339. * Callback triggered when the right joystick has changed
  12340. * @param callback
  12341. */
  12342. onrightstickchanged(callback: (values: StickValues) => void): void;
  12343. /**
  12344. * Gets the left joystick
  12345. */
  12346. /**
  12347. * Sets the left joystick values
  12348. */
  12349. leftStick: StickValues;
  12350. /**
  12351. * Gets the right joystick
  12352. */
  12353. /**
  12354. * Sets the right joystick value
  12355. */
  12356. rightStick: StickValues;
  12357. /**
  12358. * Updates the gamepad joystick positions
  12359. */
  12360. update(): void;
  12361. /**
  12362. * Disposes the gamepad
  12363. */
  12364. dispose(): void;
  12365. }
  12366. /**
  12367. * Represents a generic gamepad
  12368. */
  12369. export class GenericPad extends Gamepad {
  12370. private _buttons;
  12371. private _onbuttondown;
  12372. private _onbuttonup;
  12373. /**
  12374. * Observable triggered when a button has been pressed
  12375. */
  12376. onButtonDownObservable: Observable<number>;
  12377. /**
  12378. * Observable triggered when a button has been released
  12379. */
  12380. onButtonUpObservable: Observable<number>;
  12381. /**
  12382. * Callback triggered when a button has been pressed
  12383. * @param callback Called when a button has been pressed
  12384. */
  12385. onbuttondown(callback: (buttonPressed: number) => void): void;
  12386. /**
  12387. * Callback triggered when a button has been released
  12388. * @param callback Called when a button has been released
  12389. */
  12390. onbuttonup(callback: (buttonReleased: number) => void): void;
  12391. /**
  12392. * Initializes the generic gamepad
  12393. * @param id The id of the generic gamepad
  12394. * @param index The index of the generic gamepad
  12395. * @param browserGamepad The browser gamepad
  12396. */
  12397. constructor(id: string, index: number, browserGamepad: any);
  12398. private _setButtonValue;
  12399. /**
  12400. * Updates the generic gamepad
  12401. */
  12402. update(): void;
  12403. /**
  12404. * Disposes the generic gamepad
  12405. */
  12406. dispose(): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12410. import { Nullable } from "babylonjs/types";
  12411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12412. import { Scene } from "babylonjs/scene";
  12413. module "babylonjs/Engines/engine" {
  12414. interface Engine {
  12415. /**
  12416. * Creates a raw texture
  12417. * @param data defines the data to store in the texture
  12418. * @param width defines the width of the texture
  12419. * @param height defines the height of the texture
  12420. * @param format defines the format of the data
  12421. * @param generateMipMaps defines if the engine should generate the mip levels
  12422. * @param invertY defines if data must be stored with Y axis inverted
  12423. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12424. * @param compression defines the compression used (null by default)
  12425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12426. * @returns the raw texture inside an InternalTexture
  12427. */
  12428. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12429. /**
  12430. * Update a raw texture
  12431. * @param texture defines the texture to update
  12432. * @param data defines the data to store in the texture
  12433. * @param format defines the format of the data
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. */
  12436. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12437. /**
  12438. * Update a raw texture
  12439. * @param texture defines the texture to update
  12440. * @param data defines the data to store in the texture
  12441. * @param format defines the format of the data
  12442. * @param invertY defines if data must be stored with Y axis inverted
  12443. * @param compression defines the compression used (null by default)
  12444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12445. */
  12446. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12447. /**
  12448. * Creates a new raw cube texture
  12449. * @param data defines the array of data to use to create each face
  12450. * @param size defines the size of the textures
  12451. * @param format defines the format of the data
  12452. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12453. * @param generateMipMaps defines if the engine should generate the mip levels
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12456. * @param compression defines the compression used (null by default)
  12457. * @returns the cube texture as an InternalTexture
  12458. */
  12459. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12460. /**
  12461. * Update a raw cube texture
  12462. * @param texture defines the texture to udpdate
  12463. * @param data defines the data to store
  12464. * @param format defines the data format
  12465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. */
  12468. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12469. /**
  12470. * Update a raw cube texture
  12471. * @param texture defines the texture to udpdate
  12472. * @param data defines the data to store
  12473. * @param format defines the data format
  12474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12475. * @param invertY defines if data must be stored with Y axis inverted
  12476. * @param compression defines the compression used (null by default)
  12477. */
  12478. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12479. /**
  12480. * Update a raw cube texture
  12481. * @param texture defines the texture to udpdate
  12482. * @param data defines the data to store
  12483. * @param format defines the data format
  12484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. * @param compression defines the compression used (null by default)
  12487. * @param level defines which level of the texture to update
  12488. */
  12489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12490. /**
  12491. * Creates a new raw cube texture from a specified url
  12492. * @param url defines the url where the data is located
  12493. * @param scene defines the current scene
  12494. * @param size defines the size of the textures
  12495. * @param format defines the format of the data
  12496. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12497. * @param noMipmap defines if the engine should avoid generating the mip levels
  12498. * @param callback defines a callback used to extract texture data from loaded data
  12499. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12500. * @param onLoad defines a callback called when texture is loaded
  12501. * @param onError defines a callback called if there is an error
  12502. * @returns the cube texture as an InternalTexture
  12503. */
  12504. 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;
  12505. /**
  12506. * Creates a new raw cube texture from a specified url
  12507. * @param url defines the url where the data is located
  12508. * @param scene defines the current scene
  12509. * @param size defines the size of the textures
  12510. * @param format defines the format of the data
  12511. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12512. * @param noMipmap defines if the engine should avoid generating the mip levels
  12513. * @param callback defines a callback used to extract texture data from loaded data
  12514. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12515. * @param onLoad defines a callback called when texture is loaded
  12516. * @param onError defines a callback called if there is an error
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param invertY defines if data must be stored with Y axis inverted
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. 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;
  12522. /**
  12523. * Creates a new raw 3D texture
  12524. * @param data defines the data used to create the texture
  12525. * @param width defines the width of the texture
  12526. * @param height defines the height of the texture
  12527. * @param depth defines the depth of the texture
  12528. * @param format defines the format of the texture
  12529. * @param generateMipMaps defines if the engine must generate mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12532. * @param compression defines the compressed used (can be null)
  12533. * @param textureType defines the compressed used (can be null)
  12534. * @returns a new raw 3D texture (stored in an InternalTexture)
  12535. */
  12536. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12537. /**
  12538. * Update a raw 3D texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store
  12541. * @param format defines the data format
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw 3D texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store
  12549. * @param format defines the data format
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the used compression (can be null)
  12552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12553. */
  12554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12555. }
  12556. }
  12557. }
  12558. declare module "babylonjs/Materials/Textures/rawTexture" {
  12559. import { Scene } from "babylonjs/scene";
  12560. import { Texture } from "babylonjs/Materials/Textures/texture";
  12561. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12562. /**
  12563. * Raw texture can help creating a texture directly from an array of data.
  12564. * This can be super useful if you either get the data from an uncompressed source or
  12565. * if you wish to create your texture pixel by pixel.
  12566. */
  12567. export class RawTexture extends Texture {
  12568. /**
  12569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12570. */
  12571. format: number;
  12572. private _engine;
  12573. /**
  12574. * Instantiates a new RawTexture.
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. * @param data define the array of data to use to create the texture
  12579. * @param width define the width of the texture
  12580. * @param height define the height of the texture
  12581. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. * @param scene define the scene the texture belongs to
  12583. * @param generateMipMaps define whether mip maps should be generated or not
  12584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12587. */
  12588. constructor(data: ArrayBufferView, width: number, height: number,
  12589. /**
  12590. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12591. */
  12592. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12593. /**
  12594. * Updates the texture underlying data.
  12595. * @param data Define the new data of the texture
  12596. */
  12597. update(data: ArrayBufferView): void;
  12598. /**
  12599. * Creates a luminance texture from some data.
  12600. * @param data Define the texture data
  12601. * @param width Define the width of the texture
  12602. * @param height Define the height of the texture
  12603. * @param scene Define the scene the texture belongs to
  12604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12607. * @returns the luminance texture
  12608. */
  12609. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12610. /**
  12611. * Creates a luminance alpha texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance alpha texture
  12620. */
  12621. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates an alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the alpha texture
  12632. */
  12633. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates a RGB texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12644. * @returns the RGB alpha texture
  12645. */
  12646. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12647. /**
  12648. * Creates a RGBA texture from some data.
  12649. * @param data Define the texture data
  12650. * @param width Define the width of the texture
  12651. * @param height Define the height of the texture
  12652. * @param scene Define the scene the texture belongs to
  12653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12657. * @returns the RGBA texture
  12658. */
  12659. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12660. /**
  12661. * Creates a R texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12670. * @returns the R texture
  12671. */
  12672. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12673. }
  12674. }
  12675. declare module "babylonjs/Maths/math.size" {
  12676. /**
  12677. * Interface for the size containing width and height
  12678. */
  12679. export interface ISize {
  12680. /**
  12681. * Width
  12682. */
  12683. width: number;
  12684. /**
  12685. * Heighht
  12686. */
  12687. height: number;
  12688. }
  12689. /**
  12690. * Size containing widht and height
  12691. */
  12692. export class Size implements ISize {
  12693. /**
  12694. * Width
  12695. */
  12696. width: number;
  12697. /**
  12698. * Height
  12699. */
  12700. height: number;
  12701. /**
  12702. * Creates a Size object from the given width and height (floats).
  12703. * @param width width of the new size
  12704. * @param height height of the new size
  12705. */
  12706. constructor(width: number, height: number);
  12707. /**
  12708. * Returns a string with the Size width and height
  12709. * @returns a string with the Size width and height
  12710. */
  12711. toString(): string;
  12712. /**
  12713. * "Size"
  12714. * @returns the string "Size"
  12715. */
  12716. getClassName(): string;
  12717. /**
  12718. * Returns the Size hash code.
  12719. * @returns a hash code for a unique width and height
  12720. */
  12721. getHashCode(): number;
  12722. /**
  12723. * Updates the current size from the given one.
  12724. * @param src the given size
  12725. */
  12726. copyFrom(src: Size): void;
  12727. /**
  12728. * Updates in place the current Size from the given floats.
  12729. * @param width width of the new size
  12730. * @param height height of the new size
  12731. * @returns the updated Size.
  12732. */
  12733. copyFromFloats(width: number, height: number): Size;
  12734. /**
  12735. * Updates in place the current Size from the given floats.
  12736. * @param width width to set
  12737. * @param height height to set
  12738. * @returns the updated Size.
  12739. */
  12740. set(width: number, height: number): Size;
  12741. /**
  12742. * Multiplies the width and height by numbers
  12743. * @param w factor to multiple the width by
  12744. * @param h factor to multiple the height by
  12745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12746. */
  12747. multiplyByFloats(w: number, h: number): Size;
  12748. /**
  12749. * Clones the size
  12750. * @returns a new Size copied from the given one.
  12751. */
  12752. clone(): Size;
  12753. /**
  12754. * True if the current Size and the given one width and height are strictly equal.
  12755. * @param other the other size to compare against
  12756. * @returns True if the current Size and the given one width and height are strictly equal.
  12757. */
  12758. equals(other: Size): boolean;
  12759. /**
  12760. * The surface of the Size : width * height (float).
  12761. */
  12762. readonly surface: number;
  12763. /**
  12764. * Create a new size of zero
  12765. * @returns a new Size set to (0.0, 0.0)
  12766. */
  12767. static Zero(): Size;
  12768. /**
  12769. * Sums the width and height of two sizes
  12770. * @param otherSize size to add to this size
  12771. * @returns a new Size set as the addition result of the current Size and the given one.
  12772. */
  12773. add(otherSize: Size): Size;
  12774. /**
  12775. * Subtracts the width and height of two
  12776. * @param otherSize size to subtract to this size
  12777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12778. */
  12779. subtract(otherSize: Size): Size;
  12780. /**
  12781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. * @param start starting size to lerp between
  12783. * @param end end size to lerp between
  12784. * @param amount amount to lerp between the start and end values
  12785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12786. */
  12787. static Lerp(start: Size, end: Size, amount: number): Size;
  12788. }
  12789. }
  12790. declare module "babylonjs/Animations/runtimeAnimation" {
  12791. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12792. import { Animatable } from "babylonjs/Animations/animatable";
  12793. import { Scene } from "babylonjs/scene";
  12794. /**
  12795. * Defines a runtime animation
  12796. */
  12797. export class RuntimeAnimation {
  12798. private _events;
  12799. /**
  12800. * The current frame of the runtime animation
  12801. */
  12802. private _currentFrame;
  12803. /**
  12804. * The animation used by the runtime animation
  12805. */
  12806. private _animation;
  12807. /**
  12808. * The target of the runtime animation
  12809. */
  12810. private _target;
  12811. /**
  12812. * The initiating animatable
  12813. */
  12814. private _host;
  12815. /**
  12816. * The original value of the runtime animation
  12817. */
  12818. private _originalValue;
  12819. /**
  12820. * The original blend value of the runtime animation
  12821. */
  12822. private _originalBlendValue;
  12823. /**
  12824. * The offsets cache of the runtime animation
  12825. */
  12826. private _offsetsCache;
  12827. /**
  12828. * The high limits cache of the runtime animation
  12829. */
  12830. private _highLimitsCache;
  12831. /**
  12832. * Specifies if the runtime animation has been stopped
  12833. */
  12834. private _stopped;
  12835. /**
  12836. * The blending factor of the runtime animation
  12837. */
  12838. private _blendingFactor;
  12839. /**
  12840. * The BabylonJS scene
  12841. */
  12842. private _scene;
  12843. /**
  12844. * The current value of the runtime animation
  12845. */
  12846. private _currentValue;
  12847. /** @hidden */
  12848. _animationState: _IAnimationState;
  12849. /**
  12850. * The active target of the runtime animation
  12851. */
  12852. private _activeTargets;
  12853. private _currentActiveTarget;
  12854. private _directTarget;
  12855. /**
  12856. * The target path of the runtime animation
  12857. */
  12858. private _targetPath;
  12859. /**
  12860. * The weight of the runtime animation
  12861. */
  12862. private _weight;
  12863. /**
  12864. * The ratio offset of the runtime animation
  12865. */
  12866. private _ratioOffset;
  12867. /**
  12868. * The previous delay of the runtime animation
  12869. */
  12870. private _previousDelay;
  12871. /**
  12872. * The previous ratio of the runtime animation
  12873. */
  12874. private _previousRatio;
  12875. private _enableBlending;
  12876. private _keys;
  12877. private _minFrame;
  12878. private _maxFrame;
  12879. private _minValue;
  12880. private _maxValue;
  12881. private _targetIsArray;
  12882. /**
  12883. * Gets the current frame of the runtime animation
  12884. */
  12885. readonly currentFrame: number;
  12886. /**
  12887. * Gets the weight of the runtime animation
  12888. */
  12889. readonly weight: number;
  12890. /**
  12891. * Gets the current value of the runtime animation
  12892. */
  12893. readonly currentValue: any;
  12894. /**
  12895. * Gets the target path of the runtime animation
  12896. */
  12897. readonly targetPath: string;
  12898. /**
  12899. * Gets the actual target of the runtime animation
  12900. */
  12901. readonly target: any;
  12902. /** @hidden */
  12903. _onLoop: () => void;
  12904. /**
  12905. * Create a new RuntimeAnimation object
  12906. * @param target defines the target of the animation
  12907. * @param animation defines the source animation object
  12908. * @param scene defines the hosting scene
  12909. * @param host defines the initiating Animatable
  12910. */
  12911. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12912. private _preparePath;
  12913. /**
  12914. * Gets the animation from the runtime animation
  12915. */
  12916. readonly animation: Animation;
  12917. /**
  12918. * Resets the runtime animation to the beginning
  12919. * @param restoreOriginal defines whether to restore the target property to the original value
  12920. */
  12921. reset(restoreOriginal?: boolean): void;
  12922. /**
  12923. * Specifies if the runtime animation is stopped
  12924. * @returns Boolean specifying if the runtime animation is stopped
  12925. */
  12926. isStopped(): boolean;
  12927. /**
  12928. * Disposes of the runtime animation
  12929. */
  12930. dispose(): void;
  12931. /**
  12932. * Apply the interpolated value to the target
  12933. * @param currentValue defines the value computed by the animation
  12934. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12935. */
  12936. setValue(currentValue: any, weight: number): void;
  12937. private _getOriginalValues;
  12938. private _setValue;
  12939. /**
  12940. * Gets the loop pmode of the runtime animation
  12941. * @returns Loop Mode
  12942. */
  12943. private _getCorrectLoopMode;
  12944. /**
  12945. * Move the current animation to a given frame
  12946. * @param frame defines the frame to move to
  12947. */
  12948. goToFrame(frame: number): void;
  12949. /**
  12950. * @hidden Internal use only
  12951. */
  12952. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12953. /**
  12954. * Execute the current animation
  12955. * @param delay defines the delay to add to the current frame
  12956. * @param from defines the lower bound of the animation range
  12957. * @param to defines the upper bound of the animation range
  12958. * @param loop defines if the current animation must loop
  12959. * @param speedRatio defines the current speed ratio
  12960. * @param weight defines the weight of the animation (default is -1 so no weight)
  12961. * @param onLoop optional callback called when animation loops
  12962. * @returns a boolean indicating if the animation is running
  12963. */
  12964. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12965. }
  12966. }
  12967. declare module "babylonjs/Animations/animatable" {
  12968. import { Animation } from "babylonjs/Animations/animation";
  12969. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Observable } from "babylonjs/Misc/observable";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12974. import { Node } from "babylonjs/node";
  12975. /**
  12976. * Class used to store an actual running animation
  12977. */
  12978. export class Animatable {
  12979. /** defines the target object */
  12980. target: any;
  12981. /** defines the starting frame number (default is 0) */
  12982. fromFrame: number;
  12983. /** defines the ending frame number (default is 100) */
  12984. toFrame: number;
  12985. /** defines if the animation must loop (default is false) */
  12986. loopAnimation: boolean;
  12987. /** defines a callback to call when animation ends if it is not looping */
  12988. onAnimationEnd?: (() => void) | null | undefined;
  12989. /** defines a callback to call when animation loops */
  12990. onAnimationLoop?: (() => void) | null | undefined;
  12991. private _localDelayOffset;
  12992. private _pausedDelay;
  12993. private _runtimeAnimations;
  12994. private _paused;
  12995. private _scene;
  12996. private _speedRatio;
  12997. private _weight;
  12998. private _syncRoot;
  12999. /**
  13000. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13001. * This will only apply for non looping animation (default is true)
  13002. */
  13003. disposeOnEnd: boolean;
  13004. /**
  13005. * Gets a boolean indicating if the animation has started
  13006. */
  13007. animationStarted: boolean;
  13008. /**
  13009. * Observer raised when the animation ends
  13010. */
  13011. onAnimationEndObservable: Observable<Animatable>;
  13012. /**
  13013. * Observer raised when the animation loops
  13014. */
  13015. onAnimationLoopObservable: Observable<Animatable>;
  13016. /**
  13017. * Gets the root Animatable used to synchronize and normalize animations
  13018. */
  13019. readonly syncRoot: Nullable<Animatable>;
  13020. /**
  13021. * Gets the current frame of the first RuntimeAnimation
  13022. * Used to synchronize Animatables
  13023. */
  13024. readonly masterFrame: number;
  13025. /**
  13026. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13027. */
  13028. weight: number;
  13029. /**
  13030. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13031. */
  13032. speedRatio: number;
  13033. /**
  13034. * Creates a new Animatable
  13035. * @param scene defines the hosting scene
  13036. * @param target defines the target object
  13037. * @param fromFrame defines the starting frame number (default is 0)
  13038. * @param toFrame defines the ending frame number (default is 100)
  13039. * @param loopAnimation defines if the animation must loop (default is false)
  13040. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13041. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13042. * @param animations defines a group of animation to add to the new Animatable
  13043. * @param onAnimationLoop defines a callback to call when animation loops
  13044. */
  13045. constructor(scene: Scene,
  13046. /** defines the target object */
  13047. target: any,
  13048. /** defines the starting frame number (default is 0) */
  13049. fromFrame?: number,
  13050. /** defines the ending frame number (default is 100) */
  13051. toFrame?: number,
  13052. /** defines if the animation must loop (default is false) */
  13053. loopAnimation?: boolean, speedRatio?: number,
  13054. /** defines a callback to call when animation ends if it is not looping */
  13055. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13056. /** defines a callback to call when animation loops */
  13057. onAnimationLoop?: (() => void) | null | undefined);
  13058. /**
  13059. * Synchronize and normalize current Animatable with a source Animatable
  13060. * This is useful when using animation weights and when animations are not of the same length
  13061. * @param root defines the root Animatable to synchronize with
  13062. * @returns the current Animatable
  13063. */
  13064. syncWith(root: Animatable): Animatable;
  13065. /**
  13066. * Gets the list of runtime animations
  13067. * @returns an array of RuntimeAnimation
  13068. */
  13069. getAnimations(): RuntimeAnimation[];
  13070. /**
  13071. * Adds more animations to the current animatable
  13072. * @param target defines the target of the animations
  13073. * @param animations defines the new animations to add
  13074. */
  13075. appendAnimations(target: any, animations: Animation[]): void;
  13076. /**
  13077. * Gets the source animation for a specific property
  13078. * @param property defines the propertyu to look for
  13079. * @returns null or the source animation for the given property
  13080. */
  13081. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13082. /**
  13083. * Gets the runtime animation for a specific property
  13084. * @param property defines the propertyu to look for
  13085. * @returns null or the runtime animation for the given property
  13086. */
  13087. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13088. /**
  13089. * Resets the animatable to its original state
  13090. */
  13091. reset(): void;
  13092. /**
  13093. * Allows the animatable to blend with current running animations
  13094. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13095. * @param blendingSpeed defines the blending speed to use
  13096. */
  13097. enableBlending(blendingSpeed: number): void;
  13098. /**
  13099. * Disable animation blending
  13100. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13101. */
  13102. disableBlending(): void;
  13103. /**
  13104. * Jump directly to a given frame
  13105. * @param frame defines the frame to jump to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * Pause the animation
  13110. */
  13111. pause(): void;
  13112. /**
  13113. * Restart the animation
  13114. */
  13115. restart(): void;
  13116. private _raiseOnAnimationEnd;
  13117. /**
  13118. * Stop and delete the current animation
  13119. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13120. * @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)
  13121. */
  13122. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13123. /**
  13124. * Wait asynchronously for the animation to end
  13125. * @returns a promise which will be fullfilled when the animation ends
  13126. */
  13127. waitAsync(): Promise<Animatable>;
  13128. /** @hidden */
  13129. _animate(delay: number): boolean;
  13130. }
  13131. module "babylonjs/scene" {
  13132. interface Scene {
  13133. /** @hidden */
  13134. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13135. /** @hidden */
  13136. _processLateAnimationBindingsForMatrices(holder: {
  13137. totalWeight: number;
  13138. animations: RuntimeAnimation[];
  13139. originalValue: Matrix;
  13140. }): any;
  13141. /** @hidden */
  13142. _processLateAnimationBindingsForQuaternions(holder: {
  13143. totalWeight: number;
  13144. animations: RuntimeAnimation[];
  13145. originalValue: Quaternion;
  13146. }, refQuaternion: Quaternion): Quaternion;
  13147. /** @hidden */
  13148. _processLateAnimationBindings(): void;
  13149. /**
  13150. * Will start the animation sequence of a given target
  13151. * @param target defines the target
  13152. * @param from defines from which frame should animation start
  13153. * @param to defines until which frame should animation run.
  13154. * @param weight defines the weight to apply to the animation (1.0 by default)
  13155. * @param loop defines if the animation loops
  13156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13157. * @param onAnimationEnd defines the function to be executed when the animation ends
  13158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13160. * @param onAnimationLoop defines the callback to call when an animation loops
  13161. * @returns the animatable object created for this animation
  13162. */
  13163. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13164. /**
  13165. * Will start the animation sequence of a given target
  13166. * @param target defines the target
  13167. * @param from defines from which frame should animation start
  13168. * @param to defines until which frame should animation run.
  13169. * @param loop defines if the animation loops
  13170. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13171. * @param onAnimationEnd defines the function to be executed when the animation ends
  13172. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13173. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13174. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13175. * @param onAnimationLoop defines the callback to call when an animation loops
  13176. * @returns the animatable object created for this animation
  13177. */
  13178. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13179. /**
  13180. * Will start the animation sequence of a given target and its hierarchy
  13181. * @param target defines the target
  13182. * @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.
  13183. * @param from defines from which frame should animation start
  13184. * @param to defines until which frame should animation run.
  13185. * @param loop defines if the animation loops
  13186. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13187. * @param onAnimationEnd defines the function to be executed when the animation ends
  13188. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13189. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13190. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13191. * @param onAnimationLoop defines the callback to call when an animation loops
  13192. * @returns the list of created animatables
  13193. */
  13194. 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[];
  13195. /**
  13196. * Begin a new animation on a given node
  13197. * @param target defines the target where the animation will take place
  13198. * @param animations defines the list of animations to start
  13199. * @param from defines the initial value
  13200. * @param to defines the final value
  13201. * @param loop defines if you want animation to loop (off by default)
  13202. * @param speedRatio defines the speed ratio to apply to all animations
  13203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13204. * @param onAnimationLoop defines the callback to call when an animation loops
  13205. * @returns the list of created animatables
  13206. */
  13207. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13208. /**
  13209. * Begin a new animation on a given node and its hierarchy
  13210. * @param target defines the root node where the animation will take place
  13211. * @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.
  13212. * @param animations defines the list of animations to start
  13213. * @param from defines the initial value
  13214. * @param to defines the final value
  13215. * @param loop defines if you want animation to loop (off by default)
  13216. * @param speedRatio defines the speed ratio to apply to all animations
  13217. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13218. * @param onAnimationLoop defines the callback to call when an animation loops
  13219. * @returns the list of animatables created for all nodes
  13220. */
  13221. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13222. /**
  13223. * Gets the animatable associated with a specific target
  13224. * @param target defines the target of the animatable
  13225. * @returns the required animatable if found
  13226. */
  13227. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13228. /**
  13229. * Gets all animatables associated with a given target
  13230. * @param target defines the target to look animatables for
  13231. * @returns an array of Animatables
  13232. */
  13233. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13234. /**
  13235. * Stops and removes all animations that have been applied to the scene
  13236. */
  13237. stopAllAnimations(): void;
  13238. }
  13239. }
  13240. module "babylonjs/Bones/bone" {
  13241. interface Bone {
  13242. /**
  13243. * Copy an animation range from another bone
  13244. * @param source defines the source bone
  13245. * @param rangeName defines the range name to copy
  13246. * @param frameOffset defines the frame offset
  13247. * @param rescaleAsRequired defines if rescaling must be applied if required
  13248. * @param skelDimensionsRatio defines the scaling ratio
  13249. * @returns true if operation was successful
  13250. */
  13251. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13252. }
  13253. }
  13254. }
  13255. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13256. /**
  13257. * Class used to override all child animations of a given target
  13258. */
  13259. export class AnimationPropertiesOverride {
  13260. /**
  13261. * Gets or sets a value indicating if animation blending must be used
  13262. */
  13263. enableBlending: boolean;
  13264. /**
  13265. * Gets or sets the blending speed to use when enableBlending is true
  13266. */
  13267. blendingSpeed: number;
  13268. /**
  13269. * Gets or sets the default loop mode to use
  13270. */
  13271. loopMode: number;
  13272. }
  13273. }
  13274. declare module "babylonjs/Bones/skeleton" {
  13275. import { Bone } from "babylonjs/Bones/bone";
  13276. import { Observable } from "babylonjs/Misc/observable";
  13277. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13278. import { Scene } from "babylonjs/scene";
  13279. import { Nullable } from "babylonjs/types";
  13280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13281. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13282. import { Animatable } from "babylonjs/Animations/animatable";
  13283. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13284. import { Animation } from "babylonjs/Animations/animation";
  13285. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13286. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13288. /**
  13289. * Class used to handle skinning animations
  13290. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13291. */
  13292. export class Skeleton implements IAnimatable {
  13293. /** defines the skeleton name */
  13294. name: string;
  13295. /** defines the skeleton Id */
  13296. id: string;
  13297. /**
  13298. * Defines the list of child bones
  13299. */
  13300. bones: Bone[];
  13301. /**
  13302. * Defines an estimate of the dimension of the skeleton at rest
  13303. */
  13304. dimensionsAtRest: Vector3;
  13305. /**
  13306. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13307. */
  13308. needInitialSkinMatrix: boolean;
  13309. /**
  13310. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13311. */
  13312. overrideMesh: Nullable<AbstractMesh>;
  13313. /**
  13314. * Gets the list of animations attached to this skeleton
  13315. */
  13316. animations: Array<Animation>;
  13317. private _scene;
  13318. private _isDirty;
  13319. private _transformMatrices;
  13320. private _transformMatrixTexture;
  13321. private _meshesWithPoseMatrix;
  13322. private _animatables;
  13323. private _identity;
  13324. private _synchronizedWithMesh;
  13325. private _ranges;
  13326. private _lastAbsoluteTransformsUpdateId;
  13327. private _canUseTextureForBones;
  13328. private _uniqueId;
  13329. /** @hidden */
  13330. _numBonesWithLinkedTransformNode: number;
  13331. /** @hidden */
  13332. _hasWaitingData: Nullable<boolean>;
  13333. /**
  13334. * Specifies if the skeleton should be serialized
  13335. */
  13336. doNotSerialize: boolean;
  13337. private _useTextureToStoreBoneMatrices;
  13338. /**
  13339. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13340. * Please note that this option is not available if the hardware does not support it
  13341. */
  13342. useTextureToStoreBoneMatrices: boolean;
  13343. private _animationPropertiesOverride;
  13344. /**
  13345. * Gets or sets the animation properties override
  13346. */
  13347. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13348. /**
  13349. * List of inspectable custom properties (used by the Inspector)
  13350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13351. */
  13352. inspectableCustomProperties: IInspectable[];
  13353. /**
  13354. * An observable triggered before computing the skeleton's matrices
  13355. */
  13356. onBeforeComputeObservable: Observable<Skeleton>;
  13357. /**
  13358. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13359. */
  13360. readonly isUsingTextureForMatrices: boolean;
  13361. /**
  13362. * Gets the unique ID of this skeleton
  13363. */
  13364. readonly uniqueId: number;
  13365. /**
  13366. * Creates a new skeleton
  13367. * @param name defines the skeleton name
  13368. * @param id defines the skeleton Id
  13369. * @param scene defines the hosting scene
  13370. */
  13371. constructor(
  13372. /** defines the skeleton name */
  13373. name: string,
  13374. /** defines the skeleton Id */
  13375. id: string, scene: Scene);
  13376. /**
  13377. * Gets the current object class name.
  13378. * @return the class name
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Returns an array containing the root bones
  13383. * @returns an array containing the root bones
  13384. */
  13385. getChildren(): Array<Bone>;
  13386. /**
  13387. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13389. * @returns a Float32Array containing matrices data
  13390. */
  13391. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13392. /**
  13393. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13394. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13395. * @returns a raw texture containing the data
  13396. */
  13397. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13398. /**
  13399. * Gets the current hosting scene
  13400. * @returns a scene object
  13401. */
  13402. getScene(): Scene;
  13403. /**
  13404. * Gets a string representing the current skeleton data
  13405. * @param fullDetails defines a boolean indicating if we want a verbose version
  13406. * @returns a string representing the current skeleton data
  13407. */
  13408. toString(fullDetails?: boolean): string;
  13409. /**
  13410. * Get bone's index searching by name
  13411. * @param name defines bone's name to search for
  13412. * @return the indice of the bone. Returns -1 if not found
  13413. */
  13414. getBoneIndexByName(name: string): number;
  13415. /**
  13416. * Creater a new animation range
  13417. * @param name defines the name of the range
  13418. * @param from defines the start key
  13419. * @param to defines the end key
  13420. */
  13421. createAnimationRange(name: string, from: number, to: number): void;
  13422. /**
  13423. * Delete a specific animation range
  13424. * @param name defines the name of the range
  13425. * @param deleteFrames defines if frames must be removed as well
  13426. */
  13427. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13428. /**
  13429. * Gets a specific animation range
  13430. * @param name defines the name of the range to look for
  13431. * @returns the requested animation range or null if not found
  13432. */
  13433. getAnimationRange(name: string): Nullable<AnimationRange>;
  13434. /**
  13435. * Gets the list of all animation ranges defined on this skeleton
  13436. * @returns an array
  13437. */
  13438. getAnimationRanges(): Nullable<AnimationRange>[];
  13439. /**
  13440. * Copy animation range from a source skeleton.
  13441. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13442. * @param source defines the source skeleton
  13443. * @param name defines the name of the range to copy
  13444. * @param rescaleAsRequired defines if rescaling must be applied if required
  13445. * @returns true if operation was successful
  13446. */
  13447. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13448. /**
  13449. * Forces the skeleton to go to rest pose
  13450. */
  13451. returnToRest(): void;
  13452. private _getHighestAnimationFrame;
  13453. /**
  13454. * Begin a specific animation range
  13455. * @param name defines the name of the range to start
  13456. * @param loop defines if looping must be turned on (false by default)
  13457. * @param speedRatio defines the speed ratio to apply (1 by default)
  13458. * @param onAnimationEnd defines a callback which will be called when animation will end
  13459. * @returns a new animatable
  13460. */
  13461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13462. /** @hidden */
  13463. _markAsDirty(): void;
  13464. /** @hidden */
  13465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13466. /** @hidden */
  13467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13468. private _computeTransformMatrices;
  13469. /**
  13470. * Build all resources required to render a skeleton
  13471. */
  13472. prepare(): void;
  13473. /**
  13474. * Gets the list of animatables currently running for this skeleton
  13475. * @returns an array of animatables
  13476. */
  13477. getAnimatables(): IAnimatable[];
  13478. /**
  13479. * Clone the current skeleton
  13480. * @param name defines the name of the new skeleton
  13481. * @param id defines the id of the new skeleton
  13482. * @returns the new skeleton
  13483. */
  13484. clone(name: string, id: string): Skeleton;
  13485. /**
  13486. * Enable animation blending for this skeleton
  13487. * @param blendingSpeed defines the blending speed to apply
  13488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13489. */
  13490. enableBlending(blendingSpeed?: number): void;
  13491. /**
  13492. * Releases all resources associated with the current skeleton
  13493. */
  13494. dispose(): void;
  13495. /**
  13496. * Serialize the skeleton in a JSON object
  13497. * @returns a JSON object
  13498. */
  13499. serialize(): any;
  13500. /**
  13501. * Creates a new skeleton from serialized data
  13502. * @param parsedSkeleton defines the serialized data
  13503. * @param scene defines the hosting scene
  13504. * @returns a new skeleton
  13505. */
  13506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13507. /**
  13508. * Compute all node absolute transforms
  13509. * @param forceUpdate defines if computation must be done even if cache is up to date
  13510. */
  13511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13512. /**
  13513. * Gets the root pose matrix
  13514. * @returns a matrix
  13515. */
  13516. getPoseMatrix(): Nullable<Matrix>;
  13517. /**
  13518. * Sorts bones per internal index
  13519. */
  13520. sortBones(): void;
  13521. private _sortBones;
  13522. }
  13523. }
  13524. declare module "babylonjs/Bones/bone" {
  13525. import { Skeleton } from "babylonjs/Bones/skeleton";
  13526. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13529. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13530. import { Node } from "babylonjs/node";
  13531. import { Space } from "babylonjs/Maths/math.axis";
  13532. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13533. /**
  13534. * Class used to store bone information
  13535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13536. */
  13537. export class Bone extends Node {
  13538. /**
  13539. * defines the bone name
  13540. */
  13541. name: string;
  13542. private static _tmpVecs;
  13543. private static _tmpQuat;
  13544. private static _tmpMats;
  13545. /**
  13546. * Gets the list of child bones
  13547. */
  13548. children: Bone[];
  13549. /** Gets the animations associated with this bone */
  13550. animations: import("babylonjs/Animations/animation").Animation[];
  13551. /**
  13552. * Gets or sets bone length
  13553. */
  13554. length: number;
  13555. /**
  13556. * @hidden Internal only
  13557. * Set this value to map this bone to a different index in the transform matrices
  13558. * Set this value to -1 to exclude the bone from the transform matrices
  13559. */
  13560. _index: Nullable<number>;
  13561. private _skeleton;
  13562. private _localMatrix;
  13563. private _restPose;
  13564. private _baseMatrix;
  13565. private _absoluteTransform;
  13566. private _invertedAbsoluteTransform;
  13567. private _parent;
  13568. private _scalingDeterminant;
  13569. private _worldTransform;
  13570. private _localScaling;
  13571. private _localRotation;
  13572. private _localPosition;
  13573. private _needToDecompose;
  13574. private _needToCompose;
  13575. /** @hidden */
  13576. _linkedTransformNode: Nullable<TransformNode>;
  13577. /** @hidden */
  13578. _waitingTransformNodeId: Nullable<string>;
  13579. /** @hidden */
  13580. /** @hidden */
  13581. _matrix: Matrix;
  13582. /**
  13583. * Create a new bone
  13584. * @param name defines the bone name
  13585. * @param skeleton defines the parent skeleton
  13586. * @param parentBone defines the parent (can be null if the bone is the root)
  13587. * @param localMatrix defines the local matrix
  13588. * @param restPose defines the rest pose matrix
  13589. * @param baseMatrix defines the base matrix
  13590. * @param index defines index of the bone in the hiearchy
  13591. */
  13592. constructor(
  13593. /**
  13594. * defines the bone name
  13595. */
  13596. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13597. /**
  13598. * Gets the current object class name.
  13599. * @return the class name
  13600. */
  13601. getClassName(): string;
  13602. /**
  13603. * Gets the parent skeleton
  13604. * @returns a skeleton
  13605. */
  13606. getSkeleton(): Skeleton;
  13607. /**
  13608. * Gets parent bone
  13609. * @returns a bone or null if the bone is the root of the bone hierarchy
  13610. */
  13611. getParent(): Nullable<Bone>;
  13612. /**
  13613. * Returns an array containing the root bones
  13614. * @returns an array containing the root bones
  13615. */
  13616. getChildren(): Array<Bone>;
  13617. /**
  13618. * Sets the parent bone
  13619. * @param parent defines the parent (can be null if the bone is the root)
  13620. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13621. */
  13622. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13623. /**
  13624. * Gets the local matrix
  13625. * @returns a matrix
  13626. */
  13627. getLocalMatrix(): Matrix;
  13628. /**
  13629. * Gets the base matrix (initial matrix which remains unchanged)
  13630. * @returns a matrix
  13631. */
  13632. getBaseMatrix(): Matrix;
  13633. /**
  13634. * Gets the rest pose matrix
  13635. * @returns a matrix
  13636. */
  13637. getRestPose(): Matrix;
  13638. /**
  13639. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13640. */
  13641. getWorldMatrix(): Matrix;
  13642. /**
  13643. * Sets the local matrix to rest pose matrix
  13644. */
  13645. returnToRest(): void;
  13646. /**
  13647. * Gets the inverse of the absolute transform matrix.
  13648. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13649. * @returns a matrix
  13650. */
  13651. getInvertedAbsoluteTransform(): Matrix;
  13652. /**
  13653. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13654. * @returns a matrix
  13655. */
  13656. getAbsoluteTransform(): Matrix;
  13657. /**
  13658. * Links with the given transform node.
  13659. * The local matrix of this bone is copied from the transform node every frame.
  13660. * @param transformNode defines the transform node to link to
  13661. */
  13662. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13663. /**
  13664. * Gets the node used to drive the bone's transformation
  13665. * @returns a transform node or null
  13666. */
  13667. getTransformNode(): Nullable<TransformNode>;
  13668. /** Gets or sets current position (in local space) */
  13669. position: Vector3;
  13670. /** Gets or sets current rotation (in local space) */
  13671. rotation: Vector3;
  13672. /** Gets or sets current rotation quaternion (in local space) */
  13673. rotationQuaternion: Quaternion;
  13674. /** Gets or sets current scaling (in local space) */
  13675. scaling: Vector3;
  13676. /**
  13677. * Gets the animation properties override
  13678. */
  13679. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13680. private _decompose;
  13681. private _compose;
  13682. /**
  13683. * Update the base and local matrices
  13684. * @param matrix defines the new base or local matrix
  13685. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13686. * @param updateLocalMatrix defines if the local matrix should be updated
  13687. */
  13688. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13689. /** @hidden */
  13690. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13691. /**
  13692. * Flag the bone as dirty (Forcing it to update everything)
  13693. */
  13694. markAsDirty(): void;
  13695. /** @hidden */
  13696. _markAsDirtyAndCompose(): void;
  13697. private _markAsDirtyAndDecompose;
  13698. /**
  13699. * Translate the bone in local or world space
  13700. * @param vec The amount to translate the bone
  13701. * @param space The space that the translation is in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. */
  13704. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13705. /**
  13706. * Set the postion of the bone in local or world space
  13707. * @param position The position to set the bone
  13708. * @param space The space that the position is in
  13709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13710. */
  13711. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13712. /**
  13713. * Set the absolute position of the bone (world space)
  13714. * @param position The position to set the bone
  13715. * @param mesh The mesh that this bone is attached to
  13716. */
  13717. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13718. /**
  13719. * Scale the bone on the x, y and z axes (in local space)
  13720. * @param x The amount to scale the bone on the x axis
  13721. * @param y The amount to scale the bone on the y axis
  13722. * @param z The amount to scale the bone on the z axis
  13723. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13724. */
  13725. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13726. /**
  13727. * Set the bone scaling in local space
  13728. * @param scale defines the scaling vector
  13729. */
  13730. setScale(scale: Vector3): void;
  13731. /**
  13732. * Gets the current scaling in local space
  13733. * @returns the current scaling vector
  13734. */
  13735. getScale(): Vector3;
  13736. /**
  13737. * Gets the current scaling in local space and stores it in a target vector
  13738. * @param result defines the target vector
  13739. */
  13740. getScaleToRef(result: Vector3): void;
  13741. /**
  13742. * Set the yaw, pitch, and roll of the bone in local or world space
  13743. * @param yaw The rotation of the bone on the y axis
  13744. * @param pitch The rotation of the bone on the x axis
  13745. * @param roll The rotation of the bone on the z axis
  13746. * @param space The space that the axes of rotation are in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. */
  13749. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13750. /**
  13751. * Add a rotation to the bone on an axis in local or world space
  13752. * @param axis The axis to rotate the bone on
  13753. * @param amount The amount to rotate the bone
  13754. * @param space The space that the axis is in
  13755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13756. */
  13757. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13758. /**
  13759. * Set the rotation of the bone to a particular axis angle in local or world space
  13760. * @param axis The axis to rotate the bone on
  13761. * @param angle The angle that the bone should be rotated to
  13762. * @param space The space that the axis is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the euler rotation of the bone in local of world space
  13768. * @param rotation The euler rotation that the bone should be set to
  13769. * @param space The space that the rotation is in
  13770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13771. */
  13772. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13773. /**
  13774. * Set the quaternion rotation of the bone in local of world space
  13775. * @param quat The quaternion rotation that the bone should be set to
  13776. * @param space The space that the rotation is in
  13777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13778. */
  13779. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Set the rotation matrix of the bone in local of world space
  13782. * @param rotMat The rotation matrix that the bone should be set to
  13783. * @param space The space that the rotation is in
  13784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13785. */
  13786. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13787. private _rotateWithMatrix;
  13788. private _getNegativeRotationToRef;
  13789. /**
  13790. * Get the position of the bone in local or world space
  13791. * @param space The space that the returned position is in
  13792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13793. * @returns The position of the bone
  13794. */
  13795. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13796. /**
  13797. * Copy the position of the bone to a vector3 in local or world space
  13798. * @param space The space that the returned position is in
  13799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13800. * @param result The vector3 to copy the position to
  13801. */
  13802. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13803. /**
  13804. * Get the absolute position of the bone (world space)
  13805. * @param mesh The mesh that this bone is attached to
  13806. * @returns The absolute position of the bone
  13807. */
  13808. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13809. /**
  13810. * Copy the absolute position of the bone (world space) to the result param
  13811. * @param mesh The mesh that this bone is attached to
  13812. * @param result The vector3 to copy the absolute position to
  13813. */
  13814. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13815. /**
  13816. * Compute the absolute transforms of this bone and its children
  13817. */
  13818. computeAbsoluteTransforms(): void;
  13819. /**
  13820. * Get the world direction from an axis that is in the local space of the bone
  13821. * @param localAxis The local direction that is used to compute the world direction
  13822. * @param mesh The mesh that this bone is attached to
  13823. * @returns The world direction
  13824. */
  13825. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13826. /**
  13827. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13828. * @param localAxis The local direction that is used to compute the world direction
  13829. * @param mesh The mesh that this bone is attached to
  13830. * @param result The vector3 that the world direction will be copied to
  13831. */
  13832. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13833. /**
  13834. * Get the euler rotation of the bone in local or world space
  13835. * @param space The space that the rotation should be in
  13836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13837. * @returns The euler rotation
  13838. */
  13839. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13840. /**
  13841. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13842. * @param space The space that the rotation should be in
  13843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13844. * @param result The vector3 that the rotation should be copied to
  13845. */
  13846. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13847. /**
  13848. * Get the quaternion rotation of the bone in either local or world space
  13849. * @param space The space that the rotation should be in
  13850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13851. * @returns The quaternion rotation
  13852. */
  13853. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13854. /**
  13855. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13856. * @param space The space that the rotation should be in
  13857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13858. * @param result The quaternion that the rotation should be copied to
  13859. */
  13860. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13861. /**
  13862. * Get the rotation matrix of the bone in local or world space
  13863. * @param space The space that the rotation should be in
  13864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13865. * @returns The rotation matrix
  13866. */
  13867. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13868. /**
  13869. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13870. * @param space The space that the rotation should be in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. * @param result The quaternion that the rotation should be copied to
  13873. */
  13874. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13875. /**
  13876. * Get the world position of a point that is in the local space of the bone
  13877. * @param position The local position
  13878. * @param mesh The mesh that this bone is attached to
  13879. * @returns The world position
  13880. */
  13881. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13882. /**
  13883. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13884. * @param position The local position
  13885. * @param mesh The mesh that this bone is attached to
  13886. * @param result The vector3 that the world position should be copied to
  13887. */
  13888. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13889. /**
  13890. * Get the local position of a point that is in world space
  13891. * @param position The world position
  13892. * @param mesh The mesh that this bone is attached to
  13893. * @returns The local position
  13894. */
  13895. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13896. /**
  13897. * Get the local position of a point that is in world space and copy it to the result param
  13898. * @param position The world position
  13899. * @param mesh The mesh that this bone is attached to
  13900. * @param result The vector3 that the local position should be copied to
  13901. */
  13902. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13903. }
  13904. }
  13905. declare module "babylonjs/Meshes/transformNode" {
  13906. import { DeepImmutable } from "babylonjs/types";
  13907. import { Observable } from "babylonjs/Misc/observable";
  13908. import { Nullable } from "babylonjs/types";
  13909. import { Camera } from "babylonjs/Cameras/camera";
  13910. import { Scene } from "babylonjs/scene";
  13911. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13912. import { Node } from "babylonjs/node";
  13913. import { Bone } from "babylonjs/Bones/bone";
  13914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13915. import { Space } from "babylonjs/Maths/math.axis";
  13916. /**
  13917. * 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.
  13918. * @see https://doc.babylonjs.com/how_to/transformnode
  13919. */
  13920. export class TransformNode extends Node {
  13921. /**
  13922. * Object will not rotate to face the camera
  13923. */
  13924. static BILLBOARDMODE_NONE: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the x axis
  13927. */
  13928. static BILLBOARDMODE_X: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the y axis
  13931. */
  13932. static BILLBOARDMODE_Y: number;
  13933. /**
  13934. * Object will rotate to face the camera but only on the z axis
  13935. */
  13936. static BILLBOARDMODE_Z: number;
  13937. /**
  13938. * Object will rotate to face the camera
  13939. */
  13940. static BILLBOARDMODE_ALL: number;
  13941. private _forward;
  13942. private _forwardInverted;
  13943. private _up;
  13944. private _right;
  13945. private _rightInverted;
  13946. private _position;
  13947. private _rotation;
  13948. private _rotationQuaternion;
  13949. protected _scaling: Vector3;
  13950. protected _isDirty: boolean;
  13951. private _transformToBoneReferal;
  13952. private _isAbsoluteSynced;
  13953. private _billboardMode;
  13954. /**
  13955. * Gets or sets the billboard mode. Default is 0.
  13956. *
  13957. * | Value | Type | Description |
  13958. * | --- | --- | --- |
  13959. * | 0 | BILLBOARDMODE_NONE | |
  13960. * | 1 | BILLBOARDMODE_X | |
  13961. * | 2 | BILLBOARDMODE_Y | |
  13962. * | 4 | BILLBOARDMODE_Z | |
  13963. * | 7 | BILLBOARDMODE_ALL | |
  13964. *
  13965. */
  13966. billboardMode: number;
  13967. private _preserveParentRotationForBillboard;
  13968. /**
  13969. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13970. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13971. */
  13972. preserveParentRotationForBillboard: boolean;
  13973. /**
  13974. * 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
  13975. */
  13976. scalingDeterminant: number;
  13977. private _infiniteDistance;
  13978. /**
  13979. * Gets or sets the distance of the object to max, often used by skybox
  13980. */
  13981. infiniteDistance: boolean;
  13982. /**
  13983. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13984. * By default the system will update normals to compensate
  13985. */
  13986. ignoreNonUniformScaling: boolean;
  13987. /**
  13988. * 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
  13989. */
  13990. reIntegrateRotationIntoRotationQuaternion: boolean;
  13991. /** @hidden */
  13992. _poseMatrix: Nullable<Matrix>;
  13993. /** @hidden */
  13994. _localMatrix: Matrix;
  13995. private _usePivotMatrix;
  13996. private _absolutePosition;
  13997. private _absoluteScaling;
  13998. private _absoluteRotationQuaternion;
  13999. private _pivotMatrix;
  14000. private _pivotMatrixInverse;
  14001. protected _postMultiplyPivotMatrix: boolean;
  14002. protected _isWorldMatrixFrozen: boolean;
  14003. /** @hidden */
  14004. _indexInSceneTransformNodesArray: number;
  14005. /**
  14006. * An event triggered after the world matrix is updated
  14007. */
  14008. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14009. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14010. /**
  14011. * Gets a string identifying the name of the class
  14012. * @returns "TransformNode" string
  14013. */
  14014. getClassName(): string;
  14015. /**
  14016. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14017. */
  14018. position: Vector3;
  14019. /**
  14020. * 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)).
  14021. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14022. */
  14023. rotation: Vector3;
  14024. /**
  14025. * 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)).
  14026. */
  14027. scaling: Vector3;
  14028. /**
  14029. * 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).
  14030. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14031. */
  14032. rotationQuaternion: Nullable<Quaternion>;
  14033. /**
  14034. * The forward direction of that transform in world space.
  14035. */
  14036. readonly forward: Vector3;
  14037. /**
  14038. * The up direction of that transform in world space.
  14039. */
  14040. readonly up: Vector3;
  14041. /**
  14042. * The right direction of that transform in world space.
  14043. */
  14044. readonly right: Vector3;
  14045. /**
  14046. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14047. * @param matrix the matrix to copy the pose from
  14048. * @returns this TransformNode.
  14049. */
  14050. updatePoseMatrix(matrix: Matrix): TransformNode;
  14051. /**
  14052. * Returns the mesh Pose matrix.
  14053. * @returns the pose matrix
  14054. */
  14055. getPoseMatrix(): Matrix;
  14056. /** @hidden */
  14057. _isSynchronized(): boolean;
  14058. /** @hidden */
  14059. _initCache(): void;
  14060. /**
  14061. * Flag the transform node as dirty (Forcing it to update everything)
  14062. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14063. * @returns this transform node
  14064. */
  14065. markAsDirty(property: string): TransformNode;
  14066. /**
  14067. * Returns the current mesh absolute position.
  14068. * Returns a Vector3.
  14069. */
  14070. readonly absolutePosition: Vector3;
  14071. /**
  14072. * Returns the current mesh absolute scaling.
  14073. * Returns a Vector3.
  14074. */
  14075. readonly absoluteScaling: Vector3;
  14076. /**
  14077. * Returns the current mesh absolute rotation.
  14078. * Returns a Quaternion.
  14079. */
  14080. readonly absoluteRotationQuaternion: Quaternion;
  14081. /**
  14082. * Sets a new matrix to apply before all other transformation
  14083. * @param matrix defines the transform matrix
  14084. * @returns the current TransformNode
  14085. */
  14086. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14087. /**
  14088. * Sets a new pivot matrix to the current node
  14089. * @param matrix defines the new pivot matrix to use
  14090. * @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
  14091. * @returns the current TransformNode
  14092. */
  14093. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14094. /**
  14095. * Returns the mesh pivot matrix.
  14096. * Default : Identity.
  14097. * @returns the matrix
  14098. */
  14099. getPivotMatrix(): Matrix;
  14100. /**
  14101. * Prevents the World matrix to be computed any longer.
  14102. * @returns the TransformNode.
  14103. */
  14104. freezeWorldMatrix(): TransformNode;
  14105. /**
  14106. * Allows back the World matrix computation.
  14107. * @returns the TransformNode.
  14108. */
  14109. unfreezeWorldMatrix(): this;
  14110. /**
  14111. * True if the World matrix has been frozen.
  14112. */
  14113. readonly isWorldMatrixFrozen: boolean;
  14114. /**
  14115. * Retuns the mesh absolute position in the World.
  14116. * @returns a Vector3.
  14117. */
  14118. getAbsolutePosition(): Vector3;
  14119. /**
  14120. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14121. * @param absolutePosition the absolute position to set
  14122. * @returns the TransformNode.
  14123. */
  14124. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14125. /**
  14126. * Sets the mesh position in its local space.
  14127. * @param vector3 the position to set in localspace
  14128. * @returns the TransformNode.
  14129. */
  14130. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14131. /**
  14132. * Returns the mesh position in the local space from the current World matrix values.
  14133. * @returns a new Vector3.
  14134. */
  14135. getPositionExpressedInLocalSpace(): Vector3;
  14136. /**
  14137. * Translates the mesh along the passed Vector3 in its local space.
  14138. * @param vector3 the distance to translate in localspace
  14139. * @returns the TransformNode.
  14140. */
  14141. locallyTranslate(vector3: Vector3): TransformNode;
  14142. private static _lookAtVectorCache;
  14143. /**
  14144. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14145. * @param targetPoint the position (must be in same space as current mesh) to look at
  14146. * @param yawCor optional yaw (y-axis) correction in radians
  14147. * @param pitchCor optional pitch (x-axis) correction in radians
  14148. * @param rollCor optional roll (z-axis) correction in radians
  14149. * @param space the choosen space of the target
  14150. * @returns the TransformNode.
  14151. */
  14152. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14153. /**
  14154. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14155. * This Vector3 is expressed in the World space.
  14156. * @param localAxis axis to rotate
  14157. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14158. */
  14159. getDirection(localAxis: Vector3): Vector3;
  14160. /**
  14161. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14162. * localAxis is expressed in the mesh local space.
  14163. * result is computed in the Wordl space from the mesh World matrix.
  14164. * @param localAxis axis to rotate
  14165. * @param result the resulting transformnode
  14166. * @returns this TransformNode.
  14167. */
  14168. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14169. /**
  14170. * Sets this transform node rotation to the given local axis.
  14171. * @param localAxis the axis in local space
  14172. * @param yawCor optional yaw (y-axis) correction in radians
  14173. * @param pitchCor optional pitch (x-axis) correction in radians
  14174. * @param rollCor optional roll (z-axis) correction in radians
  14175. * @returns this TransformNode
  14176. */
  14177. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14178. /**
  14179. * Sets a new pivot point to the current node
  14180. * @param point defines the new pivot point to use
  14181. * @param space defines if the point is in world or local space (local by default)
  14182. * @returns the current TransformNode
  14183. */
  14184. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14185. /**
  14186. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14187. * @returns the pivot point
  14188. */
  14189. getPivotPoint(): Vector3;
  14190. /**
  14191. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14192. * @param result the vector3 to store the result
  14193. * @returns this TransformNode.
  14194. */
  14195. getPivotPointToRef(result: Vector3): TransformNode;
  14196. /**
  14197. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14198. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14199. */
  14200. getAbsolutePivotPoint(): Vector3;
  14201. /**
  14202. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14203. * @param result vector3 to store the result
  14204. * @returns this TransformNode.
  14205. */
  14206. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14207. /**
  14208. * Defines the passed node as the parent of the current node.
  14209. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14210. * @see https://doc.babylonjs.com/how_to/parenting
  14211. * @param node the node ot set as the parent
  14212. * @returns this TransformNode.
  14213. */
  14214. setParent(node: Nullable<Node>): TransformNode;
  14215. private _nonUniformScaling;
  14216. /**
  14217. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14218. */
  14219. readonly nonUniformScaling: boolean;
  14220. /** @hidden */
  14221. _updateNonUniformScalingState(value: boolean): boolean;
  14222. /**
  14223. * Attach the current TransformNode to another TransformNode associated with a bone
  14224. * @param bone Bone affecting the TransformNode
  14225. * @param affectedTransformNode TransformNode associated with the bone
  14226. * @returns this object
  14227. */
  14228. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14229. /**
  14230. * Detach the transform node if its associated with a bone
  14231. * @returns this object
  14232. */
  14233. detachFromBone(): TransformNode;
  14234. private static _rotationAxisCache;
  14235. /**
  14236. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14237. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14238. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14239. * The passed axis is also normalized.
  14240. * @param axis the axis to rotate around
  14241. * @param amount the amount to rotate in radians
  14242. * @param space Space to rotate in (Default: local)
  14243. * @returns the TransformNode.
  14244. */
  14245. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14246. /**
  14247. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14248. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14249. * The passed axis is also normalized. .
  14250. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14251. * @param point the point to rotate around
  14252. * @param axis the axis to rotate around
  14253. * @param amount the amount to rotate in radians
  14254. * @returns the TransformNode
  14255. */
  14256. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14257. /**
  14258. * Translates the mesh along the axis vector for the passed distance in the given space.
  14259. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14260. * @param axis the axis to translate in
  14261. * @param distance the distance to translate
  14262. * @param space Space to rotate in (Default: local)
  14263. * @returns the TransformNode.
  14264. */
  14265. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14266. /**
  14267. * Adds a rotation step to the mesh current rotation.
  14268. * x, y, z are Euler angles expressed in radians.
  14269. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14270. * This means this rotation is made in the mesh local space only.
  14271. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14272. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14273. * ```javascript
  14274. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14275. * ```
  14276. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14277. * 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.
  14278. * @param x Rotation to add
  14279. * @param y Rotation to add
  14280. * @param z Rotation to add
  14281. * @returns the TransformNode.
  14282. */
  14283. addRotation(x: number, y: number, z: number): TransformNode;
  14284. /**
  14285. * @hidden
  14286. */
  14287. protected _getEffectiveParent(): Nullable<Node>;
  14288. /**
  14289. * Computes the world matrix of the node
  14290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14291. * @returns the world matrix
  14292. */
  14293. computeWorldMatrix(force?: boolean): Matrix;
  14294. protected _afterComputeWorldMatrix(): void;
  14295. /**
  14296. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14297. * @param func callback function to add
  14298. *
  14299. * @returns the TransformNode.
  14300. */
  14301. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14302. /**
  14303. * Removes a registered callback function.
  14304. * @param func callback function to remove
  14305. * @returns the TransformNode.
  14306. */
  14307. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14308. /**
  14309. * Gets the position of the current mesh in camera space
  14310. * @param camera defines the camera to use
  14311. * @returns a position
  14312. */
  14313. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14314. /**
  14315. * Returns the distance from the mesh to the active camera
  14316. * @param camera defines the camera to use
  14317. * @returns the distance
  14318. */
  14319. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14320. /**
  14321. * Clone the current transform node
  14322. * @param name Name of the new clone
  14323. * @param newParent New parent for the clone
  14324. * @param doNotCloneChildren Do not clone children hierarchy
  14325. * @returns the new transform node
  14326. */
  14327. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14328. /**
  14329. * Serializes the objects information.
  14330. * @param currentSerializationObject defines the object to serialize in
  14331. * @returns the serialized object
  14332. */
  14333. serialize(currentSerializationObject?: any): any;
  14334. /**
  14335. * Returns a new TransformNode object parsed from the source provided.
  14336. * @param parsedTransformNode is the source.
  14337. * @param scene the scne the object belongs to
  14338. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14339. * @returns a new TransformNode object parsed from the source provided.
  14340. */
  14341. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14342. /**
  14343. * Get all child-transformNodes of this node
  14344. * @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
  14345. * @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
  14346. * @returns an array of TransformNode
  14347. */
  14348. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14349. /**
  14350. * Releases resources associated with this transform node.
  14351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14353. */
  14354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14355. /**
  14356. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14357. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14358. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14359. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14360. * @returns the current mesh
  14361. */
  14362. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14363. private _syncAbsoluteScalingAndRotation;
  14364. }
  14365. }
  14366. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14367. import { Observable } from "babylonjs/Misc/observable";
  14368. import { Nullable } from "babylonjs/types";
  14369. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14372. import { Ray } from "babylonjs/Culling/ray";
  14373. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14374. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14375. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14376. /**
  14377. * Defines the types of pose enabled controllers that are supported
  14378. */
  14379. export enum PoseEnabledControllerType {
  14380. /**
  14381. * HTC Vive
  14382. */
  14383. VIVE = 0,
  14384. /**
  14385. * Oculus Rift
  14386. */
  14387. OCULUS = 1,
  14388. /**
  14389. * Windows mixed reality
  14390. */
  14391. WINDOWS = 2,
  14392. /**
  14393. * Samsung gear VR
  14394. */
  14395. GEAR_VR = 3,
  14396. /**
  14397. * Google Daydream
  14398. */
  14399. DAYDREAM = 4,
  14400. /**
  14401. * Generic
  14402. */
  14403. GENERIC = 5
  14404. }
  14405. /**
  14406. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14407. */
  14408. export interface MutableGamepadButton {
  14409. /**
  14410. * Value of the button/trigger
  14411. */
  14412. value: number;
  14413. /**
  14414. * If the button/trigger is currently touched
  14415. */
  14416. touched: boolean;
  14417. /**
  14418. * If the button/trigger is currently pressed
  14419. */
  14420. pressed: boolean;
  14421. }
  14422. /**
  14423. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14424. * @hidden
  14425. */
  14426. export interface ExtendedGamepadButton extends GamepadButton {
  14427. /**
  14428. * If the button/trigger is currently pressed
  14429. */
  14430. readonly pressed: boolean;
  14431. /**
  14432. * If the button/trigger is currently touched
  14433. */
  14434. readonly touched: boolean;
  14435. /**
  14436. * Value of the button/trigger
  14437. */
  14438. readonly value: number;
  14439. }
  14440. /** @hidden */
  14441. export interface _GamePadFactory {
  14442. /**
  14443. * Returns wether or not the current gamepad can be created for this type of controller.
  14444. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14445. * @returns true if it can be created, otherwise false
  14446. */
  14447. canCreate(gamepadInfo: any): boolean;
  14448. /**
  14449. * Creates a new instance of the Gamepad.
  14450. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14451. * @returns the new gamepad instance
  14452. */
  14453. create(gamepadInfo: any): Gamepad;
  14454. }
  14455. /**
  14456. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14457. */
  14458. export class PoseEnabledControllerHelper {
  14459. /** @hidden */
  14460. static _ControllerFactories: _GamePadFactory[];
  14461. /** @hidden */
  14462. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14463. /**
  14464. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14465. * @param vrGamepad the gamepad to initialized
  14466. * @returns a vr controller of the type the gamepad identified as
  14467. */
  14468. static InitiateController(vrGamepad: any): Gamepad;
  14469. }
  14470. /**
  14471. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14472. */
  14473. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14474. /**
  14475. * If the controller is used in a webXR session
  14476. */
  14477. isXR: boolean;
  14478. private _deviceRoomPosition;
  14479. private _deviceRoomRotationQuaternion;
  14480. /**
  14481. * The device position in babylon space
  14482. */
  14483. devicePosition: Vector3;
  14484. /**
  14485. * The device rotation in babylon space
  14486. */
  14487. deviceRotationQuaternion: Quaternion;
  14488. /**
  14489. * The scale factor of the device in babylon space
  14490. */
  14491. deviceScaleFactor: number;
  14492. /**
  14493. * (Likely devicePosition should be used instead) The device position in its room space
  14494. */
  14495. position: Vector3;
  14496. /**
  14497. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14498. */
  14499. rotationQuaternion: Quaternion;
  14500. /**
  14501. * The type of controller (Eg. Windows mixed reality)
  14502. */
  14503. controllerType: PoseEnabledControllerType;
  14504. protected _calculatedPosition: Vector3;
  14505. private _calculatedRotation;
  14506. /**
  14507. * The raw pose from the device
  14508. */
  14509. rawPose: DevicePose;
  14510. private _trackPosition;
  14511. private _maxRotationDistFromHeadset;
  14512. private _draggedRoomRotation;
  14513. /**
  14514. * @hidden
  14515. */
  14516. _disableTrackPosition(fixedPosition: Vector3): void;
  14517. /**
  14518. * Internal, the mesh attached to the controller
  14519. * @hidden
  14520. */
  14521. _mesh: Nullable<AbstractMesh>;
  14522. private _poseControlledCamera;
  14523. private _leftHandSystemQuaternion;
  14524. /**
  14525. * Internal, matrix used to convert room space to babylon space
  14526. * @hidden
  14527. */
  14528. _deviceToWorld: Matrix;
  14529. /**
  14530. * Node to be used when casting a ray from the controller
  14531. * @hidden
  14532. */
  14533. _pointingPoseNode: Nullable<TransformNode>;
  14534. /**
  14535. * Name of the child mesh that can be used to cast a ray from the controller
  14536. */
  14537. static readonly POINTING_POSE: string;
  14538. /**
  14539. * Creates a new PoseEnabledController from a gamepad
  14540. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14541. */
  14542. constructor(browserGamepad: any);
  14543. private _workingMatrix;
  14544. /**
  14545. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14546. */
  14547. update(): void;
  14548. /**
  14549. * Updates only the pose device and mesh without doing any button event checking
  14550. */
  14551. protected _updatePoseAndMesh(): void;
  14552. /**
  14553. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14554. * @param poseData raw pose fromthe device
  14555. */
  14556. updateFromDevice(poseData: DevicePose): void;
  14557. /**
  14558. * @hidden
  14559. */
  14560. _meshAttachedObservable: Observable<AbstractMesh>;
  14561. /**
  14562. * Attaches a mesh to the controller
  14563. * @param mesh the mesh to be attached
  14564. */
  14565. attachToMesh(mesh: AbstractMesh): void;
  14566. /**
  14567. * Attaches the controllers mesh to a camera
  14568. * @param camera the camera the mesh should be attached to
  14569. */
  14570. attachToPoseControlledCamera(camera: TargetCamera): void;
  14571. /**
  14572. * Disposes of the controller
  14573. */
  14574. dispose(): void;
  14575. /**
  14576. * The mesh that is attached to the controller
  14577. */
  14578. readonly mesh: Nullable<AbstractMesh>;
  14579. /**
  14580. * Gets the ray of the controller in the direction the controller is pointing
  14581. * @param length the length the resulting ray should be
  14582. * @returns a ray in the direction the controller is pointing
  14583. */
  14584. getForwardRay(length?: number): Ray;
  14585. }
  14586. }
  14587. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14588. import { Observable } from "babylonjs/Misc/observable";
  14589. import { Scene } from "babylonjs/scene";
  14590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14591. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14592. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14593. /**
  14594. * Defines the WebVRController object that represents controllers tracked in 3D space
  14595. */
  14596. export abstract class WebVRController extends PoseEnabledController {
  14597. /**
  14598. * Internal, the default controller model for the controller
  14599. */
  14600. protected _defaultModel: AbstractMesh;
  14601. /**
  14602. * Fired when the trigger state has changed
  14603. */
  14604. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14605. /**
  14606. * Fired when the main button state has changed
  14607. */
  14608. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the secondary button state has changed
  14611. */
  14612. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when the pad state has changed
  14615. */
  14616. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14617. /**
  14618. * Fired when controllers stick values have changed
  14619. */
  14620. onPadValuesChangedObservable: Observable<StickValues>;
  14621. /**
  14622. * Array of button availible on the controller
  14623. */
  14624. protected _buttons: Array<MutableGamepadButton>;
  14625. private _onButtonStateChange;
  14626. /**
  14627. * Fired when a controller button's state has changed
  14628. * @param callback the callback containing the button that was modified
  14629. */
  14630. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14631. /**
  14632. * X and Y axis corresponding to the controllers joystick
  14633. */
  14634. pad: StickValues;
  14635. /**
  14636. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14637. */
  14638. hand: string;
  14639. /**
  14640. * The default controller model for the controller
  14641. */
  14642. readonly defaultModel: AbstractMesh;
  14643. /**
  14644. * Creates a new WebVRController from a gamepad
  14645. * @param vrGamepad the gamepad that the WebVRController should be created from
  14646. */
  14647. constructor(vrGamepad: any);
  14648. /**
  14649. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14650. */
  14651. update(): void;
  14652. /**
  14653. * Function to be called when a button is modified
  14654. */
  14655. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14656. /**
  14657. * Loads a mesh and attaches it to the controller
  14658. * @param scene the scene the mesh should be added to
  14659. * @param meshLoaded callback for when the mesh has been loaded
  14660. */
  14661. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14662. private _setButtonValue;
  14663. private _changes;
  14664. private _checkChanges;
  14665. /**
  14666. * Disposes of th webVRCOntroller
  14667. */
  14668. dispose(): void;
  14669. }
  14670. }
  14671. declare module "babylonjs/Lights/hemisphericLight" {
  14672. import { Nullable } from "babylonjs/types";
  14673. import { Scene } from "babylonjs/scene";
  14674. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14675. import { Color3 } from "babylonjs/Maths/math.color";
  14676. import { Effect } from "babylonjs/Materials/effect";
  14677. import { Light } from "babylonjs/Lights/light";
  14678. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14679. /**
  14680. * The HemisphericLight simulates the ambient environment light,
  14681. * so the passed direction is the light reflection direction, not the incoming direction.
  14682. */
  14683. export class HemisphericLight extends Light {
  14684. /**
  14685. * The groundColor is the light in the opposite direction to the one specified during creation.
  14686. * 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.
  14687. */
  14688. groundColor: Color3;
  14689. /**
  14690. * The light reflection direction, not the incoming direction.
  14691. */
  14692. direction: Vector3;
  14693. /**
  14694. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14695. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14696. * The HemisphericLight can't cast shadows.
  14697. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14698. * @param name The friendly name of the light
  14699. * @param direction The direction of the light reflection
  14700. * @param scene The scene the light belongs to
  14701. */
  14702. constructor(name: string, direction: Vector3, scene: Scene);
  14703. protected _buildUniformLayout(): void;
  14704. /**
  14705. * Returns the string "HemisphericLight".
  14706. * @return The class name
  14707. */
  14708. getClassName(): string;
  14709. /**
  14710. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14711. * Returns the updated direction.
  14712. * @param target The target the direction should point to
  14713. * @return The computed direction
  14714. */
  14715. setDirectionToTarget(target: Vector3): Vector3;
  14716. /**
  14717. * Returns the shadow generator associated to the light.
  14718. * @returns Always null for hemispheric lights because it does not support shadows.
  14719. */
  14720. getShadowGenerator(): Nullable<IShadowGenerator>;
  14721. /**
  14722. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14723. * @param effect The effect to update
  14724. * @param lightIndex The index of the light in the effect to update
  14725. * @returns The hemispheric light
  14726. */
  14727. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14728. /**
  14729. * Computes the world matrix of the node
  14730. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14731. * @param useWasUpdatedFlag defines a reserved property
  14732. * @returns the world matrix
  14733. */
  14734. computeWorldMatrix(): Matrix;
  14735. /**
  14736. * Returns the integer 3.
  14737. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14738. */
  14739. getTypeID(): number;
  14740. /**
  14741. * Prepares the list of defines specific to the light type.
  14742. * @param defines the list of defines
  14743. * @param lightIndex defines the index of the light for the effect
  14744. */
  14745. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14746. }
  14747. }
  14748. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14749. /** @hidden */
  14750. export var vrMultiviewToSingleviewPixelShader: {
  14751. name: string;
  14752. shader: string;
  14753. };
  14754. }
  14755. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14757. import { Scene } from "babylonjs/scene";
  14758. /**
  14759. * Renders to multiple views with a single draw call
  14760. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14761. */
  14762. export class MultiviewRenderTarget extends RenderTargetTexture {
  14763. /**
  14764. * Creates a multiview render target
  14765. * @param scene scene used with the render target
  14766. * @param size the size of the render target (used for each view)
  14767. */
  14768. constructor(scene: Scene, size?: number | {
  14769. width: number;
  14770. height: number;
  14771. } | {
  14772. ratio: number;
  14773. });
  14774. /**
  14775. * @hidden
  14776. * @param faceIndex the face index, if its a cube texture
  14777. */
  14778. _bindFrameBuffer(faceIndex?: number): void;
  14779. /**
  14780. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14781. * @returns the view count
  14782. */
  14783. getViewCount(): number;
  14784. }
  14785. }
  14786. declare module "babylonjs/Maths/math.frustum" {
  14787. import { Matrix } from "babylonjs/Maths/math.vector";
  14788. import { DeepImmutable } from "babylonjs/types";
  14789. import { Plane } from "babylonjs/Maths/math.plane";
  14790. /**
  14791. * Reprasents a camera frustum
  14792. */
  14793. export class Frustum {
  14794. /**
  14795. * Gets the planes representing the frustum
  14796. * @param transform matrix to be applied to the returned planes
  14797. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14798. */
  14799. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14800. /**
  14801. * Gets the near frustum plane transformed by the transform matrix
  14802. * @param transform transformation matrix to be applied to the resulting frustum plane
  14803. * @param frustumPlane the resuling frustum plane
  14804. */
  14805. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14806. /**
  14807. * Gets the far frustum plane transformed by the transform matrix
  14808. * @param transform transformation matrix to be applied to the resulting frustum plane
  14809. * @param frustumPlane the resuling frustum plane
  14810. */
  14811. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14812. /**
  14813. * Gets the left frustum plane transformed by the transform matrix
  14814. * @param transform transformation matrix to be applied to the resulting frustum plane
  14815. * @param frustumPlane the resuling frustum plane
  14816. */
  14817. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14818. /**
  14819. * Gets the right frustum plane transformed by the transform matrix
  14820. * @param transform transformation matrix to be applied to the resulting frustum plane
  14821. * @param frustumPlane the resuling frustum plane
  14822. */
  14823. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14824. /**
  14825. * Gets the top frustum plane transformed by the transform matrix
  14826. * @param transform transformation matrix to be applied to the resulting frustum plane
  14827. * @param frustumPlane the resuling frustum plane
  14828. */
  14829. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14830. /**
  14831. * Gets the bottom frustum plane transformed by the transform matrix
  14832. * @param transform transformation matrix to be applied to the resulting frustum plane
  14833. * @param frustumPlane the resuling frustum plane
  14834. */
  14835. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14836. /**
  14837. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14838. * @param transform transformation matrix to be applied to the resulting frustum planes
  14839. * @param frustumPlanes the resuling frustum planes
  14840. */
  14841. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14842. }
  14843. }
  14844. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14845. import { Camera } from "babylonjs/Cameras/camera";
  14846. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14847. import { Nullable } from "babylonjs/types";
  14848. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14849. import { Matrix } from "babylonjs/Maths/math.vector";
  14850. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14851. module "babylonjs/Engines/engine" {
  14852. interface Engine {
  14853. /**
  14854. * Creates a new multiview render target
  14855. * @param width defines the width of the texture
  14856. * @param height defines the height of the texture
  14857. * @returns the created multiview texture
  14858. */
  14859. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14860. /**
  14861. * Binds a multiview framebuffer to be drawn to
  14862. * @param multiviewTexture texture to bind
  14863. */
  14864. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14865. }
  14866. }
  14867. module "babylonjs/Cameras/camera" {
  14868. interface Camera {
  14869. /**
  14870. * @hidden
  14871. * 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)
  14872. */
  14873. _useMultiviewToSingleView: boolean;
  14874. /**
  14875. * @hidden
  14876. * 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)
  14877. */
  14878. _multiviewTexture: Nullable<RenderTargetTexture>;
  14879. /**
  14880. * @hidden
  14881. * ensures the multiview texture of the camera exists and has the specified width/height
  14882. * @param width height to set on the multiview texture
  14883. * @param height width to set on the multiview texture
  14884. */
  14885. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14886. }
  14887. }
  14888. module "babylonjs/scene" {
  14889. interface Scene {
  14890. /** @hidden */
  14891. _transformMatrixR: Matrix;
  14892. /** @hidden */
  14893. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14894. /** @hidden */
  14895. _createMultiviewUbo(): void;
  14896. /** @hidden */
  14897. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14898. /** @hidden */
  14899. _renderMultiviewToSingleView(camera: Camera): void;
  14900. }
  14901. }
  14902. }
  14903. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14904. import { Camera } from "babylonjs/Cameras/camera";
  14905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14906. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14907. import "babylonjs/Engines/Extensions/engine.multiview";
  14908. /**
  14909. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14910. * This will not be used for webXR as it supports displaying texture arrays directly
  14911. */
  14912. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14913. /**
  14914. * Initializes a VRMultiviewToSingleview
  14915. * @param name name of the post process
  14916. * @param camera camera to be applied to
  14917. * @param scaleFactor scaling factor to the size of the output texture
  14918. */
  14919. constructor(name: string, camera: Camera, scaleFactor: number);
  14920. }
  14921. }
  14922. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14923. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14924. import { Nullable } from "babylonjs/types";
  14925. import { Size } from "babylonjs/Maths/math.size";
  14926. import { Observable } from "babylonjs/Misc/observable";
  14927. module "babylonjs/Engines/engine" {
  14928. interface Engine {
  14929. /** @hidden */
  14930. _vrDisplay: any;
  14931. /** @hidden */
  14932. _vrSupported: boolean;
  14933. /** @hidden */
  14934. _oldSize: Size;
  14935. /** @hidden */
  14936. _oldHardwareScaleFactor: number;
  14937. /** @hidden */
  14938. _vrExclusivePointerMode: boolean;
  14939. /** @hidden */
  14940. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14941. /** @hidden */
  14942. _onVRDisplayPointerRestricted: () => void;
  14943. /** @hidden */
  14944. _onVRDisplayPointerUnrestricted: () => void;
  14945. /** @hidden */
  14946. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14947. /** @hidden */
  14948. _onVrDisplayDisconnect: Nullable<() => void>;
  14949. /** @hidden */
  14950. _onVrDisplayPresentChange: Nullable<() => void>;
  14951. /**
  14952. * Observable signaled when VR display mode changes
  14953. */
  14954. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14955. /**
  14956. * Observable signaled when VR request present is complete
  14957. */
  14958. onVRRequestPresentComplete: Observable<boolean>;
  14959. /**
  14960. * Observable signaled when VR request present starts
  14961. */
  14962. onVRRequestPresentStart: Observable<Engine>;
  14963. /**
  14964. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14965. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14966. */
  14967. isInVRExclusivePointerMode: boolean;
  14968. /**
  14969. * Gets a boolean indicating if a webVR device was detected
  14970. * @returns true if a webVR device was detected
  14971. */
  14972. isVRDevicePresent(): boolean;
  14973. /**
  14974. * Gets the current webVR device
  14975. * @returns the current webVR device (or null)
  14976. */
  14977. getVRDevice(): any;
  14978. /**
  14979. * Initializes a webVR display and starts listening to display change events
  14980. * The onVRDisplayChangedObservable will be notified upon these changes
  14981. * @returns A promise containing a VRDisplay and if vr is supported
  14982. */
  14983. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14984. /** @hidden */
  14985. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14986. /**
  14987. * Call this function to switch to webVR mode
  14988. * Will do nothing if webVR is not supported or if there is no webVR device
  14989. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14990. */
  14991. enableVR(): void;
  14992. /** @hidden */
  14993. _onVRFullScreenTriggered(): void;
  14994. }
  14995. }
  14996. }
  14997. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14998. import { Nullable } from "babylonjs/types";
  14999. import { Observable } from "babylonjs/Misc/observable";
  15000. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15001. import { Scene } from "babylonjs/scene";
  15002. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15003. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15004. import { Node } from "babylonjs/node";
  15005. import { Ray } from "babylonjs/Culling/ray";
  15006. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15007. import "babylonjs/Engines/Extensions/engine.webVR";
  15008. /**
  15009. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15010. * IMPORTANT!! The data is right-hand data.
  15011. * @export
  15012. * @interface DevicePose
  15013. */
  15014. export interface DevicePose {
  15015. /**
  15016. * The position of the device, values in array are [x,y,z].
  15017. */
  15018. readonly position: Nullable<Float32Array>;
  15019. /**
  15020. * The linearVelocity of the device, values in array are [x,y,z].
  15021. */
  15022. readonly linearVelocity: Nullable<Float32Array>;
  15023. /**
  15024. * The linearAcceleration of the device, values in array are [x,y,z].
  15025. */
  15026. readonly linearAcceleration: Nullable<Float32Array>;
  15027. /**
  15028. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15029. */
  15030. readonly orientation: Nullable<Float32Array>;
  15031. /**
  15032. * The angularVelocity of the device, values in array are [x,y,z].
  15033. */
  15034. readonly angularVelocity: Nullable<Float32Array>;
  15035. /**
  15036. * The angularAcceleration of the device, values in array are [x,y,z].
  15037. */
  15038. readonly angularAcceleration: Nullable<Float32Array>;
  15039. }
  15040. /**
  15041. * Interface representing a pose controlled object in Babylon.
  15042. * A pose controlled object has both regular pose values as well as pose values
  15043. * from an external device such as a VR head mounted display
  15044. */
  15045. export interface PoseControlled {
  15046. /**
  15047. * The position of the object in babylon space.
  15048. */
  15049. position: Vector3;
  15050. /**
  15051. * The rotation quaternion of the object in babylon space.
  15052. */
  15053. rotationQuaternion: Quaternion;
  15054. /**
  15055. * The position of the device in babylon space.
  15056. */
  15057. devicePosition?: Vector3;
  15058. /**
  15059. * The rotation quaternion of the device in babylon space.
  15060. */
  15061. deviceRotationQuaternion: Quaternion;
  15062. /**
  15063. * The raw pose coming from the device.
  15064. */
  15065. rawPose: Nullable<DevicePose>;
  15066. /**
  15067. * The scale of the device to be used when translating from device space to babylon space.
  15068. */
  15069. deviceScaleFactor: number;
  15070. /**
  15071. * Updates the poseControlled values based on the input device pose.
  15072. * @param poseData the pose data to update the object with
  15073. */
  15074. updateFromDevice(poseData: DevicePose): void;
  15075. }
  15076. /**
  15077. * Set of options to customize the webVRCamera
  15078. */
  15079. export interface WebVROptions {
  15080. /**
  15081. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15082. */
  15083. trackPosition?: boolean;
  15084. /**
  15085. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15086. */
  15087. positionScale?: number;
  15088. /**
  15089. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15090. */
  15091. displayName?: string;
  15092. /**
  15093. * Should the native controller meshes be initialized. (default: true)
  15094. */
  15095. controllerMeshes?: boolean;
  15096. /**
  15097. * Creating a default HemiLight only on controllers. (default: true)
  15098. */
  15099. defaultLightingOnControllers?: boolean;
  15100. /**
  15101. * If you don't want to use the default VR button of the helper. (default: false)
  15102. */
  15103. useCustomVRButton?: boolean;
  15104. /**
  15105. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15106. */
  15107. customVRButton?: HTMLButtonElement;
  15108. /**
  15109. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15110. */
  15111. rayLength?: number;
  15112. /**
  15113. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15114. */
  15115. defaultHeight?: number;
  15116. /**
  15117. * If multiview should be used if availible (default: false)
  15118. */
  15119. useMultiview?: boolean;
  15120. }
  15121. /**
  15122. * This represents a WebVR camera.
  15123. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15124. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15125. */
  15126. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15127. private webVROptions;
  15128. /**
  15129. * @hidden
  15130. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15131. */
  15132. _vrDevice: any;
  15133. /**
  15134. * The rawPose of the vrDevice.
  15135. */
  15136. rawPose: Nullable<DevicePose>;
  15137. private _onVREnabled;
  15138. private _specsVersion;
  15139. private _attached;
  15140. private _frameData;
  15141. protected _descendants: Array<Node>;
  15142. private _deviceRoomPosition;
  15143. /** @hidden */
  15144. _deviceRoomRotationQuaternion: Quaternion;
  15145. private _standingMatrix;
  15146. /**
  15147. * Represents device position in babylon space.
  15148. */
  15149. devicePosition: Vector3;
  15150. /**
  15151. * Represents device rotation in babylon space.
  15152. */
  15153. deviceRotationQuaternion: Quaternion;
  15154. /**
  15155. * The scale of the device to be used when translating from device space to babylon space.
  15156. */
  15157. deviceScaleFactor: number;
  15158. private _deviceToWorld;
  15159. private _worldToDevice;
  15160. /**
  15161. * References to the webVR controllers for the vrDevice.
  15162. */
  15163. controllers: Array<WebVRController>;
  15164. /**
  15165. * Emits an event when a controller is attached.
  15166. */
  15167. onControllersAttachedObservable: Observable<WebVRController[]>;
  15168. /**
  15169. * Emits an event when a controller's mesh has been loaded;
  15170. */
  15171. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15172. /**
  15173. * Emits an event when the HMD's pose has been updated.
  15174. */
  15175. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15176. private _poseSet;
  15177. /**
  15178. * If the rig cameras be used as parent instead of this camera.
  15179. */
  15180. rigParenting: boolean;
  15181. private _lightOnControllers;
  15182. private _defaultHeight?;
  15183. /**
  15184. * Instantiates a WebVRFreeCamera.
  15185. * @param name The name of the WebVRFreeCamera
  15186. * @param position The starting anchor position for the camera
  15187. * @param scene The scene the camera belongs to
  15188. * @param webVROptions a set of customizable options for the webVRCamera
  15189. */
  15190. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15191. /**
  15192. * Gets the device distance from the ground in meters.
  15193. * @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.
  15194. */
  15195. deviceDistanceToRoomGround(): number;
  15196. /**
  15197. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15198. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15199. */
  15200. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15201. /**
  15202. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15203. * @returns A promise with a boolean set to if the standing matrix is supported.
  15204. */
  15205. useStandingMatrixAsync(): Promise<boolean>;
  15206. /**
  15207. * Disposes the camera
  15208. */
  15209. dispose(): void;
  15210. /**
  15211. * Gets a vrController by name.
  15212. * @param name The name of the controller to retreive
  15213. * @returns the controller matching the name specified or null if not found
  15214. */
  15215. getControllerByName(name: string): Nullable<WebVRController>;
  15216. private _leftController;
  15217. /**
  15218. * The controller corresponding to the users left hand.
  15219. */
  15220. readonly leftController: Nullable<WebVRController>;
  15221. private _rightController;
  15222. /**
  15223. * The controller corresponding to the users right hand.
  15224. */
  15225. readonly rightController: Nullable<WebVRController>;
  15226. /**
  15227. * Casts a ray forward from the vrCamera's gaze.
  15228. * @param length Length of the ray (default: 100)
  15229. * @returns the ray corresponding to the gaze
  15230. */
  15231. getForwardRay(length?: number): Ray;
  15232. /**
  15233. * @hidden
  15234. * Updates the camera based on device's frame data
  15235. */
  15236. _checkInputs(): void;
  15237. /**
  15238. * Updates the poseControlled values based on the input device pose.
  15239. * @param poseData Pose coming from the device
  15240. */
  15241. updateFromDevice(poseData: DevicePose): void;
  15242. private _htmlElementAttached;
  15243. private _detachIfAttached;
  15244. /**
  15245. * WebVR's attach control will start broadcasting frames to the device.
  15246. * Note that in certain browsers (chrome for example) this function must be called
  15247. * within a user-interaction callback. Example:
  15248. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15249. *
  15250. * @param element html element to attach the vrDevice to
  15251. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15252. */
  15253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15254. /**
  15255. * Detaches the camera from the html element and disables VR
  15256. *
  15257. * @param element html element to detach from
  15258. */
  15259. detachControl(element: HTMLElement): void;
  15260. /**
  15261. * @returns the name of this class
  15262. */
  15263. getClassName(): string;
  15264. /**
  15265. * Calls resetPose on the vrDisplay
  15266. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15267. */
  15268. resetToCurrentRotation(): void;
  15269. /**
  15270. * @hidden
  15271. * Updates the rig cameras (left and right eye)
  15272. */
  15273. _updateRigCameras(): void;
  15274. private _workingVector;
  15275. private _oneVector;
  15276. private _workingMatrix;
  15277. private updateCacheCalled;
  15278. private _correctPositionIfNotTrackPosition;
  15279. /**
  15280. * @hidden
  15281. * Updates the cached values of the camera
  15282. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15283. */
  15284. _updateCache(ignoreParentClass?: boolean): void;
  15285. /**
  15286. * @hidden
  15287. * Get current device position in babylon world
  15288. */
  15289. _computeDevicePosition(): void;
  15290. /**
  15291. * Updates the current device position and rotation in the babylon world
  15292. */
  15293. update(): void;
  15294. /**
  15295. * @hidden
  15296. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15297. * @returns an identity matrix
  15298. */
  15299. _getViewMatrix(): Matrix;
  15300. private _tmpMatrix;
  15301. /**
  15302. * This function is called by the two RIG cameras.
  15303. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15304. * @hidden
  15305. */
  15306. _getWebVRViewMatrix(): Matrix;
  15307. /** @hidden */
  15308. _getWebVRProjectionMatrix(): Matrix;
  15309. private _onGamepadConnectedObserver;
  15310. private _onGamepadDisconnectedObserver;
  15311. private _updateCacheWhenTrackingDisabledObserver;
  15312. /**
  15313. * Initializes the controllers and their meshes
  15314. */
  15315. initControllers(): void;
  15316. }
  15317. }
  15318. declare module "babylonjs/PostProcesses/postProcess" {
  15319. import { Nullable } from "babylonjs/types";
  15320. import { SmartArray } from "babylonjs/Misc/smartArray";
  15321. import { Observable } from "babylonjs/Misc/observable";
  15322. import { Vector2 } from "babylonjs/Maths/math.vector";
  15323. import { Camera } from "babylonjs/Cameras/camera";
  15324. import { Effect } from "babylonjs/Materials/effect";
  15325. import "babylonjs/Shaders/postprocess.vertex";
  15326. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15327. import { Engine } from "babylonjs/Engines/engine";
  15328. import { Color4 } from "babylonjs/Maths/math.color";
  15329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15330. /**
  15331. * Size options for a post process
  15332. */
  15333. export type PostProcessOptions = {
  15334. width: number;
  15335. height: number;
  15336. };
  15337. /**
  15338. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15339. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15340. */
  15341. export class PostProcess {
  15342. /** Name of the PostProcess. */
  15343. name: string;
  15344. /**
  15345. * Gets or sets the unique id of the post process
  15346. */
  15347. uniqueId: number;
  15348. /**
  15349. * Width of the texture to apply the post process on
  15350. */
  15351. width: number;
  15352. /**
  15353. * Height of the texture to apply the post process on
  15354. */
  15355. height: number;
  15356. /**
  15357. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15358. * @hidden
  15359. */
  15360. _outputTexture: Nullable<InternalTexture>;
  15361. /**
  15362. * Sampling mode used by the shader
  15363. * See https://doc.babylonjs.com/classes/3.1/texture
  15364. */
  15365. renderTargetSamplingMode: number;
  15366. /**
  15367. * Clear color to use when screen clearing
  15368. */
  15369. clearColor: Color4;
  15370. /**
  15371. * If the buffer needs to be cleared before applying the post process. (default: true)
  15372. * Should be set to false if shader will overwrite all previous pixels.
  15373. */
  15374. autoClear: boolean;
  15375. /**
  15376. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15377. */
  15378. alphaMode: number;
  15379. /**
  15380. * Sets the setAlphaBlendConstants of the babylon engine
  15381. */
  15382. alphaConstants: Color4;
  15383. /**
  15384. * Animations to be used for the post processing
  15385. */
  15386. animations: import("babylonjs/Animations/animation").Animation[];
  15387. /**
  15388. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15389. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15390. */
  15391. enablePixelPerfectMode: boolean;
  15392. /**
  15393. * Force the postprocess to be applied without taking in account viewport
  15394. */
  15395. forceFullscreenViewport: boolean;
  15396. /**
  15397. * List of inspectable custom properties (used by the Inspector)
  15398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15399. */
  15400. inspectableCustomProperties: IInspectable[];
  15401. /**
  15402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15403. *
  15404. * | Value | Type | Description |
  15405. * | ----- | ----------------------------------- | ----------- |
  15406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15409. *
  15410. */
  15411. scaleMode: number;
  15412. /**
  15413. * Force textures to be a power of two (default: false)
  15414. */
  15415. alwaysForcePOT: boolean;
  15416. private _samples;
  15417. /**
  15418. * Number of sample textures (default: 1)
  15419. */
  15420. samples: number;
  15421. /**
  15422. * Modify the scale of the post process to be the same as the viewport (default: false)
  15423. */
  15424. adaptScaleToCurrentViewport: boolean;
  15425. private _camera;
  15426. private _scene;
  15427. private _engine;
  15428. private _options;
  15429. private _reusable;
  15430. private _textureType;
  15431. /**
  15432. * Smart array of input and output textures for the post process.
  15433. * @hidden
  15434. */
  15435. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15436. /**
  15437. * The index in _textures that corresponds to the output texture.
  15438. * @hidden
  15439. */
  15440. _currentRenderTextureInd: number;
  15441. private _effect;
  15442. private _samplers;
  15443. private _fragmentUrl;
  15444. private _vertexUrl;
  15445. private _parameters;
  15446. private _scaleRatio;
  15447. protected _indexParameters: any;
  15448. private _shareOutputWithPostProcess;
  15449. private _texelSize;
  15450. private _forcedOutputTexture;
  15451. /**
  15452. * Returns the fragment url or shader name used in the post process.
  15453. * @returns the fragment url or name in the shader store.
  15454. */
  15455. getEffectName(): string;
  15456. /**
  15457. * An event triggered when the postprocess is activated.
  15458. */
  15459. onActivateObservable: Observable<Camera>;
  15460. private _onActivateObserver;
  15461. /**
  15462. * A function that is added to the onActivateObservable
  15463. */
  15464. onActivate: Nullable<(camera: Camera) => void>;
  15465. /**
  15466. * An event triggered when the postprocess changes its size.
  15467. */
  15468. onSizeChangedObservable: Observable<PostProcess>;
  15469. private _onSizeChangedObserver;
  15470. /**
  15471. * A function that is added to the onSizeChangedObservable
  15472. */
  15473. onSizeChanged: (postProcess: PostProcess) => void;
  15474. /**
  15475. * An event triggered when the postprocess applies its effect.
  15476. */
  15477. onApplyObservable: Observable<Effect>;
  15478. private _onApplyObserver;
  15479. /**
  15480. * A function that is added to the onApplyObservable
  15481. */
  15482. onApply: (effect: Effect) => void;
  15483. /**
  15484. * An event triggered before rendering the postprocess
  15485. */
  15486. onBeforeRenderObservable: Observable<Effect>;
  15487. private _onBeforeRenderObserver;
  15488. /**
  15489. * A function that is added to the onBeforeRenderObservable
  15490. */
  15491. onBeforeRender: (effect: Effect) => void;
  15492. /**
  15493. * An event triggered after rendering the postprocess
  15494. */
  15495. onAfterRenderObservable: Observable<Effect>;
  15496. private _onAfterRenderObserver;
  15497. /**
  15498. * A function that is added to the onAfterRenderObservable
  15499. */
  15500. onAfterRender: (efect: Effect) => void;
  15501. /**
  15502. * 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
  15503. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15504. */
  15505. inputTexture: InternalTexture;
  15506. /**
  15507. * Gets the camera which post process is applied to.
  15508. * @returns The camera the post process is applied to.
  15509. */
  15510. getCamera(): Camera;
  15511. /**
  15512. * Gets the texel size of the postprocess.
  15513. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15514. */
  15515. readonly texelSize: Vector2;
  15516. /**
  15517. * Creates a new instance PostProcess
  15518. * @param name The name of the PostProcess.
  15519. * @param fragmentUrl The url of the fragment shader to be used.
  15520. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15521. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15522. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15523. * @param camera The camera to apply the render pass to.
  15524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15525. * @param engine The engine which the post process will be applied. (default: current engine)
  15526. * @param reusable If the post process can be reused on the same frame. (default: false)
  15527. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15528. * @param textureType Type of textures used when performing the post process. (default: 0)
  15529. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15530. * @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
  15531. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15532. */
  15533. constructor(
  15534. /** Name of the PostProcess. */
  15535. 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);
  15536. /**
  15537. * Gets a string idenfifying the name of the class
  15538. * @returns "PostProcess" string
  15539. */
  15540. getClassName(): string;
  15541. /**
  15542. * Gets the engine which this post process belongs to.
  15543. * @returns The engine the post process was enabled with.
  15544. */
  15545. getEngine(): Engine;
  15546. /**
  15547. * The effect that is created when initializing the post process.
  15548. * @returns The created effect corresponding the the postprocess.
  15549. */
  15550. getEffect(): Effect;
  15551. /**
  15552. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15553. * @param postProcess The post process to share the output with.
  15554. * @returns This post process.
  15555. */
  15556. shareOutputWith(postProcess: PostProcess): PostProcess;
  15557. /**
  15558. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15559. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15560. */
  15561. useOwnOutput(): void;
  15562. /**
  15563. * Updates the effect with the current post process compile time values and recompiles the shader.
  15564. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15565. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15566. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15567. * @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
  15568. * @param onCompiled Called when the shader has been compiled.
  15569. * @param onError Called if there is an error when compiling a shader.
  15570. */
  15571. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15572. /**
  15573. * The post process is reusable if it can be used multiple times within one frame.
  15574. * @returns If the post process is reusable
  15575. */
  15576. isReusable(): boolean;
  15577. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15578. markTextureDirty(): void;
  15579. /**
  15580. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15581. * 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.
  15582. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15583. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15584. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15585. * @returns The target texture that was bound to be written to.
  15586. */
  15587. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15588. /**
  15589. * If the post process is supported.
  15590. */
  15591. readonly isSupported: boolean;
  15592. /**
  15593. * The aspect ratio of the output texture.
  15594. */
  15595. readonly aspectRatio: number;
  15596. /**
  15597. * Get a value indicating if the post-process is ready to be used
  15598. * @returns true if the post-process is ready (shader is compiled)
  15599. */
  15600. isReady(): boolean;
  15601. /**
  15602. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15603. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15604. */
  15605. apply(): Nullable<Effect>;
  15606. private _disposeTextures;
  15607. /**
  15608. * Disposes the post process.
  15609. * @param camera The camera to dispose the post process on.
  15610. */
  15611. dispose(camera?: Camera): void;
  15612. }
  15613. }
  15614. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15615. /** @hidden */
  15616. export var kernelBlurVaryingDeclaration: {
  15617. name: string;
  15618. shader: string;
  15619. };
  15620. }
  15621. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15622. /** @hidden */
  15623. export var kernelBlurFragment: {
  15624. name: string;
  15625. shader: string;
  15626. };
  15627. }
  15628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15629. /** @hidden */
  15630. export var kernelBlurFragment2: {
  15631. name: string;
  15632. shader: string;
  15633. };
  15634. }
  15635. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15636. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15637. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15638. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15639. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15640. /** @hidden */
  15641. export var kernelBlurPixelShader: {
  15642. name: string;
  15643. shader: string;
  15644. };
  15645. }
  15646. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15647. /** @hidden */
  15648. export var kernelBlurVertex: {
  15649. name: string;
  15650. shader: string;
  15651. };
  15652. }
  15653. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15654. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15655. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15656. /** @hidden */
  15657. export var kernelBlurVertexShader: {
  15658. name: string;
  15659. shader: string;
  15660. };
  15661. }
  15662. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15663. import { Vector2 } from "babylonjs/Maths/math.vector";
  15664. import { Nullable } from "babylonjs/types";
  15665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15666. import { Camera } from "babylonjs/Cameras/camera";
  15667. import { Effect } from "babylonjs/Materials/effect";
  15668. import { Engine } from "babylonjs/Engines/engine";
  15669. import "babylonjs/Shaders/kernelBlur.fragment";
  15670. import "babylonjs/Shaders/kernelBlur.vertex";
  15671. /**
  15672. * The Blur Post Process which blurs an image based on a kernel and direction.
  15673. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15674. */
  15675. export class BlurPostProcess extends PostProcess {
  15676. /** The direction in which to blur the image. */
  15677. direction: Vector2;
  15678. private blockCompilation;
  15679. protected _kernel: number;
  15680. protected _idealKernel: number;
  15681. protected _packedFloat: boolean;
  15682. private _staticDefines;
  15683. /**
  15684. * Sets the length in pixels of the blur sample region
  15685. */
  15686. /**
  15687. * Gets the length in pixels of the blur sample region
  15688. */
  15689. kernel: number;
  15690. /**
  15691. * Sets wether or not the blur needs to unpack/repack floats
  15692. */
  15693. /**
  15694. * Gets wether or not the blur is unpacking/repacking floats
  15695. */
  15696. packedFloat: boolean;
  15697. /**
  15698. * Creates a new instance BlurPostProcess
  15699. * @param name The name of the effect.
  15700. * @param direction The direction in which to blur the image.
  15701. * @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.
  15702. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15703. * @param camera The camera to apply the render pass to.
  15704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15705. * @param engine The engine which the post process will be applied. (default: current engine)
  15706. * @param reusable If the post process can be reused on the same frame. (default: false)
  15707. * @param textureType Type of textures used when performing the post process. (default: 0)
  15708. * @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)
  15709. */
  15710. constructor(name: string,
  15711. /** The direction in which to blur the image. */
  15712. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15713. /**
  15714. * Updates the effect with the current post process compile time values and recompiles the shader.
  15715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15718. * @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
  15719. * @param onCompiled Called when the shader has been compiled.
  15720. * @param onError Called if there is an error when compiling a shader.
  15721. */
  15722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15723. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15724. /**
  15725. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15726. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15727. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15728. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15729. * The gaps between physical kernels are compensated for in the weighting of the samples
  15730. * @param idealKernel Ideal blur kernel.
  15731. * @return Nearest best kernel.
  15732. */
  15733. protected _nearestBestKernel(idealKernel: number): number;
  15734. /**
  15735. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15736. * @param x The point on the Gaussian distribution to sample.
  15737. * @return the value of the Gaussian function at x.
  15738. */
  15739. protected _gaussianWeight(x: number): number;
  15740. /**
  15741. * Generates a string that can be used as a floating point number in GLSL.
  15742. * @param x Value to print.
  15743. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15744. * @return GLSL float string.
  15745. */
  15746. protected _glslFloat(x: number, decimalFigures?: number): string;
  15747. }
  15748. }
  15749. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15750. import { Scene } from "babylonjs/scene";
  15751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15752. import { Plane } from "babylonjs/Maths/math.plane";
  15753. /**
  15754. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15755. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15756. * You can then easily use it as a reflectionTexture on a flat surface.
  15757. * In case the surface is not a plane, please consider relying on reflection probes.
  15758. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15759. */
  15760. export class MirrorTexture extends RenderTargetTexture {
  15761. private scene;
  15762. /**
  15763. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15764. * 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.
  15765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15766. */
  15767. mirrorPlane: Plane;
  15768. /**
  15769. * Define the blur ratio used to blur the reflection if needed.
  15770. */
  15771. blurRatio: number;
  15772. /**
  15773. * Define the adaptive blur kernel used to blur the reflection if needed.
  15774. * This will autocompute the closest best match for the `blurKernel`
  15775. */
  15776. adaptiveBlurKernel: number;
  15777. /**
  15778. * Define the blur kernel used to blur the reflection if needed.
  15779. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15780. */
  15781. blurKernel: number;
  15782. /**
  15783. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15784. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15785. */
  15786. blurKernelX: number;
  15787. /**
  15788. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15789. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15790. */
  15791. blurKernelY: number;
  15792. private _autoComputeBlurKernel;
  15793. protected _onRatioRescale(): void;
  15794. private _updateGammaSpace;
  15795. private _imageProcessingConfigChangeObserver;
  15796. private _transformMatrix;
  15797. private _mirrorMatrix;
  15798. private _savedViewMatrix;
  15799. private _blurX;
  15800. private _blurY;
  15801. private _adaptiveBlurKernel;
  15802. private _blurKernelX;
  15803. private _blurKernelY;
  15804. private _blurRatio;
  15805. /**
  15806. * Instantiates a Mirror Texture.
  15807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15809. * You can then easily use it as a reflectionTexture on a flat surface.
  15810. * In case the surface is not a plane, please consider relying on reflection probes.
  15811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15812. * @param name
  15813. * @param size
  15814. * @param scene
  15815. * @param generateMipMaps
  15816. * @param type
  15817. * @param samplingMode
  15818. * @param generateDepthBuffer
  15819. */
  15820. constructor(name: string, size: number | {
  15821. width: number;
  15822. height: number;
  15823. } | {
  15824. ratio: number;
  15825. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15826. private _preparePostProcesses;
  15827. /**
  15828. * Clone the mirror texture.
  15829. * @returns the cloned texture
  15830. */
  15831. clone(): MirrorTexture;
  15832. /**
  15833. * Serialize the texture to a JSON representation you could use in Parse later on
  15834. * @returns the serialized JSON representation
  15835. */
  15836. serialize(): any;
  15837. /**
  15838. * Dispose the texture and release its associated resources.
  15839. */
  15840. dispose(): void;
  15841. }
  15842. }
  15843. declare module "babylonjs/Materials/Textures/texture" {
  15844. import { Observable } from "babylonjs/Misc/observable";
  15845. import { Nullable } from "babylonjs/types";
  15846. import { Scene } from "babylonjs/scene";
  15847. import { Matrix } from "babylonjs/Maths/math.vector";
  15848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15849. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15850. import { Engine } from "babylonjs/Engines/engine";
  15851. /**
  15852. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15853. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15854. */
  15855. export class Texture extends BaseTexture {
  15856. /** @hidden */
  15857. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15858. /** @hidden */
  15859. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15860. /** @hidden */
  15861. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15862. /** nearest is mag = nearest and min = nearest and mip = linear */
  15863. static readonly NEAREST_SAMPLINGMODE: number;
  15864. /** nearest is mag = nearest and min = nearest and mip = linear */
  15865. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15866. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15867. static readonly BILINEAR_SAMPLINGMODE: number;
  15868. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15869. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15870. /** Trilinear is mag = linear and min = linear and mip = linear */
  15871. static readonly TRILINEAR_SAMPLINGMODE: number;
  15872. /** Trilinear is mag = linear and min = linear and mip = linear */
  15873. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15874. /** mag = nearest and min = nearest and mip = nearest */
  15875. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15876. /** mag = nearest and min = linear and mip = nearest */
  15877. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15878. /** mag = nearest and min = linear and mip = linear */
  15879. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15880. /** mag = nearest and min = linear and mip = none */
  15881. static readonly NEAREST_LINEAR: number;
  15882. /** mag = nearest and min = nearest and mip = none */
  15883. static readonly NEAREST_NEAREST: number;
  15884. /** mag = linear and min = nearest and mip = nearest */
  15885. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15886. /** mag = linear and min = nearest and mip = linear */
  15887. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15888. /** mag = linear and min = linear and mip = none */
  15889. static readonly LINEAR_LINEAR: number;
  15890. /** mag = linear and min = nearest and mip = none */
  15891. static readonly LINEAR_NEAREST: number;
  15892. /** Explicit coordinates mode */
  15893. static readonly EXPLICIT_MODE: number;
  15894. /** Spherical coordinates mode */
  15895. static readonly SPHERICAL_MODE: number;
  15896. /** Planar coordinates mode */
  15897. static readonly PLANAR_MODE: number;
  15898. /** Cubic coordinates mode */
  15899. static readonly CUBIC_MODE: number;
  15900. /** Projection coordinates mode */
  15901. static readonly PROJECTION_MODE: number;
  15902. /** Inverse Cubic coordinates mode */
  15903. static readonly SKYBOX_MODE: number;
  15904. /** Inverse Cubic coordinates mode */
  15905. static readonly INVCUBIC_MODE: number;
  15906. /** Equirectangular coordinates mode */
  15907. static readonly EQUIRECTANGULAR_MODE: number;
  15908. /** Equirectangular Fixed coordinates mode */
  15909. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15910. /** Equirectangular Fixed Mirrored coordinates mode */
  15911. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15912. /** Texture is not repeating outside of 0..1 UVs */
  15913. static readonly CLAMP_ADDRESSMODE: number;
  15914. /** Texture is repeating outside of 0..1 UVs */
  15915. static readonly WRAP_ADDRESSMODE: number;
  15916. /** Texture is repeating and mirrored */
  15917. static readonly MIRROR_ADDRESSMODE: number;
  15918. /**
  15919. * 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
  15920. */
  15921. static UseSerializedUrlIfAny: boolean;
  15922. /**
  15923. * Define the url of the texture.
  15924. */
  15925. url: Nullable<string>;
  15926. /**
  15927. * Define an offset on the texture to offset the u coordinates of the UVs
  15928. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15929. */
  15930. uOffset: number;
  15931. /**
  15932. * Define an offset on the texture to offset the v coordinates of the UVs
  15933. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15934. */
  15935. vOffset: number;
  15936. /**
  15937. * Define an offset on the texture to scale the u coordinates of the UVs
  15938. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15939. */
  15940. uScale: number;
  15941. /**
  15942. * Define an offset on the texture to scale the v coordinates of the UVs
  15943. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15944. */
  15945. vScale: number;
  15946. /**
  15947. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15948. * @see http://doc.babylonjs.com/how_to/more_materials
  15949. */
  15950. uAng: number;
  15951. /**
  15952. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15953. * @see http://doc.babylonjs.com/how_to/more_materials
  15954. */
  15955. vAng: number;
  15956. /**
  15957. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15958. * @see http://doc.babylonjs.com/how_to/more_materials
  15959. */
  15960. wAng: number;
  15961. /**
  15962. * Defines the center of rotation (U)
  15963. */
  15964. uRotationCenter: number;
  15965. /**
  15966. * Defines the center of rotation (V)
  15967. */
  15968. vRotationCenter: number;
  15969. /**
  15970. * Defines the center of rotation (W)
  15971. */
  15972. wRotationCenter: number;
  15973. /**
  15974. * Are mip maps generated for this texture or not.
  15975. */
  15976. readonly noMipmap: boolean;
  15977. /**
  15978. * List of inspectable custom properties (used by the Inspector)
  15979. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15980. */
  15981. inspectableCustomProperties: Nullable<IInspectable[]>;
  15982. private _noMipmap;
  15983. /** @hidden */
  15984. _invertY: boolean;
  15985. private _rowGenerationMatrix;
  15986. private _cachedTextureMatrix;
  15987. private _projectionModeMatrix;
  15988. private _t0;
  15989. private _t1;
  15990. private _t2;
  15991. private _cachedUOffset;
  15992. private _cachedVOffset;
  15993. private _cachedUScale;
  15994. private _cachedVScale;
  15995. private _cachedUAng;
  15996. private _cachedVAng;
  15997. private _cachedWAng;
  15998. private _cachedProjectionMatrixId;
  15999. private _cachedCoordinatesMode;
  16000. /** @hidden */
  16001. protected _initialSamplingMode: number;
  16002. /** @hidden */
  16003. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16004. private _deleteBuffer;
  16005. protected _format: Nullable<number>;
  16006. private _delayedOnLoad;
  16007. private _delayedOnError;
  16008. /**
  16009. * Observable triggered once the texture has been loaded.
  16010. */
  16011. onLoadObservable: Observable<Texture>;
  16012. protected _isBlocking: boolean;
  16013. /**
  16014. * Is the texture preventing material to render while loading.
  16015. * If false, a default texture will be used instead of the loading one during the preparation step.
  16016. */
  16017. isBlocking: boolean;
  16018. /**
  16019. * Get the current sampling mode associated with the texture.
  16020. */
  16021. readonly samplingMode: number;
  16022. /**
  16023. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16024. */
  16025. readonly invertY: boolean;
  16026. /**
  16027. * Instantiates a new texture.
  16028. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16029. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16030. * @param url define the url of the picture to load as a texture
  16031. * @param scene define the scene or engine the texture will belong to
  16032. * @param noMipmap define if the texture will require mip maps or not
  16033. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16034. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16035. * @param onLoad define a callback triggered when the texture has been loaded
  16036. * @param onError define a callback triggered when an error occurred during the loading session
  16037. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16038. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16039. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16040. */
  16041. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16042. /**
  16043. * Update the url (and optional buffer) of this texture if url was null during construction.
  16044. * @param url the url of the texture
  16045. * @param buffer the buffer of the texture (defaults to null)
  16046. * @param onLoad callback called when the texture is loaded (defaults to null)
  16047. */
  16048. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16049. /**
  16050. * Finish the loading sequence of a texture flagged as delayed load.
  16051. * @hidden
  16052. */
  16053. delayLoad(): void;
  16054. private _prepareRowForTextureGeneration;
  16055. /**
  16056. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16057. * @returns the transform matrix of the texture.
  16058. */
  16059. getTextureMatrix(): Matrix;
  16060. /**
  16061. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16062. * @returns The reflection texture transform
  16063. */
  16064. getReflectionTextureMatrix(): Matrix;
  16065. /**
  16066. * Clones the texture.
  16067. * @returns the cloned texture
  16068. */
  16069. clone(): Texture;
  16070. /**
  16071. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16072. * @returns The JSON representation of the texture
  16073. */
  16074. serialize(): any;
  16075. /**
  16076. * Get the current class name of the texture useful for serialization or dynamic coding.
  16077. * @returns "Texture"
  16078. */
  16079. getClassName(): string;
  16080. /**
  16081. * Dispose the texture and release its associated resources.
  16082. */
  16083. dispose(): void;
  16084. /**
  16085. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16086. * @param parsedTexture Define the JSON representation of the texture
  16087. * @param scene Define the scene the parsed texture should be instantiated in
  16088. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16089. * @returns The parsed texture if successful
  16090. */
  16091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16092. /**
  16093. * Creates a texture from its base 64 representation.
  16094. * @param data Define the base64 payload without the data: prefix
  16095. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16096. * @param scene Define the scene the texture should belong to
  16097. * @param noMipmap Forces the texture to not create mip map information if true
  16098. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16099. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16100. * @param onLoad define a callback triggered when the texture has been loaded
  16101. * @param onError define a callback triggered when an error occurred during the loading session
  16102. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16103. * @returns the created texture
  16104. */
  16105. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16106. /**
  16107. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16108. * @param data Define the base64 payload without the data: prefix
  16109. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16110. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16111. * @param scene Define the scene the texture should belong to
  16112. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16113. * @param noMipmap Forces the texture to not create mip map information if true
  16114. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16115. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16116. * @param onLoad define a callback triggered when the texture has been loaded
  16117. * @param onError define a callback triggered when an error occurred during the loading session
  16118. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16119. * @returns the created texture
  16120. */
  16121. 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;
  16122. }
  16123. }
  16124. declare module "babylonjs/PostProcesses/postProcessManager" {
  16125. import { Nullable } from "babylonjs/types";
  16126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16128. import { Scene } from "babylonjs/scene";
  16129. /**
  16130. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16131. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16132. */
  16133. export class PostProcessManager {
  16134. private _scene;
  16135. private _indexBuffer;
  16136. private _vertexBuffers;
  16137. /**
  16138. * Creates a new instance PostProcess
  16139. * @param scene The scene that the post process is associated with.
  16140. */
  16141. constructor(scene: Scene);
  16142. private _prepareBuffers;
  16143. private _buildIndexBuffer;
  16144. /**
  16145. * Rebuilds the vertex buffers of the manager.
  16146. * @hidden
  16147. */
  16148. _rebuild(): void;
  16149. /**
  16150. * Prepares a frame to be run through a post process.
  16151. * @param sourceTexture The input texture to the post procesess. (default: null)
  16152. * @param postProcesses An array of post processes to be run. (default: null)
  16153. * @returns True if the post processes were able to be run.
  16154. * @hidden
  16155. */
  16156. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16157. /**
  16158. * Manually render a set of post processes to a texture.
  16159. * @param postProcesses An array of post processes to be run.
  16160. * @param targetTexture The target texture to render to.
  16161. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16162. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16163. * @param lodLevel defines which lod of the texture to render to
  16164. */
  16165. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16166. /**
  16167. * Finalize the result of the output of the postprocesses.
  16168. * @param doNotPresent If true the result will not be displayed to the screen.
  16169. * @param targetTexture The target texture to render to.
  16170. * @param faceIndex The index of the face to bind the target texture to.
  16171. * @param postProcesses The array of post processes to render.
  16172. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16173. * @hidden
  16174. */
  16175. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16176. /**
  16177. * Disposes of the post process manager.
  16178. */
  16179. dispose(): void;
  16180. }
  16181. }
  16182. declare module "babylonjs/Misc/gradients" {
  16183. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16184. /** Interface used by value gradients (color, factor, ...) */
  16185. export interface IValueGradient {
  16186. /**
  16187. * Gets or sets the gradient value (between 0 and 1)
  16188. */
  16189. gradient: number;
  16190. }
  16191. /** Class used to store color4 gradient */
  16192. export class ColorGradient implements IValueGradient {
  16193. /**
  16194. * Gets or sets the gradient value (between 0 and 1)
  16195. */
  16196. gradient: number;
  16197. /**
  16198. * Gets or sets first associated color
  16199. */
  16200. color1: Color4;
  16201. /**
  16202. * Gets or sets second associated color
  16203. */
  16204. color2?: Color4;
  16205. /**
  16206. * Will get a color picked randomly between color1 and color2.
  16207. * If color2 is undefined then color1 will be used
  16208. * @param result defines the target Color4 to store the result in
  16209. */
  16210. getColorToRef(result: Color4): void;
  16211. }
  16212. /** Class used to store color 3 gradient */
  16213. export class Color3Gradient implements IValueGradient {
  16214. /**
  16215. * Gets or sets the gradient value (between 0 and 1)
  16216. */
  16217. gradient: number;
  16218. /**
  16219. * Gets or sets the associated color
  16220. */
  16221. color: Color3;
  16222. }
  16223. /** Class used to store factor gradient */
  16224. export class FactorGradient implements IValueGradient {
  16225. /**
  16226. * Gets or sets the gradient value (between 0 and 1)
  16227. */
  16228. gradient: number;
  16229. /**
  16230. * Gets or sets first associated factor
  16231. */
  16232. factor1: number;
  16233. /**
  16234. * Gets or sets second associated factor
  16235. */
  16236. factor2?: number;
  16237. /**
  16238. * Will get a number picked randomly between factor1 and factor2.
  16239. * If factor2 is undefined then factor1 will be used
  16240. * @returns the picked number
  16241. */
  16242. getFactor(): number;
  16243. }
  16244. /**
  16245. * Helper used to simplify some generic gradient tasks
  16246. */
  16247. export class GradientHelper {
  16248. /**
  16249. * Gets the current gradient from an array of IValueGradient
  16250. * @param ratio defines the current ratio to get
  16251. * @param gradients defines the array of IValueGradient
  16252. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16253. */
  16254. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16255. }
  16256. }
  16257. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16258. import { Scene } from "babylonjs/scene";
  16259. import { ISceneComponent } from "babylonjs/sceneComponent";
  16260. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16261. module "babylonjs/abstractScene" {
  16262. interface AbstractScene {
  16263. /**
  16264. * The list of procedural textures added to the scene
  16265. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16266. */
  16267. proceduralTextures: Array<ProceduralTexture>;
  16268. }
  16269. }
  16270. /**
  16271. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16272. * in a given scene.
  16273. */
  16274. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16275. /**
  16276. * The component name helpfull to identify the component in the list of scene components.
  16277. */
  16278. readonly name: string;
  16279. /**
  16280. * The scene the component belongs to.
  16281. */
  16282. scene: Scene;
  16283. /**
  16284. * Creates a new instance of the component for the given scene
  16285. * @param scene Defines the scene to register the component in
  16286. */
  16287. constructor(scene: Scene);
  16288. /**
  16289. * Registers the component in a given scene
  16290. */
  16291. register(): void;
  16292. /**
  16293. * Rebuilds the elements related to this component in case of
  16294. * context lost for instance.
  16295. */
  16296. rebuild(): void;
  16297. /**
  16298. * Disposes the component and the associated ressources.
  16299. */
  16300. dispose(): void;
  16301. private _beforeClear;
  16302. }
  16303. }
  16304. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16305. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16306. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16307. module "babylonjs/Engines/engine" {
  16308. interface Engine {
  16309. /**
  16310. * Creates a new render target cube texture
  16311. * @param size defines the size of the texture
  16312. * @param options defines the options used to create the texture
  16313. * @returns a new render target cube texture stored in an InternalTexture
  16314. */
  16315. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16316. }
  16317. }
  16318. }
  16319. declare module "babylonjs/Shaders/procedural.vertex" {
  16320. /** @hidden */
  16321. export var proceduralVertexShader: {
  16322. name: string;
  16323. shader: string;
  16324. };
  16325. }
  16326. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16327. import { Observable } from "babylonjs/Misc/observable";
  16328. import { Nullable } from "babylonjs/types";
  16329. import { Scene } from "babylonjs/scene";
  16330. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16331. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16332. import { Effect } from "babylonjs/Materials/effect";
  16333. import { Texture } from "babylonjs/Materials/Textures/texture";
  16334. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16335. import "babylonjs/Shaders/procedural.vertex";
  16336. /**
  16337. * 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.
  16338. * This is the base class of any Procedural texture and contains most of the shareable code.
  16339. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16340. */
  16341. export class ProceduralTexture extends Texture {
  16342. isCube: boolean;
  16343. /**
  16344. * Define if the texture is enabled or not (disabled texture will not render)
  16345. */
  16346. isEnabled: boolean;
  16347. /**
  16348. * Define if the texture must be cleared before rendering (default is true)
  16349. */
  16350. autoClear: boolean;
  16351. /**
  16352. * Callback called when the texture is generated
  16353. */
  16354. onGenerated: () => void;
  16355. /**
  16356. * Event raised when the texture is generated
  16357. */
  16358. onGeneratedObservable: Observable<ProceduralTexture>;
  16359. /** @hidden */
  16360. _generateMipMaps: boolean;
  16361. /** @hidden **/
  16362. _effect: Effect;
  16363. /** @hidden */
  16364. _textures: {
  16365. [key: string]: Texture;
  16366. };
  16367. private _size;
  16368. private _currentRefreshId;
  16369. private _refreshRate;
  16370. private _vertexBuffers;
  16371. private _indexBuffer;
  16372. private _uniforms;
  16373. private _samplers;
  16374. private _fragment;
  16375. private _floats;
  16376. private _ints;
  16377. private _floatsArrays;
  16378. private _colors3;
  16379. private _colors4;
  16380. private _vectors2;
  16381. private _vectors3;
  16382. private _matrices;
  16383. private _fallbackTexture;
  16384. private _fallbackTextureUsed;
  16385. private _engine;
  16386. private _cachedDefines;
  16387. private _contentUpdateId;
  16388. private _contentData;
  16389. /**
  16390. * Instantiates a new procedural texture.
  16391. * 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.
  16392. * This is the base class of any Procedural texture and contains most of the shareable code.
  16393. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16394. * @param name Define the name of the texture
  16395. * @param size Define the size of the texture to create
  16396. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16397. * @param scene Define the scene the texture belongs to
  16398. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16399. * @param generateMipMaps Define if the texture should creates mip maps or not
  16400. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16401. */
  16402. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16403. /**
  16404. * The effect that is created when initializing the post process.
  16405. * @returns The created effect corresponding the the postprocess.
  16406. */
  16407. getEffect(): Effect;
  16408. /**
  16409. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16410. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16411. */
  16412. getContent(): Nullable<ArrayBufferView>;
  16413. private _createIndexBuffer;
  16414. /** @hidden */
  16415. _rebuild(): void;
  16416. /**
  16417. * Resets the texture in order to recreate its associated resources.
  16418. * This can be called in case of context loss
  16419. */
  16420. reset(): void;
  16421. protected _getDefines(): string;
  16422. /**
  16423. * Is the texture ready to be used ? (rendered at least once)
  16424. * @returns true if ready, otherwise, false.
  16425. */
  16426. isReady(): boolean;
  16427. /**
  16428. * Resets the refresh counter of the texture and start bak from scratch.
  16429. * Could be useful to regenerate the texture if it is setup to render only once.
  16430. */
  16431. resetRefreshCounter(): void;
  16432. /**
  16433. * Set the fragment shader to use in order to render the texture.
  16434. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16435. */
  16436. setFragment(fragment: any): void;
  16437. /**
  16438. * Define the refresh rate of the texture or the rendering frequency.
  16439. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16440. */
  16441. refreshRate: number;
  16442. /** @hidden */
  16443. _shouldRender(): boolean;
  16444. /**
  16445. * Get the size the texture is rendering at.
  16446. * @returns the size (texture is always squared)
  16447. */
  16448. getRenderSize(): number;
  16449. /**
  16450. * Resize the texture to new value.
  16451. * @param size Define the new size the texture should have
  16452. * @param generateMipMaps Define whether the new texture should create mip maps
  16453. */
  16454. resize(size: number, generateMipMaps: boolean): void;
  16455. private _checkUniform;
  16456. /**
  16457. * Set a texture in the shader program used to render.
  16458. * @param name Define the name of the uniform samplers as defined in the shader
  16459. * @param texture Define the texture to bind to this sampler
  16460. * @return the texture itself allowing "fluent" like uniform updates
  16461. */
  16462. setTexture(name: string, texture: Texture): ProceduralTexture;
  16463. /**
  16464. * Set a float in the shader.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the texture itself allowing "fluent" like uniform updates
  16468. */
  16469. setFloat(name: string, value: number): ProceduralTexture;
  16470. /**
  16471. * Set a int in the shader.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the texture itself allowing "fluent" like uniform updates
  16475. */
  16476. setInt(name: string, value: number): ProceduralTexture;
  16477. /**
  16478. * Set an array of floats in the shader.
  16479. * @param name Define the name of the uniform as defined in the shader
  16480. * @param value Define the value to give to the uniform
  16481. * @return the texture itself allowing "fluent" like uniform updates
  16482. */
  16483. setFloats(name: string, value: number[]): ProceduralTexture;
  16484. /**
  16485. * Set a vec3 in the shader from a Color3.
  16486. * @param name Define the name of the uniform as defined in the shader
  16487. * @param value Define the value to give to the uniform
  16488. * @return the texture itself allowing "fluent" like uniform updates
  16489. */
  16490. setColor3(name: string, value: Color3): ProceduralTexture;
  16491. /**
  16492. * Set a vec4 in the shader from a Color4.
  16493. * @param name Define the name of the uniform as defined in the shader
  16494. * @param value Define the value to give to the uniform
  16495. * @return the texture itself allowing "fluent" like uniform updates
  16496. */
  16497. setColor4(name: string, value: Color4): ProceduralTexture;
  16498. /**
  16499. * Set a vec2 in the shader from a Vector2.
  16500. * @param name Define the name of the uniform as defined in the shader
  16501. * @param value Define the value to give to the uniform
  16502. * @return the texture itself allowing "fluent" like uniform updates
  16503. */
  16504. setVector2(name: string, value: Vector2): ProceduralTexture;
  16505. /**
  16506. * Set a vec3 in the shader from a Vector3.
  16507. * @param name Define the name of the uniform as defined in the shader
  16508. * @param value Define the value to give to the uniform
  16509. * @return the texture itself allowing "fluent" like uniform updates
  16510. */
  16511. setVector3(name: string, value: Vector3): ProceduralTexture;
  16512. /**
  16513. * Set a mat4 in the shader from a MAtrix.
  16514. * @param name Define the name of the uniform as defined in the shader
  16515. * @param value Define the value to give to the uniform
  16516. * @return the texture itself allowing "fluent" like uniform updates
  16517. */
  16518. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16519. /**
  16520. * Render the texture to its associated render target.
  16521. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16522. */
  16523. render(useCameraPostProcess?: boolean): void;
  16524. /**
  16525. * Clone the texture.
  16526. * @returns the cloned texture
  16527. */
  16528. clone(): ProceduralTexture;
  16529. /**
  16530. * Dispose the texture and release its asoociated resources.
  16531. */
  16532. dispose(): void;
  16533. }
  16534. }
  16535. declare module "babylonjs/Particles/baseParticleSystem" {
  16536. import { Nullable } from "babylonjs/types";
  16537. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16539. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16540. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16541. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16542. import { Scene } from "babylonjs/scene";
  16543. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16544. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16545. import { Texture } from "babylonjs/Materials/Textures/texture";
  16546. import { Color4 } from "babylonjs/Maths/math.color";
  16547. import { Animation } from "babylonjs/Animations/animation";
  16548. /**
  16549. * This represents the base class for particle system in Babylon.
  16550. * 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.
  16551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16552. * @example https://doc.babylonjs.com/babylon101/particles
  16553. */
  16554. export class BaseParticleSystem {
  16555. /**
  16556. * Source color is added to the destination color without alpha affecting the result
  16557. */
  16558. static BLENDMODE_ONEONE: number;
  16559. /**
  16560. * Blend current color and particle color using particle’s alpha
  16561. */
  16562. static BLENDMODE_STANDARD: number;
  16563. /**
  16564. * Add current color and particle color multiplied by particle’s alpha
  16565. */
  16566. static BLENDMODE_ADD: number;
  16567. /**
  16568. * Multiply current color with particle color
  16569. */
  16570. static BLENDMODE_MULTIPLY: number;
  16571. /**
  16572. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16573. */
  16574. static BLENDMODE_MULTIPLYADD: number;
  16575. /**
  16576. * List of animations used by the particle system.
  16577. */
  16578. animations: Animation[];
  16579. /**
  16580. * The id of the Particle system.
  16581. */
  16582. id: string;
  16583. /**
  16584. * The friendly name of the Particle system.
  16585. */
  16586. name: string;
  16587. /**
  16588. * The rendering group used by the Particle system to chose when to render.
  16589. */
  16590. renderingGroupId: number;
  16591. /**
  16592. * The emitter represents the Mesh or position we are attaching the particle system to.
  16593. */
  16594. emitter: Nullable<AbstractMesh | Vector3>;
  16595. /**
  16596. * The maximum number of particles to emit per frame
  16597. */
  16598. emitRate: number;
  16599. /**
  16600. * If you want to launch only a few particles at once, that can be done, as well.
  16601. */
  16602. manualEmitCount: number;
  16603. /**
  16604. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16605. */
  16606. updateSpeed: number;
  16607. /**
  16608. * The amount of time the particle system is running (depends of the overall update speed).
  16609. */
  16610. targetStopDuration: number;
  16611. /**
  16612. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16613. */
  16614. disposeOnStop: boolean;
  16615. /**
  16616. * Minimum power of emitting particles.
  16617. */
  16618. minEmitPower: number;
  16619. /**
  16620. * Maximum power of emitting particles.
  16621. */
  16622. maxEmitPower: number;
  16623. /**
  16624. * Minimum life time of emitting particles.
  16625. */
  16626. minLifeTime: number;
  16627. /**
  16628. * Maximum life time of emitting particles.
  16629. */
  16630. maxLifeTime: number;
  16631. /**
  16632. * Minimum Size of emitting particles.
  16633. */
  16634. minSize: number;
  16635. /**
  16636. * Maximum Size of emitting particles.
  16637. */
  16638. maxSize: number;
  16639. /**
  16640. * Minimum scale of emitting particles on X axis.
  16641. */
  16642. minScaleX: number;
  16643. /**
  16644. * Maximum scale of emitting particles on X axis.
  16645. */
  16646. maxScaleX: number;
  16647. /**
  16648. * Minimum scale of emitting particles on Y axis.
  16649. */
  16650. minScaleY: number;
  16651. /**
  16652. * Maximum scale of emitting particles on Y axis.
  16653. */
  16654. maxScaleY: number;
  16655. /**
  16656. * Gets or sets the minimal initial rotation in radians.
  16657. */
  16658. minInitialRotation: number;
  16659. /**
  16660. * Gets or sets the maximal initial rotation in radians.
  16661. */
  16662. maxInitialRotation: number;
  16663. /**
  16664. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16665. */
  16666. minAngularSpeed: number;
  16667. /**
  16668. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16669. */
  16670. maxAngularSpeed: number;
  16671. /**
  16672. * The texture used to render each particle. (this can be a spritesheet)
  16673. */
  16674. particleTexture: Nullable<Texture>;
  16675. /**
  16676. * The layer mask we are rendering the particles through.
  16677. */
  16678. layerMask: number;
  16679. /**
  16680. * This can help using your own shader to render the particle system.
  16681. * The according effect will be created
  16682. */
  16683. customShader: any;
  16684. /**
  16685. * By default particle system starts as soon as they are created. This prevents the
  16686. * automatic start to happen and let you decide when to start emitting particles.
  16687. */
  16688. preventAutoStart: boolean;
  16689. private _noiseTexture;
  16690. /**
  16691. * Gets or sets a texture used to add random noise to particle positions
  16692. */
  16693. noiseTexture: Nullable<ProceduralTexture>;
  16694. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16695. noiseStrength: Vector3;
  16696. /**
  16697. * Callback triggered when the particle animation is ending.
  16698. */
  16699. onAnimationEnd: Nullable<() => void>;
  16700. /**
  16701. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16702. */
  16703. blendMode: number;
  16704. /**
  16705. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16706. * to override the particles.
  16707. */
  16708. forceDepthWrite: boolean;
  16709. /** 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 */
  16710. preWarmCycles: number;
  16711. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16712. preWarmStepOffset: number;
  16713. /**
  16714. * 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)
  16715. */
  16716. spriteCellChangeSpeed: number;
  16717. /**
  16718. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16719. */
  16720. startSpriteCellID: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16723. */
  16724. endSpriteCellID: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16727. */
  16728. spriteCellWidth: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16731. */
  16732. spriteCellHeight: number;
  16733. /**
  16734. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16735. */
  16736. spriteRandomStartCell: boolean;
  16737. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16738. translationPivot: Vector2;
  16739. /** @hidden */
  16740. protected _isAnimationSheetEnabled: boolean;
  16741. /**
  16742. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16743. */
  16744. beginAnimationOnStart: boolean;
  16745. /**
  16746. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16747. */
  16748. beginAnimationFrom: number;
  16749. /**
  16750. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationTo: number;
  16753. /**
  16754. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16755. */
  16756. beginAnimationLoop: boolean;
  16757. /**
  16758. * Gets or sets a world offset applied to all particles
  16759. */
  16760. worldOffset: Vector3;
  16761. /**
  16762. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16763. */
  16764. isAnimationSheetEnabled: boolean;
  16765. /**
  16766. * Get hosting scene
  16767. * @returns the scene
  16768. */
  16769. getScene(): Scene;
  16770. /**
  16771. * You can use gravity if you want to give an orientation to your particles.
  16772. */
  16773. gravity: Vector3;
  16774. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16775. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16776. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16777. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16778. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16779. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16780. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16781. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16782. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16783. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16784. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16785. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16786. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16787. /**
  16788. * Defines the delay in milliseconds before starting the system (0 by default)
  16789. */
  16790. startDelay: number;
  16791. /**
  16792. * Gets the current list of drag gradients.
  16793. * You must use addDragGradient and removeDragGradient to udpate this list
  16794. * @returns the list of drag gradients
  16795. */
  16796. getDragGradients(): Nullable<Array<FactorGradient>>;
  16797. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16798. limitVelocityDamping: number;
  16799. /**
  16800. * Gets the current list of limit velocity gradients.
  16801. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16802. * @returns the list of limit velocity gradients
  16803. */
  16804. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16805. /**
  16806. * Gets the current list of color gradients.
  16807. * You must use addColorGradient and removeColorGradient to udpate this list
  16808. * @returns the list of color gradients
  16809. */
  16810. getColorGradients(): Nullable<Array<ColorGradient>>;
  16811. /**
  16812. * Gets the current list of size gradients.
  16813. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16814. * @returns the list of size gradients
  16815. */
  16816. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16817. /**
  16818. * Gets the current list of color remap gradients.
  16819. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16820. * @returns the list of color remap gradients
  16821. */
  16822. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16823. /**
  16824. * Gets the current list of alpha remap gradients.
  16825. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16826. * @returns the list of alpha remap gradients
  16827. */
  16828. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16829. /**
  16830. * Gets the current list of life time gradients.
  16831. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16832. * @returns the list of life time gradients
  16833. */
  16834. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16835. /**
  16836. * Gets the current list of angular speed gradients.
  16837. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16838. * @returns the list of angular speed gradients
  16839. */
  16840. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16841. /**
  16842. * Gets the current list of velocity gradients.
  16843. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16844. * @returns the list of velocity gradients
  16845. */
  16846. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16847. /**
  16848. * Gets the current list of start size gradients.
  16849. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16850. * @returns the list of start size gradients
  16851. */
  16852. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16853. /**
  16854. * Gets the current list of emit rate gradients.
  16855. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16856. * @returns the list of emit rate gradients
  16857. */
  16858. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16859. /**
  16860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16861. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16862. */
  16863. direction1: Vector3;
  16864. /**
  16865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16866. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16867. */
  16868. direction2: Vector3;
  16869. /**
  16870. * 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.
  16871. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16872. */
  16873. minEmitBox: Vector3;
  16874. /**
  16875. * 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.
  16876. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16877. */
  16878. maxEmitBox: Vector3;
  16879. /**
  16880. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16881. */
  16882. color1: Color4;
  16883. /**
  16884. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16885. */
  16886. color2: Color4;
  16887. /**
  16888. * Color the particle will have at the end of its lifetime
  16889. */
  16890. colorDead: Color4;
  16891. /**
  16892. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16893. */
  16894. textureMask: Color4;
  16895. /**
  16896. * The particle emitter type defines the emitter used by the particle system.
  16897. * It can be for example box, sphere, or cone...
  16898. */
  16899. particleEmitterType: IParticleEmitterType;
  16900. /** @hidden */
  16901. _isSubEmitter: boolean;
  16902. /**
  16903. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16904. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16905. */
  16906. billboardMode: number;
  16907. protected _isBillboardBased: boolean;
  16908. /**
  16909. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16910. */
  16911. isBillboardBased: boolean;
  16912. /**
  16913. * The scene the particle system belongs to.
  16914. */
  16915. protected _scene: Scene;
  16916. /**
  16917. * Local cache of defines for image processing.
  16918. */
  16919. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16920. /**
  16921. * Default configuration related to image processing available in the standard Material.
  16922. */
  16923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16924. /**
  16925. * Gets the image processing configuration used either in this material.
  16926. */
  16927. /**
  16928. * Sets the Default image processing configuration used either in the this material.
  16929. *
  16930. * If sets to null, the scene one is in use.
  16931. */
  16932. imageProcessingConfiguration: ImageProcessingConfiguration;
  16933. /**
  16934. * Attaches a new image processing configuration to the Standard Material.
  16935. * @param configuration
  16936. */
  16937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16938. /** @hidden */
  16939. protected _reset(): void;
  16940. /** @hidden */
  16941. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16942. /**
  16943. * Instantiates a particle system.
  16944. * 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.
  16945. * @param name The name of the particle system
  16946. */
  16947. constructor(name: string);
  16948. /**
  16949. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16952. * @returns the emitter
  16953. */
  16954. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16955. /**
  16956. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16957. * @param radius The radius of the hemisphere to emit from
  16958. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16959. * @returns the emitter
  16960. */
  16961. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16962. /**
  16963. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16964. * @param radius The radius of the sphere to emit from
  16965. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16966. * @returns the emitter
  16967. */
  16968. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16969. /**
  16970. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16971. * @param radius The radius of the sphere to emit from
  16972. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16973. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16974. * @returns the emitter
  16975. */
  16976. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16977. /**
  16978. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16979. * @param radius The radius of the emission cylinder
  16980. * @param height The height of the emission cylinder
  16981. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16982. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16983. * @returns the emitter
  16984. */
  16985. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16986. /**
  16987. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16988. * @param radius The radius of the cylinder to emit from
  16989. * @param height The height of the emission cylinder
  16990. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16991. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16992. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16993. * @returns the emitter
  16994. */
  16995. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16996. /**
  16997. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16998. * @param radius The radius of the cone to emit from
  16999. * @param angle The base angle of the cone
  17000. * @returns the emitter
  17001. */
  17002. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17003. /**
  17004. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17005. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17006. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17007. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17008. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17009. * @returns the emitter
  17010. */
  17011. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17012. }
  17013. }
  17014. declare module "babylonjs/Particles/subEmitter" {
  17015. import { Scene } from "babylonjs/scene";
  17016. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17017. /**
  17018. * Type of sub emitter
  17019. */
  17020. export enum SubEmitterType {
  17021. /**
  17022. * Attached to the particle over it's lifetime
  17023. */
  17024. ATTACHED = 0,
  17025. /**
  17026. * Created when the particle dies
  17027. */
  17028. END = 1
  17029. }
  17030. /**
  17031. * Sub emitter class used to emit particles from an existing particle
  17032. */
  17033. export class SubEmitter {
  17034. /**
  17035. * the particle system to be used by the sub emitter
  17036. */
  17037. particleSystem: ParticleSystem;
  17038. /**
  17039. * Type of the submitter (Default: END)
  17040. */
  17041. type: SubEmitterType;
  17042. /**
  17043. * 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)
  17044. * Note: This only is supported when using an emitter of type Mesh
  17045. */
  17046. inheritDirection: boolean;
  17047. /**
  17048. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17049. */
  17050. inheritedVelocityAmount: number;
  17051. /**
  17052. * Creates a sub emitter
  17053. * @param particleSystem the particle system to be used by the sub emitter
  17054. */
  17055. constructor(
  17056. /**
  17057. * the particle system to be used by the sub emitter
  17058. */
  17059. particleSystem: ParticleSystem);
  17060. /**
  17061. * Clones the sub emitter
  17062. * @returns the cloned sub emitter
  17063. */
  17064. clone(): SubEmitter;
  17065. /**
  17066. * Serialize current object to a JSON object
  17067. * @returns the serialized object
  17068. */
  17069. serialize(): any;
  17070. /** @hidden */
  17071. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17072. /**
  17073. * Creates a new SubEmitter from a serialized JSON version
  17074. * @param serializationObject defines the JSON object to read from
  17075. * @param scene defines the hosting scene
  17076. * @param rootUrl defines the rootUrl for data loading
  17077. * @returns a new SubEmitter
  17078. */
  17079. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17080. /** Release associated resources */
  17081. dispose(): void;
  17082. }
  17083. }
  17084. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17085. /** @hidden */
  17086. export var clipPlaneFragmentDeclaration: {
  17087. name: string;
  17088. shader: string;
  17089. };
  17090. }
  17091. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17092. /** @hidden */
  17093. export var imageProcessingDeclaration: {
  17094. name: string;
  17095. shader: string;
  17096. };
  17097. }
  17098. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17099. /** @hidden */
  17100. export var imageProcessingFunctions: {
  17101. name: string;
  17102. shader: string;
  17103. };
  17104. }
  17105. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17106. /** @hidden */
  17107. export var clipPlaneFragment: {
  17108. name: string;
  17109. shader: string;
  17110. };
  17111. }
  17112. declare module "babylonjs/Shaders/particles.fragment" {
  17113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17114. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17115. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17116. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17118. /** @hidden */
  17119. export var particlesPixelShader: {
  17120. name: string;
  17121. shader: string;
  17122. };
  17123. }
  17124. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17125. /** @hidden */
  17126. export var clipPlaneVertexDeclaration: {
  17127. name: string;
  17128. shader: string;
  17129. };
  17130. }
  17131. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17132. /** @hidden */
  17133. export var clipPlaneVertex: {
  17134. name: string;
  17135. shader: string;
  17136. };
  17137. }
  17138. declare module "babylonjs/Shaders/particles.vertex" {
  17139. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17140. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17141. /** @hidden */
  17142. export var particlesVertexShader: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Particles/particleSystem" {
  17148. import { Nullable } from "babylonjs/types";
  17149. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17150. import { Observable } from "babylonjs/Misc/observable";
  17151. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17152. import { Effect } from "babylonjs/Materials/effect";
  17153. import { Scene, IDisposable } from "babylonjs/scene";
  17154. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17155. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17156. import { Particle } from "babylonjs/Particles/particle";
  17157. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17158. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17159. import "babylonjs/Shaders/particles.fragment";
  17160. import "babylonjs/Shaders/particles.vertex";
  17161. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17162. /**
  17163. * This represents a particle system in Babylon.
  17164. * 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.
  17165. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17166. * @example https://doc.babylonjs.com/babylon101/particles
  17167. */
  17168. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17169. /**
  17170. * Billboard mode will only apply to Y axis
  17171. */
  17172. static readonly BILLBOARDMODE_Y: number;
  17173. /**
  17174. * Billboard mode will apply to all axes
  17175. */
  17176. static readonly BILLBOARDMODE_ALL: number;
  17177. /**
  17178. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17179. */
  17180. static readonly BILLBOARDMODE_STRETCHED: number;
  17181. /**
  17182. * This function can be defined to provide custom update for active particles.
  17183. * This function will be called instead of regular update (age, position, color, etc.).
  17184. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17185. */
  17186. updateFunction: (particles: Particle[]) => void;
  17187. private _emitterWorldMatrix;
  17188. /**
  17189. * This function can be defined to specify initial direction for every new particle.
  17190. * It by default use the emitterType defined function
  17191. */
  17192. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17193. /**
  17194. * This function can be defined to specify initial position for every new particle.
  17195. * It by default use the emitterType defined function
  17196. */
  17197. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17198. /**
  17199. * @hidden
  17200. */
  17201. _inheritedVelocityOffset: Vector3;
  17202. /**
  17203. * An event triggered when the system is disposed
  17204. */
  17205. onDisposeObservable: Observable<ParticleSystem>;
  17206. private _onDisposeObserver;
  17207. /**
  17208. * Sets a callback that will be triggered when the system is disposed
  17209. */
  17210. onDispose: () => void;
  17211. private _particles;
  17212. private _epsilon;
  17213. private _capacity;
  17214. private _stockParticles;
  17215. private _newPartsExcess;
  17216. private _vertexData;
  17217. private _vertexBuffer;
  17218. private _vertexBuffers;
  17219. private _spriteBuffer;
  17220. private _indexBuffer;
  17221. private _effect;
  17222. private _customEffect;
  17223. private _cachedDefines;
  17224. private _scaledColorStep;
  17225. private _colorDiff;
  17226. private _scaledDirection;
  17227. private _scaledGravity;
  17228. private _currentRenderId;
  17229. private _alive;
  17230. private _useInstancing;
  17231. private _started;
  17232. private _stopped;
  17233. private _actualFrame;
  17234. private _scaledUpdateSpeed;
  17235. private _vertexBufferSize;
  17236. /** @hidden */
  17237. _currentEmitRateGradient: Nullable<FactorGradient>;
  17238. /** @hidden */
  17239. _currentEmitRate1: number;
  17240. /** @hidden */
  17241. _currentEmitRate2: number;
  17242. /** @hidden */
  17243. _currentStartSizeGradient: Nullable<FactorGradient>;
  17244. /** @hidden */
  17245. _currentStartSize1: number;
  17246. /** @hidden */
  17247. _currentStartSize2: number;
  17248. private readonly _rawTextureWidth;
  17249. private _rampGradientsTexture;
  17250. private _useRampGradients;
  17251. /** Gets or sets a boolean indicating that ramp gradients must be used
  17252. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17253. */
  17254. useRampGradients: boolean;
  17255. /**
  17256. * 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.
  17257. * 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: [])
  17258. */
  17259. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17260. private _subEmitters;
  17261. /**
  17262. * @hidden
  17263. * If the particle systems emitter should be disposed when the particle system is disposed
  17264. */
  17265. _disposeEmitterOnDispose: boolean;
  17266. /**
  17267. * The current active Sub-systems, this property is used by the root particle system only.
  17268. */
  17269. activeSubSystems: Array<ParticleSystem>;
  17270. private _rootParticleSystem;
  17271. /**
  17272. * Gets the current list of active particles
  17273. */
  17274. readonly particles: Particle[];
  17275. /**
  17276. * Returns the string "ParticleSystem"
  17277. * @returns a string containing the class name
  17278. */
  17279. getClassName(): string;
  17280. /**
  17281. * Instantiates a particle system.
  17282. * 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.
  17283. * @param name The name of the particle system
  17284. * @param capacity The max number of particles alive at the same time
  17285. * @param scene The scene the particle system belongs to
  17286. * @param customEffect a custom effect used to change the way particles are rendered by default
  17287. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17288. * @param epsilon Offset used to render the particles
  17289. */
  17290. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17291. private _addFactorGradient;
  17292. private _removeFactorGradient;
  17293. /**
  17294. * Adds a new life time gradient
  17295. * @param gradient defines the gradient to use (between 0 and 1)
  17296. * @param factor defines the life time factor to affect to the specified gradient
  17297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17298. * @returns the current particle system
  17299. */
  17300. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17301. /**
  17302. * Remove a specific life time gradient
  17303. * @param gradient defines the gradient to remove
  17304. * @returns the current particle system
  17305. */
  17306. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17307. /**
  17308. * Adds a new size gradient
  17309. * @param gradient defines the gradient to use (between 0 and 1)
  17310. * @param factor defines the size factor to affect to the specified gradient
  17311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17312. * @returns the current particle system
  17313. */
  17314. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17315. /**
  17316. * Remove a specific size gradient
  17317. * @param gradient defines the gradient to remove
  17318. * @returns the current particle system
  17319. */
  17320. removeSizeGradient(gradient: number): IParticleSystem;
  17321. /**
  17322. * Adds a new color remap gradient
  17323. * @param gradient defines the gradient to use (between 0 and 1)
  17324. * @param min defines the color remap minimal range
  17325. * @param max defines the color remap maximal range
  17326. * @returns the current particle system
  17327. */
  17328. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17329. /**
  17330. * Remove a specific color remap gradient
  17331. * @param gradient defines the gradient to remove
  17332. * @returns the current particle system
  17333. */
  17334. removeColorRemapGradient(gradient: number): IParticleSystem;
  17335. /**
  17336. * Adds a new alpha remap gradient
  17337. * @param gradient defines the gradient to use (between 0 and 1)
  17338. * @param min defines the alpha remap minimal range
  17339. * @param max defines the alpha remap maximal range
  17340. * @returns the current particle system
  17341. */
  17342. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17343. /**
  17344. * Remove a specific alpha remap gradient
  17345. * @param gradient defines the gradient to remove
  17346. * @returns the current particle system
  17347. */
  17348. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17349. /**
  17350. * Adds a new angular speed gradient
  17351. * @param gradient defines the gradient to use (between 0 and 1)
  17352. * @param factor defines the angular speed to affect to the specified gradient
  17353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17354. * @returns the current particle system
  17355. */
  17356. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17357. /**
  17358. * Remove a specific angular speed gradient
  17359. * @param gradient defines the gradient to remove
  17360. * @returns the current particle system
  17361. */
  17362. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17363. /**
  17364. * Adds a new velocity gradient
  17365. * @param gradient defines the gradient to use (between 0 and 1)
  17366. * @param factor defines the velocity to affect to the specified gradient
  17367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17368. * @returns the current particle system
  17369. */
  17370. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17371. /**
  17372. * Remove a specific velocity gradient
  17373. * @param gradient defines the gradient to remove
  17374. * @returns the current particle system
  17375. */
  17376. removeVelocityGradient(gradient: number): IParticleSystem;
  17377. /**
  17378. * Adds a new limit velocity gradient
  17379. * @param gradient defines the gradient to use (between 0 and 1)
  17380. * @param factor defines the limit velocity value to affect to the specified gradient
  17381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17382. * @returns the current particle system
  17383. */
  17384. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17385. /**
  17386. * Remove a specific limit velocity gradient
  17387. * @param gradient defines the gradient to remove
  17388. * @returns the current particle system
  17389. */
  17390. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17391. /**
  17392. * Adds a new drag gradient
  17393. * @param gradient defines the gradient to use (between 0 and 1)
  17394. * @param factor defines the drag value to affect to the specified gradient
  17395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17396. * @returns the current particle system
  17397. */
  17398. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17399. /**
  17400. * Remove a specific drag gradient
  17401. * @param gradient defines the gradient to remove
  17402. * @returns the current particle system
  17403. */
  17404. removeDragGradient(gradient: number): IParticleSystem;
  17405. /**
  17406. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17407. * @param gradient defines the gradient to use (between 0 and 1)
  17408. * @param factor defines the emit rate value to affect to the specified gradient
  17409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17410. * @returns the current particle system
  17411. */
  17412. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17413. /**
  17414. * Remove a specific emit rate gradient
  17415. * @param gradient defines the gradient to remove
  17416. * @returns the current particle system
  17417. */
  17418. removeEmitRateGradient(gradient: number): IParticleSystem;
  17419. /**
  17420. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17421. * @param gradient defines the gradient to use (between 0 and 1)
  17422. * @param factor defines the start size value to affect to the specified gradient
  17423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17424. * @returns the current particle system
  17425. */
  17426. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17427. /**
  17428. * Remove a specific start size gradient
  17429. * @param gradient defines the gradient to remove
  17430. * @returns the current particle system
  17431. */
  17432. removeStartSizeGradient(gradient: number): IParticleSystem;
  17433. private _createRampGradientTexture;
  17434. /**
  17435. * Gets the current list of ramp gradients.
  17436. * You must use addRampGradient and removeRampGradient to udpate this list
  17437. * @returns the list of ramp gradients
  17438. */
  17439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17440. /**
  17441. * Adds a new ramp gradient used to remap particle colors
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param color defines the color to affect to the specified gradient
  17444. * @returns the current particle system
  17445. */
  17446. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17447. /**
  17448. * Remove a specific ramp gradient
  17449. * @param gradient defines the gradient to remove
  17450. * @returns the current particle system
  17451. */
  17452. removeRampGradient(gradient: number): ParticleSystem;
  17453. /**
  17454. * Adds a new color gradient
  17455. * @param gradient defines the gradient to use (between 0 and 1)
  17456. * @param color1 defines the color to affect to the specified gradient
  17457. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17458. * @returns this particle system
  17459. */
  17460. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17461. /**
  17462. * Remove a specific color gradient
  17463. * @param gradient defines the gradient to remove
  17464. * @returns this particle system
  17465. */
  17466. removeColorGradient(gradient: number): IParticleSystem;
  17467. private _fetchR;
  17468. protected _reset(): void;
  17469. private _resetEffect;
  17470. private _createVertexBuffers;
  17471. private _createIndexBuffer;
  17472. /**
  17473. * Gets the maximum number of particles active at the same time.
  17474. * @returns The max number of active particles.
  17475. */
  17476. getCapacity(): number;
  17477. /**
  17478. * Gets whether there are still active particles in the system.
  17479. * @returns True if it is alive, otherwise false.
  17480. */
  17481. isAlive(): boolean;
  17482. /**
  17483. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17484. * @returns True if it has been started, otherwise false.
  17485. */
  17486. isStarted(): boolean;
  17487. private _prepareSubEmitterInternalArray;
  17488. /**
  17489. * Starts the particle system and begins to emit
  17490. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17491. */
  17492. start(delay?: number): void;
  17493. /**
  17494. * Stops the particle system.
  17495. * @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.
  17496. */
  17497. stop(stopSubEmitters?: boolean): void;
  17498. /**
  17499. * Remove all active particles
  17500. */
  17501. reset(): void;
  17502. /**
  17503. * @hidden (for internal use only)
  17504. */
  17505. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17506. /**
  17507. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17508. * Its lifetime will start back at 0.
  17509. */
  17510. recycleParticle: (particle: Particle) => void;
  17511. private _stopSubEmitters;
  17512. private _createParticle;
  17513. private _removeFromRoot;
  17514. private _emitFromParticle;
  17515. private _update;
  17516. /** @hidden */
  17517. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17518. /** @hidden */
  17519. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17520. /** @hidden */
  17521. private _getEffect;
  17522. /**
  17523. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17524. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17525. */
  17526. animate(preWarmOnly?: boolean): void;
  17527. private _appendParticleVertices;
  17528. /**
  17529. * Rebuilds the particle system.
  17530. */
  17531. rebuild(): void;
  17532. /**
  17533. * Is this system ready to be used/rendered
  17534. * @return true if the system is ready
  17535. */
  17536. isReady(): boolean;
  17537. private _render;
  17538. /**
  17539. * Renders the particle system in its current state.
  17540. * @returns the current number of particles
  17541. */
  17542. render(): number;
  17543. /**
  17544. * Disposes the particle system and free the associated resources
  17545. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17546. */
  17547. dispose(disposeTexture?: boolean): void;
  17548. /**
  17549. * Clones the particle system.
  17550. * @param name The name of the cloned object
  17551. * @param newEmitter The new emitter to use
  17552. * @returns the cloned particle system
  17553. */
  17554. clone(name: string, newEmitter: any): ParticleSystem;
  17555. /**
  17556. * Serializes the particle system to a JSON object.
  17557. * @returns the JSON object
  17558. */
  17559. serialize(): any;
  17560. /** @hidden */
  17561. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17562. /** @hidden */
  17563. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17564. /**
  17565. * Parses a JSON object to create a particle system.
  17566. * @param parsedParticleSystem The JSON object to parse
  17567. * @param scene The scene to create the particle system in
  17568. * @param rootUrl The root url to use to load external dependencies like texture
  17569. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17570. * @returns the Parsed particle system
  17571. */
  17572. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17573. }
  17574. }
  17575. declare module "babylonjs/Particles/particle" {
  17576. import { Nullable } from "babylonjs/types";
  17577. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17578. import { Color4 } from "babylonjs/Maths/math.color";
  17579. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17580. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17581. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17582. /**
  17583. * A particle represents one of the element emitted by a particle system.
  17584. * This is mainly define by its coordinates, direction, velocity and age.
  17585. */
  17586. export class Particle {
  17587. /**
  17588. * The particle system the particle belongs to.
  17589. */
  17590. particleSystem: ParticleSystem;
  17591. private static _Count;
  17592. /**
  17593. * Unique ID of the particle
  17594. */
  17595. id: number;
  17596. /**
  17597. * The world position of the particle in the scene.
  17598. */
  17599. position: Vector3;
  17600. /**
  17601. * The world direction of the particle in the scene.
  17602. */
  17603. direction: Vector3;
  17604. /**
  17605. * The color of the particle.
  17606. */
  17607. color: Color4;
  17608. /**
  17609. * The color change of the particle per step.
  17610. */
  17611. colorStep: Color4;
  17612. /**
  17613. * Defines how long will the life of the particle be.
  17614. */
  17615. lifeTime: number;
  17616. /**
  17617. * The current age of the particle.
  17618. */
  17619. age: number;
  17620. /**
  17621. * The current size of the particle.
  17622. */
  17623. size: number;
  17624. /**
  17625. * The current scale of the particle.
  17626. */
  17627. scale: Vector2;
  17628. /**
  17629. * The current angle of the particle.
  17630. */
  17631. angle: number;
  17632. /**
  17633. * Defines how fast is the angle changing.
  17634. */
  17635. angularSpeed: number;
  17636. /**
  17637. * Defines the cell index used by the particle to be rendered from a sprite.
  17638. */
  17639. cellIndex: number;
  17640. /**
  17641. * The information required to support color remapping
  17642. */
  17643. remapData: Vector4;
  17644. /** @hidden */
  17645. _randomCellOffset?: number;
  17646. /** @hidden */
  17647. _initialDirection: Nullable<Vector3>;
  17648. /** @hidden */
  17649. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17650. /** @hidden */
  17651. _initialStartSpriteCellID: number;
  17652. /** @hidden */
  17653. _initialEndSpriteCellID: number;
  17654. /** @hidden */
  17655. _currentColorGradient: Nullable<ColorGradient>;
  17656. /** @hidden */
  17657. _currentColor1: Color4;
  17658. /** @hidden */
  17659. _currentColor2: Color4;
  17660. /** @hidden */
  17661. _currentSizeGradient: Nullable<FactorGradient>;
  17662. /** @hidden */
  17663. _currentSize1: number;
  17664. /** @hidden */
  17665. _currentSize2: number;
  17666. /** @hidden */
  17667. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17668. /** @hidden */
  17669. _currentAngularSpeed1: number;
  17670. /** @hidden */
  17671. _currentAngularSpeed2: number;
  17672. /** @hidden */
  17673. _currentVelocityGradient: Nullable<FactorGradient>;
  17674. /** @hidden */
  17675. _currentVelocity1: number;
  17676. /** @hidden */
  17677. _currentVelocity2: number;
  17678. /** @hidden */
  17679. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17680. /** @hidden */
  17681. _currentLimitVelocity1: number;
  17682. /** @hidden */
  17683. _currentLimitVelocity2: number;
  17684. /** @hidden */
  17685. _currentDragGradient: Nullable<FactorGradient>;
  17686. /** @hidden */
  17687. _currentDrag1: number;
  17688. /** @hidden */
  17689. _currentDrag2: number;
  17690. /** @hidden */
  17691. _randomNoiseCoordinates1: Vector3;
  17692. /** @hidden */
  17693. _randomNoiseCoordinates2: Vector3;
  17694. /**
  17695. * Creates a new instance Particle
  17696. * @param particleSystem the particle system the particle belongs to
  17697. */
  17698. constructor(
  17699. /**
  17700. * The particle system the particle belongs to.
  17701. */
  17702. particleSystem: ParticleSystem);
  17703. private updateCellInfoFromSystem;
  17704. /**
  17705. * Defines how the sprite cell index is updated for the particle
  17706. */
  17707. updateCellIndex(): void;
  17708. /** @hidden */
  17709. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17710. /** @hidden */
  17711. _inheritParticleInfoToSubEmitters(): void;
  17712. /** @hidden */
  17713. _reset(): void;
  17714. /**
  17715. * Copy the properties of particle to another one.
  17716. * @param other the particle to copy the information to.
  17717. */
  17718. copyTo(other: Particle): void;
  17719. }
  17720. }
  17721. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17722. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17723. import { Effect } from "babylonjs/Materials/effect";
  17724. import { Particle } from "babylonjs/Particles/particle";
  17725. /**
  17726. * Particle emitter represents a volume emitting particles.
  17727. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17728. */
  17729. export interface IParticleEmitterType {
  17730. /**
  17731. * Called by the particle System when the direction is computed for the created particle.
  17732. * @param worldMatrix is the world matrix of the particle system
  17733. * @param directionToUpdate is the direction vector to update with the result
  17734. * @param particle is the particle we are computed the direction for
  17735. */
  17736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17737. /**
  17738. * Called by the particle System when the position is computed for the created particle.
  17739. * @param worldMatrix is the world matrix of the particle system
  17740. * @param positionToUpdate is the position vector to update with the result
  17741. * @param particle is the particle we are computed the position for
  17742. */
  17743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17744. /**
  17745. * Clones the current emitter and returns a copy of it
  17746. * @returns the new emitter
  17747. */
  17748. clone(): IParticleEmitterType;
  17749. /**
  17750. * Called by the GPUParticleSystem to setup the update shader
  17751. * @param effect defines the update shader
  17752. */
  17753. applyToShader(effect: Effect): void;
  17754. /**
  17755. * Returns a string to use to update the GPU particles update shader
  17756. * @returns the effect defines string
  17757. */
  17758. getEffectDefines(): string;
  17759. /**
  17760. * Returns a string representing the class name
  17761. * @returns a string containing the class name
  17762. */
  17763. getClassName(): string;
  17764. /**
  17765. * Serializes the particle system to a JSON object.
  17766. * @returns the JSON object
  17767. */
  17768. serialize(): any;
  17769. /**
  17770. * Parse properties from a JSON object
  17771. * @param serializationObject defines the JSON object
  17772. */
  17773. parse(serializationObject: any): void;
  17774. }
  17775. }
  17776. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17777. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17778. import { Effect } from "babylonjs/Materials/effect";
  17779. import { Particle } from "babylonjs/Particles/particle";
  17780. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17781. /**
  17782. * Particle emitter emitting particles from the inside of a box.
  17783. * It emits the particles randomly between 2 given directions.
  17784. */
  17785. export class BoxParticleEmitter implements IParticleEmitterType {
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction1: Vector3;
  17790. /**
  17791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17792. */
  17793. direction2: Vector3;
  17794. /**
  17795. * 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.
  17796. */
  17797. minEmitBox: Vector3;
  17798. /**
  17799. * 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.
  17800. */
  17801. maxEmitBox: Vector3;
  17802. /**
  17803. * Creates a new instance BoxParticleEmitter
  17804. */
  17805. constructor();
  17806. /**
  17807. * Called by the particle System when the direction is computed for the created particle.
  17808. * @param worldMatrix is the world matrix of the particle system
  17809. * @param directionToUpdate is the direction vector to update with the result
  17810. * @param particle is the particle we are computed the direction for
  17811. */
  17812. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17813. /**
  17814. * Called by the particle System when the position is computed for the created particle.
  17815. * @param worldMatrix is the world matrix of the particle system
  17816. * @param positionToUpdate is the position vector to update with the result
  17817. * @param particle is the particle we are computed the position for
  17818. */
  17819. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17820. /**
  17821. * Clones the current emitter and returns a copy of it
  17822. * @returns the new emitter
  17823. */
  17824. clone(): BoxParticleEmitter;
  17825. /**
  17826. * Called by the GPUParticleSystem to setup the update shader
  17827. * @param effect defines the update shader
  17828. */
  17829. applyToShader(effect: Effect): void;
  17830. /**
  17831. * Returns a string to use to update the GPU particles update shader
  17832. * @returns a string containng the defines string
  17833. */
  17834. getEffectDefines(): string;
  17835. /**
  17836. * Returns the string "BoxParticleEmitter"
  17837. * @returns a string containing the class name
  17838. */
  17839. getClassName(): string;
  17840. /**
  17841. * Serializes the particle system to a JSON object.
  17842. * @returns the JSON object
  17843. */
  17844. serialize(): any;
  17845. /**
  17846. * Parse properties from a JSON object
  17847. * @param serializationObject defines the JSON object
  17848. */
  17849. parse(serializationObject: any): void;
  17850. }
  17851. }
  17852. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17853. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17854. import { Effect } from "babylonjs/Materials/effect";
  17855. import { Particle } from "babylonjs/Particles/particle";
  17856. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17857. /**
  17858. * Particle emitter emitting particles from the inside of a cone.
  17859. * It emits the particles alongside the cone volume from the base to the particle.
  17860. * The emission direction might be randomized.
  17861. */
  17862. export class ConeParticleEmitter implements IParticleEmitterType {
  17863. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17864. directionRandomizer: number;
  17865. private _radius;
  17866. private _angle;
  17867. private _height;
  17868. /**
  17869. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17870. */
  17871. radiusRange: number;
  17872. /**
  17873. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17874. */
  17875. heightRange: number;
  17876. /**
  17877. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17878. */
  17879. emitFromSpawnPointOnly: boolean;
  17880. /**
  17881. * Gets or sets the radius of the emission cone
  17882. */
  17883. radius: number;
  17884. /**
  17885. * Gets or sets the angle of the emission cone
  17886. */
  17887. angle: number;
  17888. private _buildHeight;
  17889. /**
  17890. * Creates a new instance ConeParticleEmitter
  17891. * @param radius the radius of the emission cone (1 by default)
  17892. * @param angle the cone base angle (PI by default)
  17893. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17894. */
  17895. constructor(radius?: number, angle?: number,
  17896. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17897. directionRandomizer?: number);
  17898. /**
  17899. * Called by the particle System when the direction is computed for the created particle.
  17900. * @param worldMatrix is the world matrix of the particle system
  17901. * @param directionToUpdate is the direction vector to update with the result
  17902. * @param particle is the particle we are computed the direction for
  17903. */
  17904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17905. /**
  17906. * Called by the particle System when the position is computed for the created particle.
  17907. * @param worldMatrix is the world matrix of the particle system
  17908. * @param positionToUpdate is the position vector to update with the result
  17909. * @param particle is the particle we are computed the position for
  17910. */
  17911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17912. /**
  17913. * Clones the current emitter and returns a copy of it
  17914. * @returns the new emitter
  17915. */
  17916. clone(): ConeParticleEmitter;
  17917. /**
  17918. * Called by the GPUParticleSystem to setup the update shader
  17919. * @param effect defines the update shader
  17920. */
  17921. applyToShader(effect: Effect): void;
  17922. /**
  17923. * Returns a string to use to update the GPU particles update shader
  17924. * @returns a string containng the defines string
  17925. */
  17926. getEffectDefines(): string;
  17927. /**
  17928. * Returns the string "ConeParticleEmitter"
  17929. * @returns a string containing the class name
  17930. */
  17931. getClassName(): string;
  17932. /**
  17933. * Serializes the particle system to a JSON object.
  17934. * @returns the JSON object
  17935. */
  17936. serialize(): any;
  17937. /**
  17938. * Parse properties from a JSON object
  17939. * @param serializationObject defines the JSON object
  17940. */
  17941. parse(serializationObject: any): void;
  17942. }
  17943. }
  17944. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17945. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17946. import { Effect } from "babylonjs/Materials/effect";
  17947. import { Particle } from "babylonjs/Particles/particle";
  17948. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17949. /**
  17950. * Particle emitter emitting particles from the inside of a cylinder.
  17951. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17952. */
  17953. export class CylinderParticleEmitter implements IParticleEmitterType {
  17954. /**
  17955. * The radius of the emission cylinder.
  17956. */
  17957. radius: number;
  17958. /**
  17959. * The height of the emission cylinder.
  17960. */
  17961. height: number;
  17962. /**
  17963. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17964. */
  17965. radiusRange: number;
  17966. /**
  17967. * How much to randomize the particle direction [0-1].
  17968. */
  17969. directionRandomizer: number;
  17970. /**
  17971. * Creates a new instance CylinderParticleEmitter
  17972. * @param radius the radius of the emission cylinder (1 by default)
  17973. * @param height the height of the emission cylinder (1 by default)
  17974. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17975. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17976. */
  17977. constructor(
  17978. /**
  17979. * The radius of the emission cylinder.
  17980. */
  17981. radius?: number,
  17982. /**
  17983. * The height of the emission cylinder.
  17984. */
  17985. height?: number,
  17986. /**
  17987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17988. */
  17989. radiusRange?: number,
  17990. /**
  17991. * How much to randomize the particle direction [0-1].
  17992. */
  17993. directionRandomizer?: number);
  17994. /**
  17995. * Called by the particle System when the direction is computed for the created particle.
  17996. * @param worldMatrix is the world matrix of the particle system
  17997. * @param directionToUpdate is the direction vector to update with the result
  17998. * @param particle is the particle we are computed the direction for
  17999. */
  18000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18001. /**
  18002. * Called by the particle System when the position is computed for the created particle.
  18003. * @param worldMatrix is the world matrix of the particle system
  18004. * @param positionToUpdate is the position vector to update with the result
  18005. * @param particle is the particle we are computed the position for
  18006. */
  18007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18008. /**
  18009. * Clones the current emitter and returns a copy of it
  18010. * @returns the new emitter
  18011. */
  18012. clone(): CylinderParticleEmitter;
  18013. /**
  18014. * Called by the GPUParticleSystem to setup the update shader
  18015. * @param effect defines the update shader
  18016. */
  18017. applyToShader(effect: Effect): void;
  18018. /**
  18019. * Returns a string to use to update the GPU particles update shader
  18020. * @returns a string containng the defines string
  18021. */
  18022. getEffectDefines(): string;
  18023. /**
  18024. * Returns the string "CylinderParticleEmitter"
  18025. * @returns a string containing the class name
  18026. */
  18027. getClassName(): string;
  18028. /**
  18029. * Serializes the particle system to a JSON object.
  18030. * @returns the JSON object
  18031. */
  18032. serialize(): any;
  18033. /**
  18034. * Parse properties from a JSON object
  18035. * @param serializationObject defines the JSON object
  18036. */
  18037. parse(serializationObject: any): void;
  18038. }
  18039. /**
  18040. * Particle emitter emitting particles from the inside of a cylinder.
  18041. * It emits the particles randomly between two vectors.
  18042. */
  18043. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18044. /**
  18045. * The min limit of the emission direction.
  18046. */
  18047. direction1: Vector3;
  18048. /**
  18049. * The max limit of the emission direction.
  18050. */
  18051. direction2: Vector3;
  18052. /**
  18053. * Creates a new instance CylinderDirectedParticleEmitter
  18054. * @param radius the radius of the emission cylinder (1 by default)
  18055. * @param height the height of the emission cylinder (1 by default)
  18056. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18057. * @param direction1 the min limit of the emission direction (up vector by default)
  18058. * @param direction2 the max limit of the emission direction (up vector by default)
  18059. */
  18060. constructor(radius?: number, height?: number, radiusRange?: number,
  18061. /**
  18062. * The min limit of the emission direction.
  18063. */
  18064. direction1?: Vector3,
  18065. /**
  18066. * The max limit of the emission direction.
  18067. */
  18068. direction2?: Vector3);
  18069. /**
  18070. * Called by the particle System when the direction is computed for the created particle.
  18071. * @param worldMatrix is the world matrix of the particle system
  18072. * @param directionToUpdate is the direction vector to update with the result
  18073. * @param particle is the particle we are computed the direction for
  18074. */
  18075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18076. /**
  18077. * Clones the current emitter and returns a copy of it
  18078. * @returns the new emitter
  18079. */
  18080. clone(): CylinderDirectedParticleEmitter;
  18081. /**
  18082. * Called by the GPUParticleSystem to setup the update shader
  18083. * @param effect defines the update shader
  18084. */
  18085. applyToShader(effect: Effect): void;
  18086. /**
  18087. * Returns a string to use to update the GPU particles update shader
  18088. * @returns a string containng the defines string
  18089. */
  18090. getEffectDefines(): string;
  18091. /**
  18092. * Returns the string "CylinderDirectedParticleEmitter"
  18093. * @returns a string containing the class name
  18094. */
  18095. getClassName(): string;
  18096. /**
  18097. * Serializes the particle system to a JSON object.
  18098. * @returns the JSON object
  18099. */
  18100. serialize(): any;
  18101. /**
  18102. * Parse properties from a JSON object
  18103. * @param serializationObject defines the JSON object
  18104. */
  18105. parse(serializationObject: any): void;
  18106. }
  18107. }
  18108. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18109. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18110. import { Effect } from "babylonjs/Materials/effect";
  18111. import { Particle } from "babylonjs/Particles/particle";
  18112. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18113. /**
  18114. * Particle emitter emitting particles from the inside of a hemisphere.
  18115. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18116. */
  18117. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18118. /**
  18119. * The radius of the emission hemisphere.
  18120. */
  18121. radius: number;
  18122. /**
  18123. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18124. */
  18125. radiusRange: number;
  18126. /**
  18127. * How much to randomize the particle direction [0-1].
  18128. */
  18129. directionRandomizer: number;
  18130. /**
  18131. * Creates a new instance HemisphericParticleEmitter
  18132. * @param radius the radius of the emission hemisphere (1 by default)
  18133. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18134. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18135. */
  18136. constructor(
  18137. /**
  18138. * The radius of the emission hemisphere.
  18139. */
  18140. radius?: number,
  18141. /**
  18142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18143. */
  18144. radiusRange?: number,
  18145. /**
  18146. * How much to randomize the particle direction [0-1].
  18147. */
  18148. directionRandomizer?: number);
  18149. /**
  18150. * Called by the particle System when the direction is computed for the created particle.
  18151. * @param worldMatrix is the world matrix of the particle system
  18152. * @param directionToUpdate is the direction vector to update with the result
  18153. * @param particle is the particle we are computed the direction for
  18154. */
  18155. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18156. /**
  18157. * Called by the particle System when the position is computed for the created particle.
  18158. * @param worldMatrix is the world matrix of the particle system
  18159. * @param positionToUpdate is the position vector to update with the result
  18160. * @param particle is the particle we are computed the position for
  18161. */
  18162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18163. /**
  18164. * Clones the current emitter and returns a copy of it
  18165. * @returns the new emitter
  18166. */
  18167. clone(): HemisphericParticleEmitter;
  18168. /**
  18169. * Called by the GPUParticleSystem to setup the update shader
  18170. * @param effect defines the update shader
  18171. */
  18172. applyToShader(effect: Effect): void;
  18173. /**
  18174. * Returns a string to use to update the GPU particles update shader
  18175. * @returns a string containng the defines string
  18176. */
  18177. getEffectDefines(): string;
  18178. /**
  18179. * Returns the string "HemisphericParticleEmitter"
  18180. * @returns a string containing the class name
  18181. */
  18182. getClassName(): string;
  18183. /**
  18184. * Serializes the particle system to a JSON object.
  18185. * @returns the JSON object
  18186. */
  18187. serialize(): any;
  18188. /**
  18189. * Parse properties from a JSON object
  18190. * @param serializationObject defines the JSON object
  18191. */
  18192. parse(serializationObject: any): void;
  18193. }
  18194. }
  18195. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18196. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18197. import { Effect } from "babylonjs/Materials/effect";
  18198. import { Particle } from "babylonjs/Particles/particle";
  18199. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18200. /**
  18201. * Particle emitter emitting particles from a point.
  18202. * It emits the particles randomly between 2 given directions.
  18203. */
  18204. export class PointParticleEmitter implements IParticleEmitterType {
  18205. /**
  18206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18207. */
  18208. direction1: Vector3;
  18209. /**
  18210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18211. */
  18212. direction2: Vector3;
  18213. /**
  18214. * Creates a new instance PointParticleEmitter
  18215. */
  18216. constructor();
  18217. /**
  18218. * Called by the particle System when the direction is computed for the created particle.
  18219. * @param worldMatrix is the world matrix of the particle system
  18220. * @param directionToUpdate is the direction vector to update with the result
  18221. * @param particle is the particle we are computed the direction for
  18222. */
  18223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18224. /**
  18225. * Called by the particle System when the position is computed for the created particle.
  18226. * @param worldMatrix is the world matrix of the particle system
  18227. * @param positionToUpdate is the position vector to update with the result
  18228. * @param particle is the particle we are computed the position for
  18229. */
  18230. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18231. /**
  18232. * Clones the current emitter and returns a copy of it
  18233. * @returns the new emitter
  18234. */
  18235. clone(): PointParticleEmitter;
  18236. /**
  18237. * Called by the GPUParticleSystem to setup the update shader
  18238. * @param effect defines the update shader
  18239. */
  18240. applyToShader(effect: Effect): void;
  18241. /**
  18242. * Returns a string to use to update the GPU particles update shader
  18243. * @returns a string containng the defines string
  18244. */
  18245. getEffectDefines(): string;
  18246. /**
  18247. * Returns the string "PointParticleEmitter"
  18248. * @returns a string containing the class name
  18249. */
  18250. getClassName(): string;
  18251. /**
  18252. * Serializes the particle system to a JSON object.
  18253. * @returns the JSON object
  18254. */
  18255. serialize(): any;
  18256. /**
  18257. * Parse properties from a JSON object
  18258. * @param serializationObject defines the JSON object
  18259. */
  18260. parse(serializationObject: any): void;
  18261. }
  18262. }
  18263. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18264. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18265. import { Effect } from "babylonjs/Materials/effect";
  18266. import { Particle } from "babylonjs/Particles/particle";
  18267. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18268. /**
  18269. * Particle emitter emitting particles from the inside of a sphere.
  18270. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18271. */
  18272. export class SphereParticleEmitter implements IParticleEmitterType {
  18273. /**
  18274. * The radius of the emission sphere.
  18275. */
  18276. radius: number;
  18277. /**
  18278. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18279. */
  18280. radiusRange: number;
  18281. /**
  18282. * How much to randomize the particle direction [0-1].
  18283. */
  18284. directionRandomizer: number;
  18285. /**
  18286. * Creates a new instance SphereParticleEmitter
  18287. * @param radius the radius of the emission sphere (1 by default)
  18288. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18289. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18290. */
  18291. constructor(
  18292. /**
  18293. * The radius of the emission sphere.
  18294. */
  18295. radius?: number,
  18296. /**
  18297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18298. */
  18299. radiusRange?: number,
  18300. /**
  18301. * How much to randomize the particle direction [0-1].
  18302. */
  18303. directionRandomizer?: number);
  18304. /**
  18305. * Called by the particle System when the direction is computed for the created particle.
  18306. * @param worldMatrix is the world matrix of the particle system
  18307. * @param directionToUpdate is the direction vector to update with the result
  18308. * @param particle is the particle we are computed the direction for
  18309. */
  18310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18311. /**
  18312. * Called by the particle System when the position is computed for the created particle.
  18313. * @param worldMatrix is the world matrix of the particle system
  18314. * @param positionToUpdate is the position vector to update with the result
  18315. * @param particle is the particle we are computed the position for
  18316. */
  18317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18318. /**
  18319. * Clones the current emitter and returns a copy of it
  18320. * @returns the new emitter
  18321. */
  18322. clone(): SphereParticleEmitter;
  18323. /**
  18324. * Called by the GPUParticleSystem to setup the update shader
  18325. * @param effect defines the update shader
  18326. */
  18327. applyToShader(effect: Effect): void;
  18328. /**
  18329. * Returns a string to use to update the GPU particles update shader
  18330. * @returns a string containng the defines string
  18331. */
  18332. getEffectDefines(): string;
  18333. /**
  18334. * Returns the string "SphereParticleEmitter"
  18335. * @returns a string containing the class name
  18336. */
  18337. getClassName(): string;
  18338. /**
  18339. * Serializes the particle system to a JSON object.
  18340. * @returns the JSON object
  18341. */
  18342. serialize(): any;
  18343. /**
  18344. * Parse properties from a JSON object
  18345. * @param serializationObject defines the JSON object
  18346. */
  18347. parse(serializationObject: any): void;
  18348. }
  18349. /**
  18350. * Particle emitter emitting particles from the inside of a sphere.
  18351. * It emits the particles randomly between two vectors.
  18352. */
  18353. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18354. /**
  18355. * The min limit of the emission direction.
  18356. */
  18357. direction1: Vector3;
  18358. /**
  18359. * The max limit of the emission direction.
  18360. */
  18361. direction2: Vector3;
  18362. /**
  18363. * Creates a new instance SphereDirectedParticleEmitter
  18364. * @param radius the radius of the emission sphere (1 by default)
  18365. * @param direction1 the min limit of the emission direction (up vector by default)
  18366. * @param direction2 the max limit of the emission direction (up vector by default)
  18367. */
  18368. constructor(radius?: number,
  18369. /**
  18370. * The min limit of the emission direction.
  18371. */
  18372. direction1?: Vector3,
  18373. /**
  18374. * The max limit of the emission direction.
  18375. */
  18376. direction2?: Vector3);
  18377. /**
  18378. * Called by the particle System when the direction is computed for the created particle.
  18379. * @param worldMatrix is the world matrix of the particle system
  18380. * @param directionToUpdate is the direction vector to update with the result
  18381. * @param particle is the particle we are computed the direction for
  18382. */
  18383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18384. /**
  18385. * Clones the current emitter and returns a copy of it
  18386. * @returns the new emitter
  18387. */
  18388. clone(): SphereDirectedParticleEmitter;
  18389. /**
  18390. * Called by the GPUParticleSystem to setup the update shader
  18391. * @param effect defines the update shader
  18392. */
  18393. applyToShader(effect: Effect): void;
  18394. /**
  18395. * Returns a string to use to update the GPU particles update shader
  18396. * @returns a string containng the defines string
  18397. */
  18398. getEffectDefines(): string;
  18399. /**
  18400. * Returns the string "SphereDirectedParticleEmitter"
  18401. * @returns a string containing the class name
  18402. */
  18403. getClassName(): string;
  18404. /**
  18405. * Serializes the particle system to a JSON object.
  18406. * @returns the JSON object
  18407. */
  18408. serialize(): any;
  18409. /**
  18410. * Parse properties from a JSON object
  18411. * @param serializationObject defines the JSON object
  18412. */
  18413. parse(serializationObject: any): void;
  18414. }
  18415. }
  18416. declare module "babylonjs/Particles/EmitterTypes/index" {
  18417. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18418. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18419. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18420. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18421. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18422. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18423. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18424. }
  18425. declare module "babylonjs/Particles/IParticleSystem" {
  18426. import { Nullable } from "babylonjs/types";
  18427. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18428. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18431. import { Texture } from "babylonjs/Materials/Textures/texture";
  18432. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18433. import { Scene } from "babylonjs/scene";
  18434. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18435. import { Animation } from "babylonjs/Animations/animation";
  18436. /**
  18437. * Interface representing a particle system in Babylon.js.
  18438. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18439. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18440. */
  18441. export interface IParticleSystem {
  18442. /**
  18443. * List of animations used by the particle system.
  18444. */
  18445. animations: Animation[];
  18446. /**
  18447. * The id of the Particle system.
  18448. */
  18449. id: string;
  18450. /**
  18451. * The name of the Particle system.
  18452. */
  18453. name: string;
  18454. /**
  18455. * The emitter represents the Mesh or position we are attaching the particle system to.
  18456. */
  18457. emitter: Nullable<AbstractMesh | Vector3>;
  18458. /**
  18459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18460. */
  18461. isBillboardBased: boolean;
  18462. /**
  18463. * The rendering group used by the Particle system to chose when to render.
  18464. */
  18465. renderingGroupId: number;
  18466. /**
  18467. * The layer mask we are rendering the particles through.
  18468. */
  18469. layerMask: number;
  18470. /**
  18471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18472. */
  18473. updateSpeed: number;
  18474. /**
  18475. * The amount of time the particle system is running (depends of the overall update speed).
  18476. */
  18477. targetStopDuration: number;
  18478. /**
  18479. * The texture used to render each particle. (this can be a spritesheet)
  18480. */
  18481. particleTexture: Nullable<Texture>;
  18482. /**
  18483. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18484. */
  18485. blendMode: number;
  18486. /**
  18487. * Minimum life time of emitting particles.
  18488. */
  18489. minLifeTime: number;
  18490. /**
  18491. * Maximum life time of emitting particles.
  18492. */
  18493. maxLifeTime: number;
  18494. /**
  18495. * Minimum Size of emitting particles.
  18496. */
  18497. minSize: number;
  18498. /**
  18499. * Maximum Size of emitting particles.
  18500. */
  18501. maxSize: number;
  18502. /**
  18503. * Minimum scale of emitting particles on X axis.
  18504. */
  18505. minScaleX: number;
  18506. /**
  18507. * Maximum scale of emitting particles on X axis.
  18508. */
  18509. maxScaleX: number;
  18510. /**
  18511. * Minimum scale of emitting particles on Y axis.
  18512. */
  18513. minScaleY: number;
  18514. /**
  18515. * Maximum scale of emitting particles on Y axis.
  18516. */
  18517. maxScaleY: number;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color1: Color4;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color2: Color4;
  18526. /**
  18527. * Color the particle will have at the end of its lifetime.
  18528. */
  18529. colorDead: Color4;
  18530. /**
  18531. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18532. */
  18533. emitRate: number;
  18534. /**
  18535. * You can use gravity if you want to give an orientation to your particles.
  18536. */
  18537. gravity: Vector3;
  18538. /**
  18539. * Minimum power of emitting particles.
  18540. */
  18541. minEmitPower: number;
  18542. /**
  18543. * Maximum power of emitting particles.
  18544. */
  18545. maxEmitPower: number;
  18546. /**
  18547. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. minAngularSpeed: number;
  18550. /**
  18551. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. maxAngularSpeed: number;
  18554. /**
  18555. * Gets or sets the minimal initial rotation in radians.
  18556. */
  18557. minInitialRotation: number;
  18558. /**
  18559. * Gets or sets the maximal initial rotation in radians.
  18560. */
  18561. maxInitialRotation: number;
  18562. /**
  18563. * The particle emitter type defines the emitter used by the particle system.
  18564. * It can be for example box, sphere, or cone...
  18565. */
  18566. particleEmitterType: Nullable<IParticleEmitterType>;
  18567. /**
  18568. * Defines the delay in milliseconds before starting the system (0 by default)
  18569. */
  18570. startDelay: number;
  18571. /**
  18572. * 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
  18573. */
  18574. preWarmCycles: number;
  18575. /**
  18576. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18577. */
  18578. preWarmStepOffset: number;
  18579. /**
  18580. * 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)
  18581. */
  18582. spriteCellChangeSpeed: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18585. */
  18586. startSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18589. */
  18590. endSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18593. */
  18594. spriteCellWidth: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18597. */
  18598. spriteCellHeight: number;
  18599. /**
  18600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18601. */
  18602. spriteRandomStartCell: boolean;
  18603. /**
  18604. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18605. */
  18606. isAnimationSheetEnabled: boolean;
  18607. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18608. translationPivot: Vector2;
  18609. /**
  18610. * Gets or sets a texture used to add random noise to particle positions
  18611. */
  18612. noiseTexture: Nullable<BaseTexture>;
  18613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18614. noiseStrength: Vector3;
  18615. /**
  18616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18618. */
  18619. billboardMode: number;
  18620. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18621. limitVelocityDamping: number;
  18622. /**
  18623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18624. */
  18625. beginAnimationOnStart: boolean;
  18626. /**
  18627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationFrom: number;
  18630. /**
  18631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationTo: number;
  18634. /**
  18635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationLoop: boolean;
  18638. /**
  18639. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18640. */
  18641. disposeOnStop: boolean;
  18642. /**
  18643. * Gets the maximum number of particles active at the same time.
  18644. * @returns The max number of active particles.
  18645. */
  18646. getCapacity(): number;
  18647. /**
  18648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18649. * @returns True if it has been started, otherwise false.
  18650. */
  18651. isStarted(): boolean;
  18652. /**
  18653. * Animates the particle system for this frame.
  18654. */
  18655. animate(): void;
  18656. /**
  18657. * Renders the particle system in its current state.
  18658. * @returns the current number of particles
  18659. */
  18660. render(): number;
  18661. /**
  18662. * Dispose the particle system and frees its associated resources.
  18663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18664. */
  18665. dispose(disposeTexture?: boolean): void;
  18666. /**
  18667. * Clones the particle system.
  18668. * @param name The name of the cloned object
  18669. * @param newEmitter The new emitter to use
  18670. * @returns the cloned particle system
  18671. */
  18672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18673. /**
  18674. * Serializes the particle system to a JSON object.
  18675. * @returns the JSON object
  18676. */
  18677. serialize(): any;
  18678. /**
  18679. * Rebuild the particle system
  18680. */
  18681. rebuild(): void;
  18682. /**
  18683. * Starts the particle system and begins to emit
  18684. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18685. */
  18686. start(delay?: number): void;
  18687. /**
  18688. * Stops the particle system.
  18689. */
  18690. stop(): void;
  18691. /**
  18692. * Remove all active particles
  18693. */
  18694. reset(): void;
  18695. /**
  18696. * Is this system ready to be used/rendered
  18697. * @return true if the system is ready
  18698. */
  18699. isReady(): boolean;
  18700. /**
  18701. * Adds a new color gradient
  18702. * @param gradient defines the gradient to use (between 0 and 1)
  18703. * @param color1 defines the color to affect to the specified gradient
  18704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18705. * @returns the current particle system
  18706. */
  18707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18708. /**
  18709. * Remove a specific color gradient
  18710. * @param gradient defines the gradient to remove
  18711. * @returns the current particle system
  18712. */
  18713. removeColorGradient(gradient: number): IParticleSystem;
  18714. /**
  18715. * Adds a new size gradient
  18716. * @param gradient defines the gradient to use (between 0 and 1)
  18717. * @param factor defines the size factor to affect to the specified gradient
  18718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18719. * @returns the current particle system
  18720. */
  18721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18722. /**
  18723. * Remove a specific size gradient
  18724. * @param gradient defines the gradient to remove
  18725. * @returns the current particle system
  18726. */
  18727. removeSizeGradient(gradient: number): IParticleSystem;
  18728. /**
  18729. * Gets the current list of color gradients.
  18730. * You must use addColorGradient and removeColorGradient to udpate this list
  18731. * @returns the list of color gradients
  18732. */
  18733. getColorGradients(): Nullable<Array<ColorGradient>>;
  18734. /**
  18735. * Gets the current list of size gradients.
  18736. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18737. * @returns the list of size gradients
  18738. */
  18739. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18740. /**
  18741. * Gets the current list of angular speed gradients.
  18742. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18743. * @returns the list of angular speed gradients
  18744. */
  18745. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18746. /**
  18747. * Adds a new angular speed gradient
  18748. * @param gradient defines the gradient to use (between 0 and 1)
  18749. * @param factor defines the angular speed to affect to the specified gradient
  18750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18751. * @returns the current particle system
  18752. */
  18753. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18754. /**
  18755. * Remove a specific angular speed gradient
  18756. * @param gradient defines the gradient to remove
  18757. * @returns the current particle system
  18758. */
  18759. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18760. /**
  18761. * Gets the current list of velocity gradients.
  18762. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18763. * @returns the list of velocity gradients
  18764. */
  18765. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18766. /**
  18767. * Adds a new velocity gradient
  18768. * @param gradient defines the gradient to use (between 0 and 1)
  18769. * @param factor defines the velocity to affect to the specified gradient
  18770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18771. * @returns the current particle system
  18772. */
  18773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18774. /**
  18775. * Remove a specific velocity gradient
  18776. * @param gradient defines the gradient to remove
  18777. * @returns the current particle system
  18778. */
  18779. removeVelocityGradient(gradient: number): IParticleSystem;
  18780. /**
  18781. * Gets the current list of limit velocity gradients.
  18782. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18783. * @returns the list of limit velocity gradients
  18784. */
  18785. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18786. /**
  18787. * Adds a new limit velocity gradient
  18788. * @param gradient defines the gradient to use (between 0 and 1)
  18789. * @param factor defines the limit velocity to affect to the specified gradient
  18790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18791. * @returns the current particle system
  18792. */
  18793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18794. /**
  18795. * Remove a specific limit velocity gradient
  18796. * @param gradient defines the gradient to remove
  18797. * @returns the current particle system
  18798. */
  18799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18800. /**
  18801. * Adds a new drag gradient
  18802. * @param gradient defines the gradient to use (between 0 and 1)
  18803. * @param factor defines the drag to affect to the specified gradient
  18804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18805. * @returns the current particle system
  18806. */
  18807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18808. /**
  18809. * Remove a specific drag gradient
  18810. * @param gradient defines the gradient to remove
  18811. * @returns the current particle system
  18812. */
  18813. removeDragGradient(gradient: number): IParticleSystem;
  18814. /**
  18815. * Gets the current list of drag gradients.
  18816. * You must use addDragGradient and removeDragGradient to udpate this list
  18817. * @returns the list of drag gradients
  18818. */
  18819. getDragGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the emit rate to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific emit rate gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeEmitRateGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of emit rate gradients.
  18836. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18837. * @returns the list of emit rate gradients
  18838. */
  18839. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the start size to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific start size gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeStartSizeGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of start size gradients.
  18856. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18857. * @returns the list of start size gradients
  18858. */
  18859. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new life time gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the life time factor to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific life time gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Gets the current list of life time gradients.
  18876. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18877. * @returns the list of life time gradients
  18878. */
  18879. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18880. /**
  18881. * Gets the current list of color gradients.
  18882. * You must use addColorGradient and removeColorGradient to udpate this list
  18883. * @returns the list of color gradients
  18884. */
  18885. getColorGradients(): Nullable<Array<ColorGradient>>;
  18886. /**
  18887. * Adds a new ramp gradient used to remap particle colors
  18888. * @param gradient defines the gradient to use (between 0 and 1)
  18889. * @param color defines the color to affect to the specified gradient
  18890. * @returns the current particle system
  18891. */
  18892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18893. /**
  18894. * Gets the current list of ramp gradients.
  18895. * You must use addRampGradient and removeRampGradient to udpate this list
  18896. * @returns the list of ramp gradients
  18897. */
  18898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18899. /** Gets or sets a boolean indicating that ramp gradients must be used
  18900. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18901. */
  18902. useRampGradients: boolean;
  18903. /**
  18904. * Adds a new color remap gradient
  18905. * @param gradient defines the gradient to use (between 0 and 1)
  18906. * @param min defines the color remap minimal range
  18907. * @param max defines the color remap maximal range
  18908. * @returns the current particle system
  18909. */
  18910. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18911. /**
  18912. * Gets the current list of color remap gradients.
  18913. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18914. * @returns the list of color remap gradients
  18915. */
  18916. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18917. /**
  18918. * Adds a new alpha remap gradient
  18919. * @param gradient defines the gradient to use (between 0 and 1)
  18920. * @param min defines the alpha remap minimal range
  18921. * @param max defines the alpha remap maximal range
  18922. * @returns the current particle system
  18923. */
  18924. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18925. /**
  18926. * Gets the current list of alpha remap gradients.
  18927. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18928. * @returns the list of alpha remap gradients
  18929. */
  18930. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18931. /**
  18932. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18935. * @returns the emitter
  18936. */
  18937. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18938. /**
  18939. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18940. * @param radius The radius of the hemisphere to emit from
  18941. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18942. * @returns the emitter
  18943. */
  18944. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18945. /**
  18946. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18947. * @param radius The radius of the sphere to emit from
  18948. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18949. * @returns the emitter
  18950. */
  18951. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18952. /**
  18953. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18954. * @param radius The radius of the sphere to emit from
  18955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18957. * @returns the emitter
  18958. */
  18959. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18960. /**
  18961. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18962. * @param radius The radius of the emission cylinder
  18963. * @param height The height of the emission cylinder
  18964. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18965. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18966. * @returns the emitter
  18967. */
  18968. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18969. /**
  18970. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18971. * @param radius The radius of the cylinder to emit from
  18972. * @param height The height of the emission cylinder
  18973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18976. * @returns the emitter
  18977. */
  18978. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18979. /**
  18980. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18981. * @param radius The radius of the cone to emit from
  18982. * @param angle The base angle of the cone
  18983. * @returns the emitter
  18984. */
  18985. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18986. /**
  18987. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18990. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18991. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18992. * @returns the emitter
  18993. */
  18994. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18995. /**
  18996. * Get hosting scene
  18997. * @returns the scene
  18998. */
  18999. getScene(): Scene;
  19000. }
  19001. }
  19002. declare module "babylonjs/Meshes/instancedMesh" {
  19003. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19004. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19005. import { Camera } from "babylonjs/Cameras/camera";
  19006. import { Node } from "babylonjs/node";
  19007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19008. import { Mesh } from "babylonjs/Meshes/mesh";
  19009. import { Material } from "babylonjs/Materials/material";
  19010. import { Skeleton } from "babylonjs/Bones/skeleton";
  19011. import { Light } from "babylonjs/Lights/light";
  19012. /**
  19013. * Creates an instance based on a source mesh.
  19014. */
  19015. export class InstancedMesh extends AbstractMesh {
  19016. private _sourceMesh;
  19017. private _currentLOD;
  19018. /** @hidden */
  19019. _indexInSourceMeshInstanceArray: number;
  19020. constructor(name: string, source: Mesh);
  19021. /**
  19022. * Returns the string "InstancedMesh".
  19023. */
  19024. getClassName(): string;
  19025. /** Gets the list of lights affecting that mesh */
  19026. readonly lightSources: Light[];
  19027. _resyncLightSources(): void;
  19028. _resyncLighSource(light: Light): void;
  19029. _removeLightSource(light: Light): void;
  19030. /**
  19031. * If the source mesh receives shadows
  19032. */
  19033. readonly receiveShadows: boolean;
  19034. /**
  19035. * The material of the source mesh
  19036. */
  19037. readonly material: Nullable<Material>;
  19038. /**
  19039. * Visibility of the source mesh
  19040. */
  19041. readonly visibility: number;
  19042. /**
  19043. * Skeleton of the source mesh
  19044. */
  19045. readonly skeleton: Nullable<Skeleton>;
  19046. /**
  19047. * Rendering ground id of the source mesh
  19048. */
  19049. renderingGroupId: number;
  19050. /**
  19051. * Returns the total number of vertices (integer).
  19052. */
  19053. getTotalVertices(): number;
  19054. /**
  19055. * Returns a positive integer : the total number of indices in this mesh geometry.
  19056. * @returns the numner of indices or zero if the mesh has no geometry.
  19057. */
  19058. getTotalIndices(): number;
  19059. /**
  19060. * The source mesh of the instance
  19061. */
  19062. readonly sourceMesh: Mesh;
  19063. /**
  19064. * Is this node ready to be used/rendered
  19065. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19066. * @return {boolean} is it ready
  19067. */
  19068. isReady(completeCheck?: boolean): boolean;
  19069. /**
  19070. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19071. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19072. * @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.
  19073. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19074. */
  19075. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19076. /**
  19077. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19078. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19079. * The `data` are either a numeric array either a Float32Array.
  19080. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19081. * 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).
  19082. * Note that a new underlying VertexBuffer object is created each call.
  19083. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19084. *
  19085. * Possible `kind` values :
  19086. * - VertexBuffer.PositionKind
  19087. * - VertexBuffer.UVKind
  19088. * - VertexBuffer.UV2Kind
  19089. * - VertexBuffer.UV3Kind
  19090. * - VertexBuffer.UV4Kind
  19091. * - VertexBuffer.UV5Kind
  19092. * - VertexBuffer.UV6Kind
  19093. * - VertexBuffer.ColorKind
  19094. * - VertexBuffer.MatricesIndicesKind
  19095. * - VertexBuffer.MatricesIndicesExtraKind
  19096. * - VertexBuffer.MatricesWeightsKind
  19097. * - VertexBuffer.MatricesWeightsExtraKind
  19098. *
  19099. * Returns the Mesh.
  19100. */
  19101. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19102. /**
  19103. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19104. * If the mesh has no geometry, it is simply returned as it is.
  19105. * The `data` are either a numeric array either a Float32Array.
  19106. * No new underlying VertexBuffer object is created.
  19107. * 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.
  19108. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19109. *
  19110. * Possible `kind` values :
  19111. * - VertexBuffer.PositionKind
  19112. * - VertexBuffer.UVKind
  19113. * - VertexBuffer.UV2Kind
  19114. * - VertexBuffer.UV3Kind
  19115. * - VertexBuffer.UV4Kind
  19116. * - VertexBuffer.UV5Kind
  19117. * - VertexBuffer.UV6Kind
  19118. * - VertexBuffer.ColorKind
  19119. * - VertexBuffer.MatricesIndicesKind
  19120. * - VertexBuffer.MatricesIndicesExtraKind
  19121. * - VertexBuffer.MatricesWeightsKind
  19122. * - VertexBuffer.MatricesWeightsExtraKind
  19123. *
  19124. * Returns the Mesh.
  19125. */
  19126. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19127. /**
  19128. * Sets the mesh indices.
  19129. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19130. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19131. * This method creates a new index buffer each call.
  19132. * Returns the Mesh.
  19133. */
  19134. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19135. /**
  19136. * Boolean : True if the mesh owns the requested kind of data.
  19137. */
  19138. isVerticesDataPresent(kind: string): boolean;
  19139. /**
  19140. * Returns an array of indices (IndicesArray).
  19141. */
  19142. getIndices(): Nullable<IndicesArray>;
  19143. readonly _positions: Nullable<Vector3[]>;
  19144. /**
  19145. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19146. * This means the mesh underlying bounding box and sphere are recomputed.
  19147. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19148. * @returns the current mesh
  19149. */
  19150. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19151. /** @hidden */
  19152. _preActivate(): InstancedMesh;
  19153. /** @hidden */
  19154. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19155. /** @hidden */
  19156. _postActivate(): void;
  19157. getWorldMatrix(): Matrix;
  19158. readonly isAnInstance: boolean;
  19159. /**
  19160. * Returns the current associated LOD AbstractMesh.
  19161. */
  19162. getLOD(camera: Camera): AbstractMesh;
  19163. /** @hidden */
  19164. _syncSubMeshes(): InstancedMesh;
  19165. /** @hidden */
  19166. _generatePointsArray(): boolean;
  19167. /**
  19168. * Creates a new InstancedMesh from the current mesh.
  19169. * - name (string) : the cloned mesh name
  19170. * - newParent (optional Node) : the optional Node to parent the clone to.
  19171. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19172. *
  19173. * Returns the clone.
  19174. */
  19175. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19176. /**
  19177. * Disposes the InstancedMesh.
  19178. * Returns nothing.
  19179. */
  19180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19181. }
  19182. }
  19183. declare module "babylonjs/Materials/shaderMaterial" {
  19184. import { Scene } from "babylonjs/scene";
  19185. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19187. import { Mesh } from "babylonjs/Meshes/mesh";
  19188. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19190. import { Texture } from "babylonjs/Materials/Textures/texture";
  19191. import { Material } from "babylonjs/Materials/material";
  19192. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19193. /**
  19194. * Defines the options associated with the creation of a shader material.
  19195. */
  19196. export interface IShaderMaterialOptions {
  19197. /**
  19198. * Does the material work in alpha blend mode
  19199. */
  19200. needAlphaBlending: boolean;
  19201. /**
  19202. * Does the material work in alpha test mode
  19203. */
  19204. needAlphaTesting: boolean;
  19205. /**
  19206. * The list of attribute names used in the shader
  19207. */
  19208. attributes: string[];
  19209. /**
  19210. * The list of unifrom names used in the shader
  19211. */
  19212. uniforms: string[];
  19213. /**
  19214. * The list of UBO names used in the shader
  19215. */
  19216. uniformBuffers: string[];
  19217. /**
  19218. * The list of sampler names used in the shader
  19219. */
  19220. samplers: string[];
  19221. /**
  19222. * The list of defines used in the shader
  19223. */
  19224. defines: string[];
  19225. }
  19226. /**
  19227. * 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.
  19228. *
  19229. * This returned material effects how the mesh will look based on the code in the shaders.
  19230. *
  19231. * @see http://doc.babylonjs.com/how_to/shader_material
  19232. */
  19233. export class ShaderMaterial extends Material {
  19234. private _shaderPath;
  19235. private _options;
  19236. private _textures;
  19237. private _textureArrays;
  19238. private _floats;
  19239. private _ints;
  19240. private _floatsArrays;
  19241. private _colors3;
  19242. private _colors3Arrays;
  19243. private _colors4;
  19244. private _colors4Arrays;
  19245. private _vectors2;
  19246. private _vectors3;
  19247. private _vectors4;
  19248. private _matrices;
  19249. private _matrices3x3;
  19250. private _matrices2x2;
  19251. private _vectors2Arrays;
  19252. private _vectors3Arrays;
  19253. private _vectors4Arrays;
  19254. private _cachedWorldViewMatrix;
  19255. private _cachedWorldViewProjectionMatrix;
  19256. private _renderId;
  19257. /**
  19258. * Instantiate a new shader material.
  19259. * 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.
  19260. * This returned material effects how the mesh will look based on the code in the shaders.
  19261. * @see http://doc.babylonjs.com/how_to/shader_material
  19262. * @param name Define the name of the material in the scene
  19263. * @param scene Define the scene the material belongs to
  19264. * @param shaderPath Defines the route to the shader code in one of three ways:
  19265. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19266. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19267. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19268. * @param options Define the options used to create the shader
  19269. */
  19270. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19271. /**
  19272. * Gets the options used to compile the shader.
  19273. * They can be modified to trigger a new compilation
  19274. */
  19275. readonly options: IShaderMaterialOptions;
  19276. /**
  19277. * Gets the current class name of the material e.g. "ShaderMaterial"
  19278. * Mainly use in serialization.
  19279. * @returns the class name
  19280. */
  19281. getClassName(): string;
  19282. /**
  19283. * Specifies if the material will require alpha blending
  19284. * @returns a boolean specifying if alpha blending is needed
  19285. */
  19286. needAlphaBlending(): boolean;
  19287. /**
  19288. * Specifies if this material should be rendered in alpha test mode
  19289. * @returns a boolean specifying if an alpha test is needed.
  19290. */
  19291. needAlphaTesting(): boolean;
  19292. private _checkUniform;
  19293. /**
  19294. * Set a texture in the shader.
  19295. * @param name Define the name of the uniform samplers as defined in the shader
  19296. * @param texture Define the texture to bind to this sampler
  19297. * @return the material itself allowing "fluent" like uniform updates
  19298. */
  19299. setTexture(name: string, texture: Texture): ShaderMaterial;
  19300. /**
  19301. * Set a texture array in the shader.
  19302. * @param name Define the name of the uniform sampler array as defined in the shader
  19303. * @param textures Define the list of textures to bind to this sampler
  19304. * @return the material itself allowing "fluent" like uniform updates
  19305. */
  19306. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19307. /**
  19308. * Set a float in the shader.
  19309. * @param name Define the name of the uniform as defined in the shader
  19310. * @param value Define the value to give to the uniform
  19311. * @return the material itself allowing "fluent" like uniform updates
  19312. */
  19313. setFloat(name: string, value: number): ShaderMaterial;
  19314. /**
  19315. * Set a int in the shader.
  19316. * @param name Define the name of the uniform as defined in the shader
  19317. * @param value Define the value to give to the uniform
  19318. * @return the material itself allowing "fluent" like uniform updates
  19319. */
  19320. setInt(name: string, value: number): ShaderMaterial;
  19321. /**
  19322. * Set an array of floats in the shader.
  19323. * @param name Define the name of the uniform as defined in the shader
  19324. * @param value Define the value to give to the uniform
  19325. * @return the material itself allowing "fluent" like uniform updates
  19326. */
  19327. setFloats(name: string, value: number[]): ShaderMaterial;
  19328. /**
  19329. * Set a vec3 in the shader from a Color3.
  19330. * @param name Define the name of the uniform as defined in the shader
  19331. * @param value Define the value to give to the uniform
  19332. * @return the material itself allowing "fluent" like uniform updates
  19333. */
  19334. setColor3(name: string, value: Color3): ShaderMaterial;
  19335. /**
  19336. * Set a vec3 array in the shader from a Color3 array.
  19337. * @param name Define the name of the uniform as defined in the shader
  19338. * @param value Define the value to give to the uniform
  19339. * @return the material itself allowing "fluent" like uniform updates
  19340. */
  19341. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19342. /**
  19343. * Set a vec4 in the shader from a Color4.
  19344. * @param name Define the name of the uniform as defined in the shader
  19345. * @param value Define the value to give to the uniform
  19346. * @return the material itself allowing "fluent" like uniform updates
  19347. */
  19348. setColor4(name: string, value: Color4): ShaderMaterial;
  19349. /**
  19350. * Set a vec4 array in the shader from a Color4 array.
  19351. * @param name Define the name of the uniform as defined in the shader
  19352. * @param value Define the value to give to the uniform
  19353. * @return the material itself allowing "fluent" like uniform updates
  19354. */
  19355. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19356. /**
  19357. * Set a vec2 in the shader from a Vector2.
  19358. * @param name Define the name of the uniform as defined in the shader
  19359. * @param value Define the value to give to the uniform
  19360. * @return the material itself allowing "fluent" like uniform updates
  19361. */
  19362. setVector2(name: string, value: Vector2): ShaderMaterial;
  19363. /**
  19364. * Set a vec3 in the shader from a Vector3.
  19365. * @param name Define the name of the uniform as defined in the shader
  19366. * @param value Define the value to give to the uniform
  19367. * @return the material itself allowing "fluent" like uniform updates
  19368. */
  19369. setVector3(name: string, value: Vector3): ShaderMaterial;
  19370. /**
  19371. * Set a vec4 in the shader from a Vector4.
  19372. * @param name Define the name of the uniform as defined in the shader
  19373. * @param value Define the value to give to the uniform
  19374. * @return the material itself allowing "fluent" like uniform updates
  19375. */
  19376. setVector4(name: string, value: Vector4): ShaderMaterial;
  19377. /**
  19378. * Set a mat4 in the shader from a Matrix.
  19379. * @param name Define the name of the uniform as defined in the shader
  19380. * @param value Define the value to give to the uniform
  19381. * @return the material itself allowing "fluent" like uniform updates
  19382. */
  19383. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19384. /**
  19385. * Set a mat3 in the shader from a Float32Array.
  19386. * @param name Define the name of the uniform as defined in the shader
  19387. * @param value Define the value to give to the uniform
  19388. * @return the material itself allowing "fluent" like uniform updates
  19389. */
  19390. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19391. /**
  19392. * Set a mat2 in the shader from a Float32Array.
  19393. * @param name Define the name of the uniform as defined in the shader
  19394. * @param value Define the value to give to the uniform
  19395. * @return the material itself allowing "fluent" like uniform updates
  19396. */
  19397. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19398. /**
  19399. * Set a vec2 array in the shader from a number array.
  19400. * @param name Define the name of the uniform as defined in the shader
  19401. * @param value Define the value to give to the uniform
  19402. * @return the material itself allowing "fluent" like uniform updates
  19403. */
  19404. setArray2(name: string, value: number[]): ShaderMaterial;
  19405. /**
  19406. * Set a vec3 array in the shader from a number array.
  19407. * @param name Define the name of the uniform as defined in the shader
  19408. * @param value Define the value to give to the uniform
  19409. * @return the material itself allowing "fluent" like uniform updates
  19410. */
  19411. setArray3(name: string, value: number[]): ShaderMaterial;
  19412. /**
  19413. * Set a vec4 array in the shader from a number array.
  19414. * @param name Define the name of the uniform as defined in the shader
  19415. * @param value Define the value to give to the uniform
  19416. * @return the material itself allowing "fluent" like uniform updates
  19417. */
  19418. setArray4(name: string, value: number[]): ShaderMaterial;
  19419. private _checkCache;
  19420. /**
  19421. * Specifies that the submesh is ready to be used
  19422. * @param mesh defines the mesh to check
  19423. * @param subMesh defines which submesh to check
  19424. * @param useInstances specifies that instances should be used
  19425. * @returns a boolean indicating that the submesh is ready or not
  19426. */
  19427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19428. /**
  19429. * Checks if the material is ready to render the requested mesh
  19430. * @param mesh Define the mesh to render
  19431. * @param useInstances Define whether or not the material is used with instances
  19432. * @returns true if ready, otherwise false
  19433. */
  19434. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19435. /**
  19436. * Binds the world matrix to the material
  19437. * @param world defines the world transformation matrix
  19438. */
  19439. bindOnlyWorldMatrix(world: Matrix): void;
  19440. /**
  19441. * Binds the material to the mesh
  19442. * @param world defines the world transformation matrix
  19443. * @param mesh defines the mesh to bind the material to
  19444. */
  19445. bind(world: Matrix, mesh?: Mesh): void;
  19446. /**
  19447. * Gets the active textures from the material
  19448. * @returns an array of textures
  19449. */
  19450. getActiveTextures(): BaseTexture[];
  19451. /**
  19452. * Specifies if the material uses a texture
  19453. * @param texture defines the texture to check against the material
  19454. * @returns a boolean specifying if the material uses the texture
  19455. */
  19456. hasTexture(texture: BaseTexture): boolean;
  19457. /**
  19458. * Makes a duplicate of the material, and gives it a new name
  19459. * @param name defines the new name for the duplicated material
  19460. * @returns the cloned material
  19461. */
  19462. clone(name: string): ShaderMaterial;
  19463. /**
  19464. * Disposes the material
  19465. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19466. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19467. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19468. */
  19469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19470. /**
  19471. * Serializes this material in a JSON representation
  19472. * @returns the serialized material object
  19473. */
  19474. serialize(): any;
  19475. /**
  19476. * Creates a shader material from parsed shader material data
  19477. * @param source defines the JSON represnetation of the material
  19478. * @param scene defines the hosting scene
  19479. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19480. * @returns a new material
  19481. */
  19482. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19483. }
  19484. }
  19485. declare module "babylonjs/Shaders/color.fragment" {
  19486. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19487. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19488. /** @hidden */
  19489. export var colorPixelShader: {
  19490. name: string;
  19491. shader: string;
  19492. };
  19493. }
  19494. declare module "babylonjs/Shaders/color.vertex" {
  19495. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19498. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19499. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19500. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19501. /** @hidden */
  19502. export var colorVertexShader: {
  19503. name: string;
  19504. shader: string;
  19505. };
  19506. }
  19507. declare module "babylonjs/Meshes/linesMesh" {
  19508. import { Nullable } from "babylonjs/types";
  19509. import { Scene } from "babylonjs/scene";
  19510. import { Color3 } from "babylonjs/Maths/math.color";
  19511. import { Node } from "babylonjs/node";
  19512. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19513. import { Mesh } from "babylonjs/Meshes/mesh";
  19514. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19515. import { Effect } from "babylonjs/Materials/effect";
  19516. import { Material } from "babylonjs/Materials/material";
  19517. import "babylonjs/Shaders/color.fragment";
  19518. import "babylonjs/Shaders/color.vertex";
  19519. /**
  19520. * Line mesh
  19521. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19522. */
  19523. export class LinesMesh extends Mesh {
  19524. /**
  19525. * If vertex color should be applied to the mesh
  19526. */
  19527. readonly useVertexColor?: boolean | undefined;
  19528. /**
  19529. * If vertex alpha should be applied to the mesh
  19530. */
  19531. readonly useVertexAlpha?: boolean | undefined;
  19532. /**
  19533. * Color of the line (Default: White)
  19534. */
  19535. color: Color3;
  19536. /**
  19537. * Alpha of the line (Default: 1)
  19538. */
  19539. alpha: number;
  19540. /**
  19541. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19542. * This margin is expressed in world space coordinates, so its value may vary.
  19543. * Default value is 0.1
  19544. */
  19545. intersectionThreshold: number;
  19546. private _colorShader;
  19547. private color4;
  19548. /**
  19549. * Creates a new LinesMesh
  19550. * @param name defines the name
  19551. * @param scene defines the hosting scene
  19552. * @param parent defines the parent mesh if any
  19553. * @param source defines the optional source LinesMesh used to clone data from
  19554. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19555. * When false, achieved by calling a clone(), also passing False.
  19556. * This will make creation of children, recursive.
  19557. * @param useVertexColor defines if this LinesMesh supports vertex color
  19558. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19559. */
  19560. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19561. /**
  19562. * If vertex color should be applied to the mesh
  19563. */
  19564. useVertexColor?: boolean | undefined,
  19565. /**
  19566. * If vertex alpha should be applied to the mesh
  19567. */
  19568. useVertexAlpha?: boolean | undefined);
  19569. private _addClipPlaneDefine;
  19570. private _removeClipPlaneDefine;
  19571. isReady(): boolean;
  19572. /**
  19573. * Returns the string "LineMesh"
  19574. */
  19575. getClassName(): string;
  19576. /**
  19577. * @hidden
  19578. */
  19579. /**
  19580. * @hidden
  19581. */
  19582. material: Material;
  19583. /**
  19584. * @hidden
  19585. */
  19586. readonly checkCollisions: boolean;
  19587. /** @hidden */
  19588. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19589. /** @hidden */
  19590. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19591. /**
  19592. * Disposes of the line mesh
  19593. * @param doNotRecurse If children should be disposed
  19594. */
  19595. dispose(doNotRecurse?: boolean): void;
  19596. /**
  19597. * Returns a new LineMesh object cloned from the current one.
  19598. */
  19599. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19600. /**
  19601. * Creates a new InstancedLinesMesh object from the mesh model.
  19602. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19603. * @param name defines the name of the new instance
  19604. * @returns a new InstancedLinesMesh
  19605. */
  19606. createInstance(name: string): InstancedLinesMesh;
  19607. }
  19608. /**
  19609. * Creates an instance based on a source LinesMesh
  19610. */
  19611. export class InstancedLinesMesh extends InstancedMesh {
  19612. /**
  19613. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19614. * This margin is expressed in world space coordinates, so its value may vary.
  19615. * Initilized with the intersectionThreshold value of the source LinesMesh
  19616. */
  19617. intersectionThreshold: number;
  19618. constructor(name: string, source: LinesMesh);
  19619. /**
  19620. * Returns the string "InstancedLinesMesh".
  19621. */
  19622. getClassName(): string;
  19623. }
  19624. }
  19625. declare module "babylonjs/Shaders/line.fragment" {
  19626. /** @hidden */
  19627. export var linePixelShader: {
  19628. name: string;
  19629. shader: string;
  19630. };
  19631. }
  19632. declare module "babylonjs/Shaders/line.vertex" {
  19633. /** @hidden */
  19634. export var lineVertexShader: {
  19635. name: string;
  19636. shader: string;
  19637. };
  19638. }
  19639. declare module "babylonjs/Rendering/edgesRenderer" {
  19640. import { Nullable } from "babylonjs/types";
  19641. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19643. import { Vector3 } from "babylonjs/Maths/math.vector";
  19644. import { IDisposable } from "babylonjs/scene";
  19645. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19646. import "babylonjs/Shaders/line.fragment";
  19647. import "babylonjs/Shaders/line.vertex";
  19648. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19649. module "babylonjs/Meshes/abstractMesh" {
  19650. interface AbstractMesh {
  19651. /**
  19652. * Gets the edgesRenderer associated with the mesh
  19653. */
  19654. edgesRenderer: Nullable<EdgesRenderer>;
  19655. }
  19656. }
  19657. module "babylonjs/Meshes/linesMesh" {
  19658. interface LinesMesh {
  19659. /**
  19660. * Enables the edge rendering mode on the mesh.
  19661. * This mode makes the mesh edges visible
  19662. * @param epsilon defines the maximal distance between two angles to detect a face
  19663. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19664. * @returns the currentAbstractMesh
  19665. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19666. */
  19667. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19668. }
  19669. }
  19670. module "babylonjs/Meshes/linesMesh" {
  19671. interface InstancedLinesMesh {
  19672. /**
  19673. * Enables the edge rendering mode on the mesh.
  19674. * This mode makes the mesh edges visible
  19675. * @param epsilon defines the maximal distance between two angles to detect a face
  19676. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19677. * @returns the current InstancedLinesMesh
  19678. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19679. */
  19680. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19681. }
  19682. }
  19683. /**
  19684. * Defines the minimum contract an Edges renderer should follow.
  19685. */
  19686. export interface IEdgesRenderer extends IDisposable {
  19687. /**
  19688. * Gets or sets a boolean indicating if the edgesRenderer is active
  19689. */
  19690. isEnabled: boolean;
  19691. /**
  19692. * Renders the edges of the attached mesh,
  19693. */
  19694. render(): void;
  19695. /**
  19696. * Checks wether or not the edges renderer is ready to render.
  19697. * @return true if ready, otherwise false.
  19698. */
  19699. isReady(): boolean;
  19700. }
  19701. /**
  19702. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19703. */
  19704. export class EdgesRenderer implements IEdgesRenderer {
  19705. /**
  19706. * Define the size of the edges with an orthographic camera
  19707. */
  19708. edgesWidthScalerForOrthographic: number;
  19709. /**
  19710. * Define the size of the edges with a perspective camera
  19711. */
  19712. edgesWidthScalerForPerspective: number;
  19713. protected _source: AbstractMesh;
  19714. protected _linesPositions: number[];
  19715. protected _linesNormals: number[];
  19716. protected _linesIndices: number[];
  19717. protected _epsilon: number;
  19718. protected _indicesCount: number;
  19719. protected _lineShader: ShaderMaterial;
  19720. protected _ib: DataBuffer;
  19721. protected _buffers: {
  19722. [key: string]: Nullable<VertexBuffer>;
  19723. };
  19724. protected _checkVerticesInsteadOfIndices: boolean;
  19725. private _meshRebuildObserver;
  19726. private _meshDisposeObserver;
  19727. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19728. isEnabled: boolean;
  19729. /**
  19730. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19731. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19732. * @param source Mesh used to create edges
  19733. * @param epsilon sum of angles in adjacency to check for edge
  19734. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19735. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19736. */
  19737. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19738. protected _prepareRessources(): void;
  19739. /** @hidden */
  19740. _rebuild(): void;
  19741. /**
  19742. * Releases the required resources for the edges renderer
  19743. */
  19744. dispose(): void;
  19745. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19746. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19747. /**
  19748. * Checks if the pair of p0 and p1 is en edge
  19749. * @param faceIndex
  19750. * @param edge
  19751. * @param faceNormals
  19752. * @param p0
  19753. * @param p1
  19754. * @private
  19755. */
  19756. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19757. /**
  19758. * push line into the position, normal and index buffer
  19759. * @protected
  19760. */
  19761. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19762. /**
  19763. * Generates lines edges from adjacencjes
  19764. * @private
  19765. */
  19766. _generateEdgesLines(): void;
  19767. /**
  19768. * Checks wether or not the edges renderer is ready to render.
  19769. * @return true if ready, otherwise false.
  19770. */
  19771. isReady(): boolean;
  19772. /**
  19773. * Renders the edges of the attached mesh,
  19774. */
  19775. render(): void;
  19776. }
  19777. /**
  19778. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19779. */
  19780. export class LineEdgesRenderer extends EdgesRenderer {
  19781. /**
  19782. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19783. * @param source LineMesh used to generate edges
  19784. * @param epsilon not important (specified angle for edge detection)
  19785. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19786. */
  19787. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19788. /**
  19789. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19790. */
  19791. _generateEdgesLines(): void;
  19792. }
  19793. }
  19794. declare module "babylonjs/Rendering/renderingGroup" {
  19795. import { SmartArray } from "babylonjs/Misc/smartArray";
  19796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19798. import { Nullable } from "babylonjs/types";
  19799. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19800. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19801. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19802. import { Material } from "babylonjs/Materials/material";
  19803. import { Scene } from "babylonjs/scene";
  19804. /**
  19805. * This represents the object necessary to create a rendering group.
  19806. * This is exclusively used and created by the rendering manager.
  19807. * To modify the behavior, you use the available helpers in your scene or meshes.
  19808. * @hidden
  19809. */
  19810. export class RenderingGroup {
  19811. index: number;
  19812. private static _zeroVector;
  19813. private _scene;
  19814. private _opaqueSubMeshes;
  19815. private _transparentSubMeshes;
  19816. private _alphaTestSubMeshes;
  19817. private _depthOnlySubMeshes;
  19818. private _particleSystems;
  19819. private _spriteManagers;
  19820. private _opaqueSortCompareFn;
  19821. private _alphaTestSortCompareFn;
  19822. private _transparentSortCompareFn;
  19823. private _renderOpaque;
  19824. private _renderAlphaTest;
  19825. private _renderTransparent;
  19826. /** @hidden */
  19827. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19828. onBeforeTransparentRendering: () => void;
  19829. /**
  19830. * Set the opaque sort comparison function.
  19831. * If null the sub meshes will be render in the order they were created
  19832. */
  19833. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19834. /**
  19835. * Set the alpha test sort comparison function.
  19836. * If null the sub meshes will be render in the order they were created
  19837. */
  19838. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19839. /**
  19840. * Set the transparent sort comparison function.
  19841. * If null the sub meshes will be render in the order they were created
  19842. */
  19843. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19844. /**
  19845. * Creates a new rendering group.
  19846. * @param index The rendering group index
  19847. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19848. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19849. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19850. */
  19851. 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>);
  19852. /**
  19853. * Render all the sub meshes contained in the group.
  19854. * @param customRenderFunction Used to override the default render behaviour of the group.
  19855. * @returns true if rendered some submeshes.
  19856. */
  19857. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19858. /**
  19859. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19860. * @param subMeshes The submeshes to render
  19861. */
  19862. private renderOpaqueSorted;
  19863. /**
  19864. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19865. * @param subMeshes The submeshes to render
  19866. */
  19867. private renderAlphaTestSorted;
  19868. /**
  19869. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19870. * @param subMeshes The submeshes to render
  19871. */
  19872. private renderTransparentSorted;
  19873. /**
  19874. * Renders the submeshes in a specified order.
  19875. * @param subMeshes The submeshes to sort before render
  19876. * @param sortCompareFn The comparison function use to sort
  19877. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19878. * @param transparent Specifies to activate blending if true
  19879. */
  19880. private static renderSorted;
  19881. /**
  19882. * Renders the submeshes in the order they were dispatched (no sort applied).
  19883. * @param subMeshes The submeshes to render
  19884. */
  19885. private static renderUnsorted;
  19886. /**
  19887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19888. * are rendered back to front if in the same alpha index.
  19889. *
  19890. * @param a The first submesh
  19891. * @param b The second submesh
  19892. * @returns The result of the comparison
  19893. */
  19894. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19895. /**
  19896. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19897. * are rendered back to front.
  19898. *
  19899. * @param a The first submesh
  19900. * @param b The second submesh
  19901. * @returns The result of the comparison
  19902. */
  19903. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19904. /**
  19905. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19906. * are rendered front to back (prevent overdraw).
  19907. *
  19908. * @param a The first submesh
  19909. * @param b The second submesh
  19910. * @returns The result of the comparison
  19911. */
  19912. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19913. /**
  19914. * Resets the different lists of submeshes to prepare a new frame.
  19915. */
  19916. prepare(): void;
  19917. dispose(): void;
  19918. /**
  19919. * Inserts the submesh in its correct queue depending on its material.
  19920. * @param subMesh The submesh to dispatch
  19921. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19922. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19923. */
  19924. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19925. dispatchSprites(spriteManager: ISpriteManager): void;
  19926. dispatchParticles(particleSystem: IParticleSystem): void;
  19927. private _renderParticles;
  19928. private _renderSprites;
  19929. }
  19930. }
  19931. declare module "babylonjs/Rendering/renderingManager" {
  19932. import { Nullable } from "babylonjs/types";
  19933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19934. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19935. import { SmartArray } from "babylonjs/Misc/smartArray";
  19936. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19937. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19938. import { Material } from "babylonjs/Materials/material";
  19939. import { Scene } from "babylonjs/scene";
  19940. import { Camera } from "babylonjs/Cameras/camera";
  19941. /**
  19942. * Interface describing the different options available in the rendering manager
  19943. * regarding Auto Clear between groups.
  19944. */
  19945. export interface IRenderingManagerAutoClearSetup {
  19946. /**
  19947. * Defines whether or not autoclear is enable.
  19948. */
  19949. autoClear: boolean;
  19950. /**
  19951. * Defines whether or not to autoclear the depth buffer.
  19952. */
  19953. depth: boolean;
  19954. /**
  19955. * Defines whether or not to autoclear the stencil buffer.
  19956. */
  19957. stencil: boolean;
  19958. }
  19959. /**
  19960. * This class is used by the onRenderingGroupObservable
  19961. */
  19962. export class RenderingGroupInfo {
  19963. /**
  19964. * The Scene that being rendered
  19965. */
  19966. scene: Scene;
  19967. /**
  19968. * The camera currently used for the rendering pass
  19969. */
  19970. camera: Nullable<Camera>;
  19971. /**
  19972. * The ID of the renderingGroup being processed
  19973. */
  19974. renderingGroupId: number;
  19975. }
  19976. /**
  19977. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19978. * It is enable to manage the different groups as well as the different necessary sort functions.
  19979. * This should not be used directly aside of the few static configurations
  19980. */
  19981. export class RenderingManager {
  19982. /**
  19983. * The max id used for rendering groups (not included)
  19984. */
  19985. static MAX_RENDERINGGROUPS: number;
  19986. /**
  19987. * The min id used for rendering groups (included)
  19988. */
  19989. static MIN_RENDERINGGROUPS: number;
  19990. /**
  19991. * Used to globally prevent autoclearing scenes.
  19992. */
  19993. static AUTOCLEAR: boolean;
  19994. /**
  19995. * @hidden
  19996. */
  19997. _useSceneAutoClearSetup: boolean;
  19998. private _scene;
  19999. private _renderingGroups;
  20000. private _depthStencilBufferAlreadyCleaned;
  20001. private _autoClearDepthStencil;
  20002. private _customOpaqueSortCompareFn;
  20003. private _customAlphaTestSortCompareFn;
  20004. private _customTransparentSortCompareFn;
  20005. private _renderingGroupInfo;
  20006. /**
  20007. * Instantiates a new rendering group for a particular scene
  20008. * @param scene Defines the scene the groups belongs to
  20009. */
  20010. constructor(scene: Scene);
  20011. private _clearDepthStencilBuffer;
  20012. /**
  20013. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20014. * @hidden
  20015. */
  20016. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20017. /**
  20018. * Resets the different information of the group to prepare a new frame
  20019. * @hidden
  20020. */
  20021. reset(): void;
  20022. /**
  20023. * Dispose and release the group and its associated resources.
  20024. * @hidden
  20025. */
  20026. dispose(): void;
  20027. /**
  20028. * Clear the info related to rendering groups preventing retention points during dispose.
  20029. */
  20030. freeRenderingGroups(): void;
  20031. private _prepareRenderingGroup;
  20032. /**
  20033. * Add a sprite manager to the rendering manager in order to render it this frame.
  20034. * @param spriteManager Define the sprite manager to render
  20035. */
  20036. dispatchSprites(spriteManager: ISpriteManager): void;
  20037. /**
  20038. * Add a particle system to the rendering manager in order to render it this frame.
  20039. * @param particleSystem Define the particle system to render
  20040. */
  20041. dispatchParticles(particleSystem: IParticleSystem): void;
  20042. /**
  20043. * Add a submesh to the manager in order to render it this frame
  20044. * @param subMesh The submesh to dispatch
  20045. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20046. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20047. */
  20048. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20049. /**
  20050. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20051. * This allowed control for front to back rendering or reversly depending of the special needs.
  20052. *
  20053. * @param renderingGroupId The rendering group id corresponding to its index
  20054. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20055. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20056. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20057. */
  20058. 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;
  20059. /**
  20060. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20061. *
  20062. * @param renderingGroupId The rendering group id corresponding to its index
  20063. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20064. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20065. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20066. */
  20067. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20068. /**
  20069. * Gets the current auto clear configuration for one rendering group of the rendering
  20070. * manager.
  20071. * @param index the rendering group index to get the information for
  20072. * @returns The auto clear setup for the requested rendering group
  20073. */
  20074. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20075. }
  20076. }
  20077. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20078. import { Observable } from "babylonjs/Misc/observable";
  20079. import { SmartArray } from "babylonjs/Misc/smartArray";
  20080. import { Nullable } from "babylonjs/types";
  20081. import { Camera } from "babylonjs/Cameras/camera";
  20082. import { Scene } from "babylonjs/scene";
  20083. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20084. import { Color4 } from "babylonjs/Maths/math.color";
  20085. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20088. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20089. import { Texture } from "babylonjs/Materials/Textures/texture";
  20090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20091. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20092. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20093. import { Engine } from "babylonjs/Engines/engine";
  20094. /**
  20095. * This Helps creating a texture that will be created from a camera in your scene.
  20096. * It is basically a dynamic texture that could be used to create special effects for instance.
  20097. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20098. */
  20099. export class RenderTargetTexture extends Texture {
  20100. isCube: boolean;
  20101. /**
  20102. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20103. */
  20104. static readonly REFRESHRATE_RENDER_ONCE: number;
  20105. /**
  20106. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20107. */
  20108. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20109. /**
  20110. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20111. * the central point of your effect and can save a lot of performances.
  20112. */
  20113. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20114. /**
  20115. * Use this predicate to dynamically define the list of mesh you want to render.
  20116. * If set, the renderList property will be overwritten.
  20117. */
  20118. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20119. private _renderList;
  20120. /**
  20121. * Use this list to define the list of mesh you want to render.
  20122. */
  20123. renderList: Nullable<Array<AbstractMesh>>;
  20124. private _hookArray;
  20125. /**
  20126. * Define if particles should be rendered in your texture.
  20127. */
  20128. renderParticles: boolean;
  20129. /**
  20130. * Define if sprites should be rendered in your texture.
  20131. */
  20132. renderSprites: boolean;
  20133. /**
  20134. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20135. */
  20136. coordinatesMode: number;
  20137. /**
  20138. * Define the camera used to render the texture.
  20139. */
  20140. activeCamera: Nullable<Camera>;
  20141. /**
  20142. * Override the render function of the texture with your own one.
  20143. */
  20144. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20145. /**
  20146. * Define if camera post processes should be use while rendering the texture.
  20147. */
  20148. useCameraPostProcesses: boolean;
  20149. /**
  20150. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20151. */
  20152. ignoreCameraViewport: boolean;
  20153. private _postProcessManager;
  20154. private _postProcesses;
  20155. private _resizeObserver;
  20156. /**
  20157. * An event triggered when the texture is unbind.
  20158. */
  20159. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20160. /**
  20161. * An event triggered when the texture is unbind.
  20162. */
  20163. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20164. private _onAfterUnbindObserver;
  20165. /**
  20166. * Set a after unbind callback in the texture.
  20167. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20168. */
  20169. onAfterUnbind: () => void;
  20170. /**
  20171. * An event triggered before rendering the texture
  20172. */
  20173. onBeforeRenderObservable: Observable<number>;
  20174. private _onBeforeRenderObserver;
  20175. /**
  20176. * Set a before render callback in the texture.
  20177. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20178. */
  20179. onBeforeRender: (faceIndex: number) => void;
  20180. /**
  20181. * An event triggered after rendering the texture
  20182. */
  20183. onAfterRenderObservable: Observable<number>;
  20184. private _onAfterRenderObserver;
  20185. /**
  20186. * Set a after render callback in the texture.
  20187. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20188. */
  20189. onAfterRender: (faceIndex: number) => void;
  20190. /**
  20191. * An event triggered after the texture clear
  20192. */
  20193. onClearObservable: Observable<Engine>;
  20194. private _onClearObserver;
  20195. /**
  20196. * Set a clear callback in the texture.
  20197. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20198. */
  20199. onClear: (Engine: Engine) => void;
  20200. /**
  20201. * An event triggered when the texture is resized.
  20202. */
  20203. onResizeObservable: Observable<RenderTargetTexture>;
  20204. /**
  20205. * Define the clear color of the Render Target if it should be different from the scene.
  20206. */
  20207. clearColor: Color4;
  20208. protected _size: number | {
  20209. width: number;
  20210. height: number;
  20211. };
  20212. protected _initialSizeParameter: number | {
  20213. width: number;
  20214. height: number;
  20215. } | {
  20216. ratio: number;
  20217. };
  20218. protected _sizeRatio: Nullable<number>;
  20219. /** @hidden */
  20220. _generateMipMaps: boolean;
  20221. protected _renderingManager: RenderingManager;
  20222. /** @hidden */
  20223. _waitingRenderList: string[];
  20224. protected _doNotChangeAspectRatio: boolean;
  20225. protected _currentRefreshId: number;
  20226. protected _refreshRate: number;
  20227. protected _textureMatrix: Matrix;
  20228. protected _samples: number;
  20229. protected _renderTargetOptions: RenderTargetCreationOptions;
  20230. /**
  20231. * Gets render target creation options that were used.
  20232. */
  20233. readonly renderTargetOptions: RenderTargetCreationOptions;
  20234. protected _engine: Engine;
  20235. protected _onRatioRescale(): void;
  20236. /**
  20237. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20238. * It must define where the camera used to render the texture is set
  20239. */
  20240. boundingBoxPosition: Vector3;
  20241. private _boundingBoxSize;
  20242. /**
  20243. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20244. * When defined, the cubemap will switch to local mode
  20245. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20246. * @example https://www.babylonjs-playground.com/#RNASML
  20247. */
  20248. boundingBoxSize: Vector3;
  20249. /**
  20250. * In case the RTT has been created with a depth texture, get the associated
  20251. * depth texture.
  20252. * Otherwise, return null.
  20253. */
  20254. depthStencilTexture: Nullable<InternalTexture>;
  20255. /**
  20256. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20257. * or used a shadow, depth texture...
  20258. * @param name The friendly name of the texture
  20259. * @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)
  20260. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20261. * @param generateMipMaps True if mip maps need to be generated after render.
  20262. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20263. * @param type The type of the buffer in the RTT (int, half float, float...)
  20264. * @param isCube True if a cube texture needs to be created
  20265. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20266. * @param generateDepthBuffer True to generate a depth buffer
  20267. * @param generateStencilBuffer True to generate a stencil buffer
  20268. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20269. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20270. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20271. */
  20272. constructor(name: string, size: number | {
  20273. width: number;
  20274. height: number;
  20275. } | {
  20276. ratio: number;
  20277. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20278. /**
  20279. * Creates a depth stencil texture.
  20280. * This is only available in WebGL 2 or with the depth texture extension available.
  20281. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20282. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20283. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20284. */
  20285. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20286. private _processSizeParameter;
  20287. /**
  20288. * Define the number of samples to use in case of MSAA.
  20289. * It defaults to one meaning no MSAA has been enabled.
  20290. */
  20291. samples: number;
  20292. /**
  20293. * Resets the refresh counter of the texture and start bak from scratch.
  20294. * Could be useful to regenerate the texture if it is setup to render only once.
  20295. */
  20296. resetRefreshCounter(): void;
  20297. /**
  20298. * Define the refresh rate of the texture or the rendering frequency.
  20299. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20300. */
  20301. refreshRate: number;
  20302. /**
  20303. * Adds a post process to the render target rendering passes.
  20304. * @param postProcess define the post process to add
  20305. */
  20306. addPostProcess(postProcess: PostProcess): void;
  20307. /**
  20308. * Clear all the post processes attached to the render target
  20309. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20310. */
  20311. clearPostProcesses(dispose?: boolean): void;
  20312. /**
  20313. * Remove one of the post process from the list of attached post processes to the texture
  20314. * @param postProcess define the post process to remove from the list
  20315. */
  20316. removePostProcess(postProcess: PostProcess): void;
  20317. /** @hidden */
  20318. _shouldRender(): boolean;
  20319. /**
  20320. * Gets the actual render size of the texture.
  20321. * @returns the width of the render size
  20322. */
  20323. getRenderSize(): number;
  20324. /**
  20325. * Gets the actual render width of the texture.
  20326. * @returns the width of the render size
  20327. */
  20328. getRenderWidth(): number;
  20329. /**
  20330. * Gets the actual render height of the texture.
  20331. * @returns the height of the render size
  20332. */
  20333. getRenderHeight(): number;
  20334. /**
  20335. * Get if the texture can be rescaled or not.
  20336. */
  20337. readonly canRescale: boolean;
  20338. /**
  20339. * Resize the texture using a ratio.
  20340. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20341. */
  20342. scale(ratio: number): void;
  20343. /**
  20344. * Get the texture reflection matrix used to rotate/transform the reflection.
  20345. * @returns the reflection matrix
  20346. */
  20347. getReflectionTextureMatrix(): Matrix;
  20348. /**
  20349. * Resize the texture to a new desired size.
  20350. * Be carrefull as it will recreate all the data in the new texture.
  20351. * @param size Define the new size. It can be:
  20352. * - a number for squared texture,
  20353. * - an object containing { width: number, height: number }
  20354. * - or an object containing a ratio { ratio: number }
  20355. */
  20356. resize(size: number | {
  20357. width: number;
  20358. height: number;
  20359. } | {
  20360. ratio: number;
  20361. }): void;
  20362. /**
  20363. * Renders all the objects from the render list into the texture.
  20364. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20365. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20366. */
  20367. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20368. private _bestReflectionRenderTargetDimension;
  20369. /**
  20370. * @hidden
  20371. * @param faceIndex face index to bind to if this is a cubetexture
  20372. */
  20373. _bindFrameBuffer(faceIndex?: number): void;
  20374. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20375. private renderToTarget;
  20376. /**
  20377. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20378. * This allowed control for front to back rendering or reversly depending of the special needs.
  20379. *
  20380. * @param renderingGroupId The rendering group id corresponding to its index
  20381. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20382. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20383. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20384. */
  20385. 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;
  20386. /**
  20387. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20388. *
  20389. * @param renderingGroupId The rendering group id corresponding to its index
  20390. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20391. */
  20392. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20393. /**
  20394. * Clones the texture.
  20395. * @returns the cloned texture
  20396. */
  20397. clone(): RenderTargetTexture;
  20398. /**
  20399. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20400. * @returns The JSON representation of the texture
  20401. */
  20402. serialize(): any;
  20403. /**
  20404. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20405. */
  20406. disposeFramebufferObjects(): void;
  20407. /**
  20408. * Dispose the texture and release its associated resources.
  20409. */
  20410. dispose(): void;
  20411. /** @hidden */
  20412. _rebuild(): void;
  20413. /**
  20414. * Clear the info related to rendering groups preventing retention point in material dispose.
  20415. */
  20416. freeRenderingGroups(): void;
  20417. /**
  20418. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20419. * @returns the view count
  20420. */
  20421. getViewCount(): number;
  20422. }
  20423. }
  20424. declare module "babylonjs/Materials/material" {
  20425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20426. import { SmartArray } from "babylonjs/Misc/smartArray";
  20427. import { Observable } from "babylonjs/Misc/observable";
  20428. import { Nullable } from "babylonjs/types";
  20429. import { Scene } from "babylonjs/scene";
  20430. import { Matrix } from "babylonjs/Maths/math.vector";
  20431. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20433. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20434. import { Effect } from "babylonjs/Materials/effect";
  20435. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20437. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20438. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20439. import { Mesh } from "babylonjs/Meshes/mesh";
  20440. import { Animation } from "babylonjs/Animations/animation";
  20441. /**
  20442. * Base class for the main features of a material in Babylon.js
  20443. */
  20444. export class Material implements IAnimatable {
  20445. /**
  20446. * Returns the triangle fill mode
  20447. */
  20448. static readonly TriangleFillMode: number;
  20449. /**
  20450. * Returns the wireframe mode
  20451. */
  20452. static readonly WireFrameFillMode: number;
  20453. /**
  20454. * Returns the point fill mode
  20455. */
  20456. static readonly PointFillMode: number;
  20457. /**
  20458. * Returns the point list draw mode
  20459. */
  20460. static readonly PointListDrawMode: number;
  20461. /**
  20462. * Returns the line list draw mode
  20463. */
  20464. static readonly LineListDrawMode: number;
  20465. /**
  20466. * Returns the line loop draw mode
  20467. */
  20468. static readonly LineLoopDrawMode: number;
  20469. /**
  20470. * Returns the line strip draw mode
  20471. */
  20472. static readonly LineStripDrawMode: number;
  20473. /**
  20474. * Returns the triangle strip draw mode
  20475. */
  20476. static readonly TriangleStripDrawMode: number;
  20477. /**
  20478. * Returns the triangle fan draw mode
  20479. */
  20480. static readonly TriangleFanDrawMode: number;
  20481. /**
  20482. * Stores the clock-wise side orientation
  20483. */
  20484. static readonly ClockWiseSideOrientation: number;
  20485. /**
  20486. * Stores the counter clock-wise side orientation
  20487. */
  20488. static readonly CounterClockWiseSideOrientation: number;
  20489. /**
  20490. * The dirty texture flag value
  20491. */
  20492. static readonly TextureDirtyFlag: number;
  20493. /**
  20494. * The dirty light flag value
  20495. */
  20496. static readonly LightDirtyFlag: number;
  20497. /**
  20498. * The dirty fresnel flag value
  20499. */
  20500. static readonly FresnelDirtyFlag: number;
  20501. /**
  20502. * The dirty attribute flag value
  20503. */
  20504. static readonly AttributesDirtyFlag: number;
  20505. /**
  20506. * The dirty misc flag value
  20507. */
  20508. static readonly MiscDirtyFlag: number;
  20509. /**
  20510. * The all dirty flag value
  20511. */
  20512. static readonly AllDirtyFlag: number;
  20513. /**
  20514. * The ID of the material
  20515. */
  20516. id: string;
  20517. /**
  20518. * Gets or sets the unique id of the material
  20519. */
  20520. uniqueId: number;
  20521. /**
  20522. * The name of the material
  20523. */
  20524. name: string;
  20525. /**
  20526. * Gets or sets user defined metadata
  20527. */
  20528. metadata: any;
  20529. /**
  20530. * For internal use only. Please do not use.
  20531. */
  20532. reservedDataStore: any;
  20533. /**
  20534. * Specifies if the ready state should be checked on each call
  20535. */
  20536. checkReadyOnEveryCall: boolean;
  20537. /**
  20538. * Specifies if the ready state should be checked once
  20539. */
  20540. checkReadyOnlyOnce: boolean;
  20541. /**
  20542. * The state of the material
  20543. */
  20544. state: string;
  20545. /**
  20546. * The alpha value of the material
  20547. */
  20548. protected _alpha: number;
  20549. /**
  20550. * List of inspectable custom properties (used by the Inspector)
  20551. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20552. */
  20553. inspectableCustomProperties: IInspectable[];
  20554. /**
  20555. * Sets the alpha value of the material
  20556. */
  20557. /**
  20558. * Gets the alpha value of the material
  20559. */
  20560. alpha: number;
  20561. /**
  20562. * Specifies if back face culling is enabled
  20563. */
  20564. protected _backFaceCulling: boolean;
  20565. /**
  20566. * Sets the back-face culling state
  20567. */
  20568. /**
  20569. * Gets the back-face culling state
  20570. */
  20571. backFaceCulling: boolean;
  20572. /**
  20573. * Stores the value for side orientation
  20574. */
  20575. sideOrientation: number;
  20576. /**
  20577. * Callback triggered when the material is compiled
  20578. */
  20579. onCompiled: Nullable<(effect: Effect) => void>;
  20580. /**
  20581. * Callback triggered when an error occurs
  20582. */
  20583. onError: Nullable<(effect: Effect, errors: string) => void>;
  20584. /**
  20585. * Callback triggered to get the render target textures
  20586. */
  20587. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20588. /**
  20589. * Gets a boolean indicating that current material needs to register RTT
  20590. */
  20591. readonly hasRenderTargetTextures: boolean;
  20592. /**
  20593. * Specifies if the material should be serialized
  20594. */
  20595. doNotSerialize: boolean;
  20596. /**
  20597. * @hidden
  20598. */
  20599. _storeEffectOnSubMeshes: boolean;
  20600. /**
  20601. * Stores the animations for the material
  20602. */
  20603. animations: Nullable<Array<Animation>>;
  20604. /**
  20605. * An event triggered when the material is disposed
  20606. */
  20607. onDisposeObservable: Observable<Material>;
  20608. /**
  20609. * An observer which watches for dispose events
  20610. */
  20611. private _onDisposeObserver;
  20612. private _onUnBindObservable;
  20613. /**
  20614. * Called during a dispose event
  20615. */
  20616. onDispose: () => void;
  20617. private _onBindObservable;
  20618. /**
  20619. * An event triggered when the material is bound
  20620. */
  20621. readonly onBindObservable: Observable<AbstractMesh>;
  20622. /**
  20623. * An observer which watches for bind events
  20624. */
  20625. private _onBindObserver;
  20626. /**
  20627. * Called during a bind event
  20628. */
  20629. onBind: (Mesh: AbstractMesh) => void;
  20630. /**
  20631. * An event triggered when the material is unbound
  20632. */
  20633. readonly onUnBindObservable: Observable<Material>;
  20634. /**
  20635. * Stores the value of the alpha mode
  20636. */
  20637. private _alphaMode;
  20638. /**
  20639. * Sets the value of the alpha mode.
  20640. *
  20641. * | Value | Type | Description |
  20642. * | --- | --- | --- |
  20643. * | 0 | ALPHA_DISABLE | |
  20644. * | 1 | ALPHA_ADD | |
  20645. * | 2 | ALPHA_COMBINE | |
  20646. * | 3 | ALPHA_SUBTRACT | |
  20647. * | 4 | ALPHA_MULTIPLY | |
  20648. * | 5 | ALPHA_MAXIMIZED | |
  20649. * | 6 | ALPHA_ONEONE | |
  20650. * | 7 | ALPHA_PREMULTIPLIED | |
  20651. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20652. * | 9 | ALPHA_INTERPOLATE | |
  20653. * | 10 | ALPHA_SCREENMODE | |
  20654. *
  20655. */
  20656. /**
  20657. * Gets the value of the alpha mode
  20658. */
  20659. alphaMode: number;
  20660. /**
  20661. * Stores the state of the need depth pre-pass value
  20662. */
  20663. private _needDepthPrePass;
  20664. /**
  20665. * Sets the need depth pre-pass value
  20666. */
  20667. /**
  20668. * Gets the depth pre-pass value
  20669. */
  20670. needDepthPrePass: boolean;
  20671. /**
  20672. * Specifies if depth writing should be disabled
  20673. */
  20674. disableDepthWrite: boolean;
  20675. /**
  20676. * Specifies if depth writing should be forced
  20677. */
  20678. forceDepthWrite: boolean;
  20679. /**
  20680. * Specifies if there should be a separate pass for culling
  20681. */
  20682. separateCullingPass: boolean;
  20683. /**
  20684. * Stores the state specifing if fog should be enabled
  20685. */
  20686. private _fogEnabled;
  20687. /**
  20688. * Sets the state for enabling fog
  20689. */
  20690. /**
  20691. * Gets the value of the fog enabled state
  20692. */
  20693. fogEnabled: boolean;
  20694. /**
  20695. * Stores the size of points
  20696. */
  20697. pointSize: number;
  20698. /**
  20699. * Stores the z offset value
  20700. */
  20701. zOffset: number;
  20702. /**
  20703. * Gets a value specifying if wireframe mode is enabled
  20704. */
  20705. /**
  20706. * Sets the state of wireframe mode
  20707. */
  20708. wireframe: boolean;
  20709. /**
  20710. * Gets the value specifying if point clouds are enabled
  20711. */
  20712. /**
  20713. * Sets the state of point cloud mode
  20714. */
  20715. pointsCloud: boolean;
  20716. /**
  20717. * Gets the material fill mode
  20718. */
  20719. /**
  20720. * Sets the material fill mode
  20721. */
  20722. fillMode: number;
  20723. /**
  20724. * @hidden
  20725. * Stores the effects for the material
  20726. */
  20727. _effect: Nullable<Effect>;
  20728. /**
  20729. * @hidden
  20730. * Specifies if the material was previously ready
  20731. */
  20732. _wasPreviouslyReady: boolean;
  20733. /**
  20734. * Specifies if uniform buffers should be used
  20735. */
  20736. private _useUBO;
  20737. /**
  20738. * Stores a reference to the scene
  20739. */
  20740. private _scene;
  20741. /**
  20742. * Stores the fill mode state
  20743. */
  20744. private _fillMode;
  20745. /**
  20746. * Specifies if the depth write state should be cached
  20747. */
  20748. private _cachedDepthWriteState;
  20749. /**
  20750. * Stores the uniform buffer
  20751. */
  20752. protected _uniformBuffer: UniformBuffer;
  20753. /** @hidden */
  20754. _indexInSceneMaterialArray: number;
  20755. /** @hidden */
  20756. meshMap: Nullable<{
  20757. [id: string]: AbstractMesh | undefined;
  20758. }>;
  20759. /**
  20760. * Creates a material instance
  20761. * @param name defines the name of the material
  20762. * @param scene defines the scene to reference
  20763. * @param doNotAdd specifies if the material should be added to the scene
  20764. */
  20765. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20766. /**
  20767. * Returns a string representation of the current material
  20768. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20769. * @returns a string with material information
  20770. */
  20771. toString(fullDetails?: boolean): string;
  20772. /**
  20773. * Gets the class name of the material
  20774. * @returns a string with the class name of the material
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Specifies if updates for the material been locked
  20779. */
  20780. readonly isFrozen: boolean;
  20781. /**
  20782. * Locks updates for the material
  20783. */
  20784. freeze(): void;
  20785. /**
  20786. * Unlocks updates for the material
  20787. */
  20788. unfreeze(): void;
  20789. /**
  20790. * Specifies if the material is ready to be used
  20791. * @param mesh defines the mesh to check
  20792. * @param useInstances specifies if instances should be used
  20793. * @returns a boolean indicating if the material is ready to be used
  20794. */
  20795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20796. /**
  20797. * Specifies that the submesh is ready to be used
  20798. * @param mesh defines the mesh to check
  20799. * @param subMesh defines which submesh to check
  20800. * @param useInstances specifies that instances should be used
  20801. * @returns a boolean indicating that the submesh is ready or not
  20802. */
  20803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20804. /**
  20805. * Returns the material effect
  20806. * @returns the effect associated with the material
  20807. */
  20808. getEffect(): Nullable<Effect>;
  20809. /**
  20810. * Returns the current scene
  20811. * @returns a Scene
  20812. */
  20813. getScene(): Scene;
  20814. /**
  20815. * Specifies if the material will require alpha blending
  20816. * @returns a boolean specifying if alpha blending is needed
  20817. */
  20818. needAlphaBlending(): boolean;
  20819. /**
  20820. * Specifies if the mesh will require alpha blending
  20821. * @param mesh defines the mesh to check
  20822. * @returns a boolean specifying if alpha blending is needed for the mesh
  20823. */
  20824. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20825. /**
  20826. * Specifies if this material should be rendered in alpha test mode
  20827. * @returns a boolean specifying if an alpha test is needed.
  20828. */
  20829. needAlphaTesting(): boolean;
  20830. /**
  20831. * Gets the texture used for the alpha test
  20832. * @returns the texture to use for alpha testing
  20833. */
  20834. getAlphaTestTexture(): Nullable<BaseTexture>;
  20835. /**
  20836. * Marks the material to indicate that it needs to be re-calculated
  20837. */
  20838. markDirty(): void;
  20839. /** @hidden */
  20840. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20841. /**
  20842. * Binds the material to the mesh
  20843. * @param world defines the world transformation matrix
  20844. * @param mesh defines the mesh to bind the material to
  20845. */
  20846. bind(world: Matrix, mesh?: Mesh): void;
  20847. /**
  20848. * Binds the submesh to the material
  20849. * @param world defines the world transformation matrix
  20850. * @param mesh defines the mesh containing the submesh
  20851. * @param subMesh defines the submesh to bind the material to
  20852. */
  20853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20854. /**
  20855. * Binds the world matrix to the material
  20856. * @param world defines the world transformation matrix
  20857. */
  20858. bindOnlyWorldMatrix(world: Matrix): void;
  20859. /**
  20860. * Binds the scene's uniform buffer to the effect.
  20861. * @param effect defines the effect to bind to the scene uniform buffer
  20862. * @param sceneUbo defines the uniform buffer storing scene data
  20863. */
  20864. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20865. /**
  20866. * Binds the view matrix to the effect
  20867. * @param effect defines the effect to bind the view matrix to
  20868. */
  20869. bindView(effect: Effect): void;
  20870. /**
  20871. * Binds the view projection matrix to the effect
  20872. * @param effect defines the effect to bind the view projection matrix to
  20873. */
  20874. bindViewProjection(effect: Effect): void;
  20875. /**
  20876. * Specifies if material alpha testing should be turned on for the mesh
  20877. * @param mesh defines the mesh to check
  20878. */
  20879. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20880. /**
  20881. * Processes to execute after binding the material to a mesh
  20882. * @param mesh defines the rendered mesh
  20883. */
  20884. protected _afterBind(mesh?: Mesh): void;
  20885. /**
  20886. * Unbinds the material from the mesh
  20887. */
  20888. unbind(): void;
  20889. /**
  20890. * Gets the active textures from the material
  20891. * @returns an array of textures
  20892. */
  20893. getActiveTextures(): BaseTexture[];
  20894. /**
  20895. * Specifies if the material uses a texture
  20896. * @param texture defines the texture to check against the material
  20897. * @returns a boolean specifying if the material uses the texture
  20898. */
  20899. hasTexture(texture: BaseTexture): boolean;
  20900. /**
  20901. * Makes a duplicate of the material, and gives it a new name
  20902. * @param name defines the new name for the duplicated material
  20903. * @returns the cloned material
  20904. */
  20905. clone(name: string): Nullable<Material>;
  20906. /**
  20907. * Gets the meshes bound to the material
  20908. * @returns an array of meshes bound to the material
  20909. */
  20910. getBindedMeshes(): AbstractMesh[];
  20911. /**
  20912. * Force shader compilation
  20913. * @param mesh defines the mesh associated with this material
  20914. * @param onCompiled defines a function to execute once the material is compiled
  20915. * @param options defines the options to configure the compilation
  20916. */
  20917. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20918. clipPlane: boolean;
  20919. }>): void;
  20920. /**
  20921. * Force shader compilation
  20922. * @param mesh defines the mesh that will use this material
  20923. * @param options defines additional options for compiling the shaders
  20924. * @returns a promise that resolves when the compilation completes
  20925. */
  20926. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20927. clipPlane: boolean;
  20928. }>): Promise<void>;
  20929. private static readonly _AllDirtyCallBack;
  20930. private static readonly _ImageProcessingDirtyCallBack;
  20931. private static readonly _TextureDirtyCallBack;
  20932. private static readonly _FresnelDirtyCallBack;
  20933. private static readonly _MiscDirtyCallBack;
  20934. private static readonly _LightsDirtyCallBack;
  20935. private static readonly _AttributeDirtyCallBack;
  20936. private static _FresnelAndMiscDirtyCallBack;
  20937. private static _TextureAndMiscDirtyCallBack;
  20938. private static readonly _DirtyCallbackArray;
  20939. private static readonly _RunDirtyCallBacks;
  20940. /**
  20941. * Marks a define in the material to indicate that it needs to be re-computed
  20942. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20943. */
  20944. markAsDirty(flag: number): void;
  20945. /**
  20946. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20947. * @param func defines a function which checks material defines against the submeshes
  20948. */
  20949. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20950. /**
  20951. * Indicates that we need to re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsAllDirty(): void;
  20954. /**
  20955. * Indicates that image processing needs to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20958. /**
  20959. * Indicates that textures need to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsTexturesDirty(): void;
  20962. /**
  20963. * Indicates that fresnel needs to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsFresnelDirty(): void;
  20966. /**
  20967. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20970. /**
  20971. * Indicates that lights need to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsLightsDirty(): void;
  20974. /**
  20975. * Indicates that attributes need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsAttributesDirty(): void;
  20978. /**
  20979. * Indicates that misc needs to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsMiscDirty(): void;
  20982. /**
  20983. * Indicates that textures and misc need to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20986. /**
  20987. * Disposes the material
  20988. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20989. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20990. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20991. */
  20992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20993. /** @hidden */
  20994. private releaseVertexArrayObject;
  20995. /**
  20996. * Serializes this material
  20997. * @returns the serialized material object
  20998. */
  20999. serialize(): any;
  21000. /**
  21001. * Creates a material from parsed material data
  21002. * @param parsedMaterial defines parsed material data
  21003. * @param scene defines the hosting scene
  21004. * @param rootUrl defines the root URL to use to load textures
  21005. * @returns a new material
  21006. */
  21007. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21008. }
  21009. }
  21010. declare module "babylonjs/Materials/multiMaterial" {
  21011. import { Nullable } from "babylonjs/types";
  21012. import { Scene } from "babylonjs/scene";
  21013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21014. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21015. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21016. import { Material } from "babylonjs/Materials/material";
  21017. /**
  21018. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21019. * separate meshes. This can be use to improve performances.
  21020. * @see http://doc.babylonjs.com/how_to/multi_materials
  21021. */
  21022. export class MultiMaterial extends Material {
  21023. private _subMaterials;
  21024. /**
  21025. * Gets or Sets the list of Materials used within the multi material.
  21026. * They need to be ordered according to the submeshes order in the associated mesh
  21027. */
  21028. subMaterials: Nullable<Material>[];
  21029. /**
  21030. * Function used to align with Node.getChildren()
  21031. * @returns the list of Materials used within the multi material
  21032. */
  21033. getChildren(): Nullable<Material>[];
  21034. /**
  21035. * Instantiates a new Multi Material
  21036. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21037. * separate meshes. This can be use to improve performances.
  21038. * @see http://doc.babylonjs.com/how_to/multi_materials
  21039. * @param name Define the name in the scene
  21040. * @param scene Define the scene the material belongs to
  21041. */
  21042. constructor(name: string, scene: Scene);
  21043. private _hookArray;
  21044. /**
  21045. * Get one of the submaterial by its index in the submaterials array
  21046. * @param index The index to look the sub material at
  21047. * @returns The Material if the index has been defined
  21048. */
  21049. getSubMaterial(index: number): Nullable<Material>;
  21050. /**
  21051. * Get the list of active textures for the whole sub materials list.
  21052. * @returns All the textures that will be used during the rendering
  21053. */
  21054. getActiveTextures(): BaseTexture[];
  21055. /**
  21056. * Gets the current class name of the material e.g. "MultiMaterial"
  21057. * Mainly use in serialization.
  21058. * @returns the class name
  21059. */
  21060. getClassName(): string;
  21061. /**
  21062. * Checks if the material is ready to render the requested sub mesh
  21063. * @param mesh Define the mesh the submesh belongs to
  21064. * @param subMesh Define the sub mesh to look readyness for
  21065. * @param useInstances Define whether or not the material is used with instances
  21066. * @returns true if ready, otherwise false
  21067. */
  21068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21069. /**
  21070. * Clones the current material and its related sub materials
  21071. * @param name Define the name of the newly cloned material
  21072. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21073. * @returns the cloned material
  21074. */
  21075. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21076. /**
  21077. * Serializes the materials into a JSON representation.
  21078. * @returns the JSON representation
  21079. */
  21080. serialize(): any;
  21081. /**
  21082. * Dispose the material and release its associated resources
  21083. * @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)
  21084. * @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)
  21085. * @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)
  21086. */
  21087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21088. /**
  21089. * Creates a MultiMaterial from parsed MultiMaterial data.
  21090. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21091. * @param scene defines the hosting scene
  21092. * @returns a new MultiMaterial
  21093. */
  21094. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21095. }
  21096. }
  21097. declare module "babylonjs/Meshes/subMesh" {
  21098. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21100. import { Engine } from "babylonjs/Engines/engine";
  21101. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21102. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21103. import { Effect } from "babylonjs/Materials/effect";
  21104. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21105. import { Plane } from "babylonjs/Maths/math.plane";
  21106. import { Collider } from "babylonjs/Collisions/collider";
  21107. import { Material } from "babylonjs/Materials/material";
  21108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21110. import { Mesh } from "babylonjs/Meshes/mesh";
  21111. import { Ray } from "babylonjs/Culling/ray";
  21112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21113. /**
  21114. * Base class for submeshes
  21115. */
  21116. export class BaseSubMesh {
  21117. /** @hidden */
  21118. _materialDefines: Nullable<MaterialDefines>;
  21119. /** @hidden */
  21120. _materialEffect: Nullable<Effect>;
  21121. /**
  21122. * Gets associated effect
  21123. */
  21124. readonly effect: Nullable<Effect>;
  21125. /**
  21126. * Sets associated effect (effect used to render this submesh)
  21127. * @param effect defines the effect to associate with
  21128. * @param defines defines the set of defines used to compile this effect
  21129. */
  21130. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21131. }
  21132. /**
  21133. * Defines a subdivision inside a mesh
  21134. */
  21135. export class SubMesh extends BaseSubMesh implements ICullable {
  21136. /** the material index to use */
  21137. materialIndex: number;
  21138. /** vertex index start */
  21139. verticesStart: number;
  21140. /** vertices count */
  21141. verticesCount: number;
  21142. /** index start */
  21143. indexStart: number;
  21144. /** indices count */
  21145. indexCount: number;
  21146. /** @hidden */
  21147. _linesIndexCount: number;
  21148. private _mesh;
  21149. private _renderingMesh;
  21150. private _boundingInfo;
  21151. private _linesIndexBuffer;
  21152. /** @hidden */
  21153. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21154. /** @hidden */
  21155. _trianglePlanes: Plane[];
  21156. /** @hidden */
  21157. _lastColliderTransformMatrix: Nullable<Matrix>;
  21158. /** @hidden */
  21159. _renderId: number;
  21160. /** @hidden */
  21161. _alphaIndex: number;
  21162. /** @hidden */
  21163. _distanceToCamera: number;
  21164. /** @hidden */
  21165. _id: number;
  21166. private _currentMaterial;
  21167. /**
  21168. * Add a new submesh to a mesh
  21169. * @param materialIndex defines the material index to use
  21170. * @param verticesStart defines vertex index start
  21171. * @param verticesCount defines vertices count
  21172. * @param indexStart defines index start
  21173. * @param indexCount defines indices count
  21174. * @param mesh defines the parent mesh
  21175. * @param renderingMesh defines an optional rendering mesh
  21176. * @param createBoundingBox defines if bounding box should be created for this submesh
  21177. * @returns the new submesh
  21178. */
  21179. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21180. /**
  21181. * Creates a new submesh
  21182. * @param materialIndex defines the material index to use
  21183. * @param verticesStart defines vertex index start
  21184. * @param verticesCount defines vertices count
  21185. * @param indexStart defines index start
  21186. * @param indexCount defines indices count
  21187. * @param mesh defines the parent mesh
  21188. * @param renderingMesh defines an optional rendering mesh
  21189. * @param createBoundingBox defines if bounding box should be created for this submesh
  21190. */
  21191. constructor(
  21192. /** the material index to use */
  21193. materialIndex: number,
  21194. /** vertex index start */
  21195. verticesStart: number,
  21196. /** vertices count */
  21197. verticesCount: number,
  21198. /** index start */
  21199. indexStart: number,
  21200. /** indices count */
  21201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21202. /**
  21203. * Returns true if this submesh covers the entire parent mesh
  21204. * @ignorenaming
  21205. */
  21206. readonly IsGlobal: boolean;
  21207. /**
  21208. * Returns the submesh BoudingInfo object
  21209. * @returns current bounding info (or mesh's one if the submesh is global)
  21210. */
  21211. getBoundingInfo(): BoundingInfo;
  21212. /**
  21213. * Sets the submesh BoundingInfo
  21214. * @param boundingInfo defines the new bounding info to use
  21215. * @returns the SubMesh
  21216. */
  21217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21218. /**
  21219. * Returns the mesh of the current submesh
  21220. * @return the parent mesh
  21221. */
  21222. getMesh(): AbstractMesh;
  21223. /**
  21224. * Returns the rendering mesh of the submesh
  21225. * @returns the rendering mesh (could be different from parent mesh)
  21226. */
  21227. getRenderingMesh(): Mesh;
  21228. /**
  21229. * Returns the submesh material
  21230. * @returns null or the current material
  21231. */
  21232. getMaterial(): Nullable<Material>;
  21233. /**
  21234. * Sets a new updated BoundingInfo object to the submesh
  21235. * @param data defines an optional position array to use to determine the bounding info
  21236. * @returns the SubMesh
  21237. */
  21238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21239. /** @hidden */
  21240. _checkCollision(collider: Collider): boolean;
  21241. /**
  21242. * Updates the submesh BoundingInfo
  21243. * @param world defines the world matrix to use to update the bounding info
  21244. * @returns the submesh
  21245. */
  21246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21247. /**
  21248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21249. * @param frustumPlanes defines the frustum planes
  21250. * @returns true if the submesh is intersecting with the frustum
  21251. */
  21252. isInFrustum(frustumPlanes: Plane[]): boolean;
  21253. /**
  21254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21255. * @param frustumPlanes defines the frustum planes
  21256. * @returns true if the submesh is inside the frustum
  21257. */
  21258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21259. /**
  21260. * Renders the submesh
  21261. * @param enableAlphaMode defines if alpha needs to be used
  21262. * @returns the submesh
  21263. */
  21264. render(enableAlphaMode: boolean): SubMesh;
  21265. /**
  21266. * @hidden
  21267. */
  21268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21269. /**
  21270. * Checks if the submesh intersects with a ray
  21271. * @param ray defines the ray to test
  21272. * @returns true is the passed ray intersects the submesh bounding box
  21273. */
  21274. canIntersects(ray: Ray): boolean;
  21275. /**
  21276. * Intersects current submesh with a ray
  21277. * @param ray defines the ray to test
  21278. * @param positions defines mesh's positions array
  21279. * @param indices defines mesh's indices array
  21280. * @param fastCheck defines if only bounding info should be used
  21281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21282. * @returns intersection info or null if no intersection
  21283. */
  21284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21285. /** @hidden */
  21286. private _intersectLines;
  21287. /** @hidden */
  21288. private _intersectUnIndexedLines;
  21289. /** @hidden */
  21290. private _intersectTriangles;
  21291. /** @hidden */
  21292. private _intersectUnIndexedTriangles;
  21293. /** @hidden */
  21294. _rebuild(): void;
  21295. /**
  21296. * Creates a new submesh from the passed mesh
  21297. * @param newMesh defines the new hosting mesh
  21298. * @param newRenderingMesh defines an optional rendering mesh
  21299. * @returns the new submesh
  21300. */
  21301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21302. /**
  21303. * Release associated resources
  21304. */
  21305. dispose(): void;
  21306. /**
  21307. * Gets the class name
  21308. * @returns the string "SubMesh".
  21309. */
  21310. getClassName(): string;
  21311. /**
  21312. * Creates a new submesh from indices data
  21313. * @param materialIndex the index of the main mesh material
  21314. * @param startIndex the index where to start the copy in the mesh indices array
  21315. * @param indexCount the number of indices to copy then from the startIndex
  21316. * @param mesh the main mesh to create the submesh from
  21317. * @param renderingMesh the optional rendering mesh
  21318. * @returns a new submesh
  21319. */
  21320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21321. }
  21322. }
  21323. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21324. /**
  21325. * Class used to represent data loading progression
  21326. */
  21327. export class SceneLoaderFlags {
  21328. private static _ForceFullSceneLoadingForIncremental;
  21329. private static _ShowLoadingScreen;
  21330. private static _CleanBoneMatrixWeights;
  21331. private static _loggingLevel;
  21332. /**
  21333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21334. */
  21335. static ForceFullSceneLoadingForIncremental: boolean;
  21336. /**
  21337. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21338. */
  21339. static ShowLoadingScreen: boolean;
  21340. /**
  21341. * Defines the current logging level (while loading the scene)
  21342. * @ignorenaming
  21343. */
  21344. static loggingLevel: number;
  21345. /**
  21346. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21347. */
  21348. static CleanBoneMatrixWeights: boolean;
  21349. }
  21350. }
  21351. declare module "babylonjs/Meshes/geometry" {
  21352. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21353. import { Scene } from "babylonjs/scene";
  21354. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21355. import { Engine } from "babylonjs/Engines/engine";
  21356. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21357. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21358. import { Effect } from "babylonjs/Materials/effect";
  21359. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21360. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21361. import { Mesh } from "babylonjs/Meshes/mesh";
  21362. /**
  21363. * Class used to store geometry data (vertex buffers + index buffer)
  21364. */
  21365. export class Geometry implements IGetSetVerticesData {
  21366. /**
  21367. * Gets or sets the ID of the geometry
  21368. */
  21369. id: string;
  21370. /**
  21371. * Gets or sets the unique ID of the geometry
  21372. */
  21373. uniqueId: number;
  21374. /**
  21375. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21376. */
  21377. delayLoadState: number;
  21378. /**
  21379. * Gets the file containing the data to load when running in delay load state
  21380. */
  21381. delayLoadingFile: Nullable<string>;
  21382. /**
  21383. * Callback called when the geometry is updated
  21384. */
  21385. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21386. private _scene;
  21387. private _engine;
  21388. private _meshes;
  21389. private _totalVertices;
  21390. /** @hidden */
  21391. _indices: IndicesArray;
  21392. /** @hidden */
  21393. _vertexBuffers: {
  21394. [key: string]: VertexBuffer;
  21395. };
  21396. private _isDisposed;
  21397. private _extend;
  21398. private _boundingBias;
  21399. /** @hidden */
  21400. _delayInfo: Array<string>;
  21401. private _indexBuffer;
  21402. private _indexBufferIsUpdatable;
  21403. /** @hidden */
  21404. _boundingInfo: Nullable<BoundingInfo>;
  21405. /** @hidden */
  21406. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21407. /** @hidden */
  21408. _softwareSkinningFrameId: number;
  21409. private _vertexArrayObjects;
  21410. private _updatable;
  21411. /** @hidden */
  21412. _positions: Nullable<Vector3[]>;
  21413. /**
  21414. * 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
  21415. */
  21416. /**
  21417. * 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
  21418. */
  21419. boundingBias: Vector2;
  21420. /**
  21421. * Static function used to attach a new empty geometry to a mesh
  21422. * @param mesh defines the mesh to attach the geometry to
  21423. * @returns the new Geometry
  21424. */
  21425. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21426. /**
  21427. * Creates a new geometry
  21428. * @param id defines the unique ID
  21429. * @param scene defines the hosting scene
  21430. * @param vertexData defines the VertexData used to get geometry data
  21431. * @param updatable defines if geometry must be updatable (false by default)
  21432. * @param mesh defines the mesh that will be associated with the geometry
  21433. */
  21434. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21435. /**
  21436. * Gets the current extend of the geometry
  21437. */
  21438. readonly extend: {
  21439. minimum: Vector3;
  21440. maximum: Vector3;
  21441. };
  21442. /**
  21443. * Gets the hosting scene
  21444. * @returns the hosting Scene
  21445. */
  21446. getScene(): Scene;
  21447. /**
  21448. * Gets the hosting engine
  21449. * @returns the hosting Engine
  21450. */
  21451. getEngine(): Engine;
  21452. /**
  21453. * Defines if the geometry is ready to use
  21454. * @returns true if the geometry is ready to be used
  21455. */
  21456. isReady(): boolean;
  21457. /**
  21458. * Gets a value indicating that the geometry should not be serialized
  21459. */
  21460. readonly doNotSerialize: boolean;
  21461. /** @hidden */
  21462. _rebuild(): void;
  21463. /**
  21464. * Affects all geometry data in one call
  21465. * @param vertexData defines the geometry data
  21466. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21467. */
  21468. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21469. /**
  21470. * Set specific vertex data
  21471. * @param kind defines the data kind (Position, normal, etc...)
  21472. * @param data defines the vertex data to use
  21473. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21474. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21475. */
  21476. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21477. /**
  21478. * Removes a specific vertex data
  21479. * @param kind defines the data kind (Position, normal, etc...)
  21480. */
  21481. removeVerticesData(kind: string): void;
  21482. /**
  21483. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21484. * @param buffer defines the vertex buffer to use
  21485. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21486. */
  21487. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21488. /**
  21489. * Update a specific vertex buffer
  21490. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21491. * It will do nothing if the buffer is not updatable
  21492. * @param kind defines the data kind (Position, normal, etc...)
  21493. * @param data defines the data to use
  21494. * @param offset defines the offset in the target buffer where to store the data
  21495. * @param useBytes set to true if the offset is in bytes
  21496. */
  21497. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21498. /**
  21499. * Update a specific vertex buffer
  21500. * This function will create a new buffer if the current one is not updatable
  21501. * @param kind defines the data kind (Position, normal, etc...)
  21502. * @param data defines the data to use
  21503. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21504. */
  21505. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21506. private _updateBoundingInfo;
  21507. /** @hidden */
  21508. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21509. /**
  21510. * Gets total number of vertices
  21511. * @returns the total number of vertices
  21512. */
  21513. getTotalVertices(): number;
  21514. /**
  21515. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21518. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21519. * @returns a float array containing vertex data
  21520. */
  21521. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21522. /**
  21523. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21524. * @param kind defines the data kind (Position, normal, etc...)
  21525. * @returns true if the vertex buffer with the specified kind is updatable
  21526. */
  21527. isVertexBufferUpdatable(kind: string): boolean;
  21528. /**
  21529. * Gets a specific vertex buffer
  21530. * @param kind defines the data kind (Position, normal, etc...)
  21531. * @returns a VertexBuffer
  21532. */
  21533. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21534. /**
  21535. * Returns all vertex buffers
  21536. * @return an object holding all vertex buffers indexed by kind
  21537. */
  21538. getVertexBuffers(): Nullable<{
  21539. [key: string]: VertexBuffer;
  21540. }>;
  21541. /**
  21542. * Gets a boolean indicating if specific vertex buffer is present
  21543. * @param kind defines the data kind (Position, normal, etc...)
  21544. * @returns true if data is present
  21545. */
  21546. isVerticesDataPresent(kind: string): boolean;
  21547. /**
  21548. * Gets a list of all attached data kinds (Position, normal, etc...)
  21549. * @returns a list of string containing all kinds
  21550. */
  21551. getVerticesDataKinds(): string[];
  21552. /**
  21553. * Update index buffer
  21554. * @param indices defines the indices to store in the index buffer
  21555. * @param offset defines the offset in the target buffer where to store the data
  21556. * @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)
  21557. */
  21558. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21559. /**
  21560. * Creates a new index buffer
  21561. * @param indices defines the indices to store in the index buffer
  21562. * @param totalVertices defines the total number of vertices (could be null)
  21563. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21564. */
  21565. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21566. /**
  21567. * Return the total number of indices
  21568. * @returns the total number of indices
  21569. */
  21570. getTotalIndices(): number;
  21571. /**
  21572. * Gets the index buffer array
  21573. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21575. * @returns the index buffer array
  21576. */
  21577. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21578. /**
  21579. * Gets the index buffer
  21580. * @return the index buffer
  21581. */
  21582. getIndexBuffer(): Nullable<DataBuffer>;
  21583. /** @hidden */
  21584. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21585. /**
  21586. * Release the associated resources for a specific mesh
  21587. * @param mesh defines the source mesh
  21588. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21589. */
  21590. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21591. /**
  21592. * Apply current geometry to a given mesh
  21593. * @param mesh defines the mesh to apply geometry to
  21594. */
  21595. applyToMesh(mesh: Mesh): void;
  21596. private _updateExtend;
  21597. private _applyToMesh;
  21598. private notifyUpdate;
  21599. /**
  21600. * Load the geometry if it was flagged as delay loaded
  21601. * @param scene defines the hosting scene
  21602. * @param onLoaded defines a callback called when the geometry is loaded
  21603. */
  21604. load(scene: Scene, onLoaded?: () => void): void;
  21605. private _queueLoad;
  21606. /**
  21607. * Invert the geometry to move from a right handed system to a left handed one.
  21608. */
  21609. toLeftHanded(): void;
  21610. /** @hidden */
  21611. _resetPointsArrayCache(): void;
  21612. /** @hidden */
  21613. _generatePointsArray(): boolean;
  21614. /**
  21615. * Gets a value indicating if the geometry is disposed
  21616. * @returns true if the geometry was disposed
  21617. */
  21618. isDisposed(): boolean;
  21619. private _disposeVertexArrayObjects;
  21620. /**
  21621. * Free all associated resources
  21622. */
  21623. dispose(): void;
  21624. /**
  21625. * Clone the current geometry into a new geometry
  21626. * @param id defines the unique ID of the new geometry
  21627. * @returns a new geometry object
  21628. */
  21629. copy(id: string): Geometry;
  21630. /**
  21631. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21632. * @return a JSON representation of the current geometry data (without the vertices data)
  21633. */
  21634. serialize(): any;
  21635. private toNumberArray;
  21636. /**
  21637. * Serialize all vertices data into a JSON oject
  21638. * @returns a JSON representation of the current geometry data
  21639. */
  21640. serializeVerticeData(): any;
  21641. /**
  21642. * Extracts a clone of a mesh geometry
  21643. * @param mesh defines the source mesh
  21644. * @param id defines the unique ID of the new geometry object
  21645. * @returns the new geometry object
  21646. */
  21647. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21648. /**
  21649. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21650. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21651. * Be aware Math.random() could cause collisions, but:
  21652. * "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"
  21653. * @returns a string containing a new GUID
  21654. */
  21655. static RandomId(): string;
  21656. /** @hidden */
  21657. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21658. private static _CleanMatricesWeights;
  21659. /**
  21660. * Create a new geometry from persisted data (Using .babylon file format)
  21661. * @param parsedVertexData defines the persisted data
  21662. * @param scene defines the hosting scene
  21663. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21664. * @returns the new geometry object
  21665. */
  21666. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21667. }
  21668. }
  21669. declare module "babylonjs/Meshes/mesh.vertexData" {
  21670. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21671. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21672. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21673. import { Geometry } from "babylonjs/Meshes/geometry";
  21674. import { Mesh } from "babylonjs/Meshes/mesh";
  21675. /**
  21676. * Define an interface for all classes that will get and set the data on vertices
  21677. */
  21678. export interface IGetSetVerticesData {
  21679. /**
  21680. * Gets a boolean indicating if specific vertex data is present
  21681. * @param kind defines the vertex data kind to use
  21682. * @returns true is data kind is present
  21683. */
  21684. isVerticesDataPresent(kind: string): boolean;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21695. * @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.
  21696. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21697. * @returns the indices array or an empty array if the mesh has no geometry
  21698. */
  21699. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21700. /**
  21701. * Set specific vertex data
  21702. * @param kind defines the data kind (Position, normal, etc...)
  21703. * @param data defines the vertex data to use
  21704. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21705. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21706. */
  21707. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21708. /**
  21709. * Update a specific associated vertex buffer
  21710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21711. * - VertexBuffer.PositionKind
  21712. * - VertexBuffer.UVKind
  21713. * - VertexBuffer.UV2Kind
  21714. * - VertexBuffer.UV3Kind
  21715. * - VertexBuffer.UV4Kind
  21716. * - VertexBuffer.UV5Kind
  21717. * - VertexBuffer.UV6Kind
  21718. * - VertexBuffer.ColorKind
  21719. * - VertexBuffer.MatricesIndicesKind
  21720. * - VertexBuffer.MatricesIndicesExtraKind
  21721. * - VertexBuffer.MatricesWeightsKind
  21722. * - VertexBuffer.MatricesWeightsExtraKind
  21723. * @param data defines the data source
  21724. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21725. * @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)
  21726. */
  21727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21728. /**
  21729. * Creates a new index buffer
  21730. * @param indices defines the indices to store in the index buffer
  21731. * @param totalVertices defines the total number of vertices (could be null)
  21732. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21733. */
  21734. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21735. }
  21736. /**
  21737. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21738. */
  21739. export class VertexData {
  21740. /**
  21741. * Mesh side orientation : usually the external or front surface
  21742. */
  21743. static readonly FRONTSIDE: number;
  21744. /**
  21745. * Mesh side orientation : usually the internal or back surface
  21746. */
  21747. static readonly BACKSIDE: number;
  21748. /**
  21749. * Mesh side orientation : both internal and external or front and back surfaces
  21750. */
  21751. static readonly DOUBLESIDE: number;
  21752. /**
  21753. * Mesh side orientation : by default, `FRONTSIDE`
  21754. */
  21755. static readonly DEFAULTSIDE: number;
  21756. /**
  21757. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21758. */
  21759. positions: Nullable<FloatArray>;
  21760. /**
  21761. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21762. */
  21763. normals: Nullable<FloatArray>;
  21764. /**
  21765. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21766. */
  21767. tangents: Nullable<FloatArray>;
  21768. /**
  21769. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21770. */
  21771. uvs: Nullable<FloatArray>;
  21772. /**
  21773. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs2: Nullable<FloatArray>;
  21776. /**
  21777. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs3: Nullable<FloatArray>;
  21780. /**
  21781. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs4: Nullable<FloatArray>;
  21784. /**
  21785. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs5: Nullable<FloatArray>;
  21788. /**
  21789. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21790. */
  21791. uvs6: Nullable<FloatArray>;
  21792. /**
  21793. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21794. */
  21795. colors: Nullable<FloatArray>;
  21796. /**
  21797. * 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).
  21798. */
  21799. matricesIndices: Nullable<FloatArray>;
  21800. /**
  21801. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21802. */
  21803. matricesWeights: Nullable<FloatArray>;
  21804. /**
  21805. * An array extending the number of possible indices
  21806. */
  21807. matricesIndicesExtra: Nullable<FloatArray>;
  21808. /**
  21809. * An array extending the number of possible weights when the number of indices is extended
  21810. */
  21811. matricesWeightsExtra: Nullable<FloatArray>;
  21812. /**
  21813. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21814. */
  21815. indices: Nullable<IndicesArray>;
  21816. /**
  21817. * Uses the passed data array to set the set the values for the specified kind of data
  21818. * @param data a linear array of floating numbers
  21819. * @param kind the type of data that is being set, eg positions, colors etc
  21820. */
  21821. set(data: FloatArray, kind: string): void;
  21822. /**
  21823. * Associates the vertexData to the passed Mesh.
  21824. * Sets it as updatable or not (default `false`)
  21825. * @param mesh the mesh the vertexData is applied to
  21826. * @param updatable when used and having the value true allows new data to update the vertexData
  21827. * @returns the VertexData
  21828. */
  21829. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21830. /**
  21831. * Associates the vertexData to the passed Geometry.
  21832. * Sets it as updatable or not (default `false`)
  21833. * @param geometry the geometry the vertexData is applied to
  21834. * @param updatable when used and having the value true allows new data to update the vertexData
  21835. * @returns VertexData
  21836. */
  21837. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21838. /**
  21839. * Updates the associated mesh
  21840. * @param mesh the mesh to be updated
  21841. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21842. * @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
  21843. * @returns VertexData
  21844. */
  21845. updateMesh(mesh: Mesh): VertexData;
  21846. /**
  21847. * Updates the associated geometry
  21848. * @param geometry the geometry to be updated
  21849. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21850. * @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
  21851. * @returns VertexData.
  21852. */
  21853. updateGeometry(geometry: Geometry): VertexData;
  21854. private _applyTo;
  21855. private _update;
  21856. /**
  21857. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21858. * @param matrix the transforming matrix
  21859. * @returns the VertexData
  21860. */
  21861. transform(matrix: Matrix): VertexData;
  21862. /**
  21863. * Merges the passed VertexData into the current one
  21864. * @param other the VertexData to be merged into the current one
  21865. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21866. * @returns the modified VertexData
  21867. */
  21868. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21869. private _mergeElement;
  21870. private _validate;
  21871. /**
  21872. * Serializes the VertexData
  21873. * @returns a serialized object
  21874. */
  21875. serialize(): any;
  21876. /**
  21877. * Extracts the vertexData from a mesh
  21878. * @param mesh the mesh from which to extract the VertexData
  21879. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21880. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21881. * @returns the object VertexData associated to the passed mesh
  21882. */
  21883. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21884. /**
  21885. * Extracts the vertexData from the geometry
  21886. * @param geometry the geometry from which to extract the VertexData
  21887. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21888. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21889. * @returns the object VertexData associated to the passed mesh
  21890. */
  21891. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21892. private static _ExtractFrom;
  21893. /**
  21894. * Creates the VertexData for a Ribbon
  21895. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21896. * * pathArray array of paths, each of which an array of successive Vector3
  21897. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21898. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21899. * * 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
  21900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21901. * * 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)
  21902. * * 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)
  21903. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21904. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21905. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21906. * @returns the VertexData of the ribbon
  21907. */
  21908. static CreateRibbon(options: {
  21909. pathArray: Vector3[][];
  21910. closeArray?: boolean;
  21911. closePath?: boolean;
  21912. offset?: number;
  21913. sideOrientation?: number;
  21914. frontUVs?: Vector4;
  21915. backUVs?: Vector4;
  21916. invertUV?: boolean;
  21917. uvs?: Vector2[];
  21918. colors?: Color4[];
  21919. }): VertexData;
  21920. /**
  21921. * Creates the VertexData for a box
  21922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21923. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21924. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21925. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21926. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21927. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21928. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21930. * * 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)
  21931. * * 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)
  21932. * @returns the VertexData of the box
  21933. */
  21934. static CreateBox(options: {
  21935. size?: number;
  21936. width?: number;
  21937. height?: number;
  21938. depth?: number;
  21939. faceUV?: Vector4[];
  21940. faceColors?: Color4[];
  21941. sideOrientation?: number;
  21942. frontUVs?: Vector4;
  21943. backUVs?: Vector4;
  21944. }): VertexData;
  21945. /**
  21946. * Creates the VertexData for a tiled box
  21947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21948. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21952. * @returns the VertexData of the box
  21953. */
  21954. static CreateTiledBox(options: {
  21955. pattern?: number;
  21956. width?: number;
  21957. height?: number;
  21958. depth?: number;
  21959. tileSize?: number;
  21960. tileWidth?: number;
  21961. tileHeight?: number;
  21962. alignHorizontal?: number;
  21963. alignVertical?: number;
  21964. faceUV?: Vector4[];
  21965. faceColors?: Color4[];
  21966. sideOrientation?: number;
  21967. }): VertexData;
  21968. /**
  21969. * Creates the VertexData for a tiled plane
  21970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21971. * * pattern a limited pattern arrangement depending on the number
  21972. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21973. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21974. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21976. * * 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)
  21977. * * 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)
  21978. * @returns the VertexData of the tiled plane
  21979. */
  21980. static CreateTiledPlane(options: {
  21981. pattern?: number;
  21982. tileSize?: number;
  21983. tileWidth?: number;
  21984. tileHeight?: number;
  21985. size?: number;
  21986. width?: number;
  21987. height?: number;
  21988. alignHorizontal?: number;
  21989. alignVertical?: number;
  21990. sideOrientation?: number;
  21991. frontUVs?: Vector4;
  21992. backUVs?: Vector4;
  21993. }): VertexData;
  21994. /**
  21995. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21997. * * segments sets the number of horizontal strips optional, default 32
  21998. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21999. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22000. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22001. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22002. * * 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
  22003. * * 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
  22004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22005. * * 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)
  22006. * * 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)
  22007. * @returns the VertexData of the ellipsoid
  22008. */
  22009. static CreateSphere(options: {
  22010. segments?: number;
  22011. diameter?: number;
  22012. diameterX?: number;
  22013. diameterY?: number;
  22014. diameterZ?: number;
  22015. arc?: number;
  22016. slice?: number;
  22017. sideOrientation?: number;
  22018. frontUVs?: Vector4;
  22019. backUVs?: Vector4;
  22020. }): VertexData;
  22021. /**
  22022. * Creates the VertexData for a cylinder, cone or prism
  22023. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22024. * * height sets the height (y direction) of the cylinder, optional, default 2
  22025. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22026. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22027. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22028. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22029. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22030. * * 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
  22031. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22032. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22033. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22034. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22036. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22037. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22038. * @returns the VertexData of the cylinder, cone or prism
  22039. */
  22040. static CreateCylinder(options: {
  22041. height?: number;
  22042. diameterTop?: number;
  22043. diameterBottom?: number;
  22044. diameter?: number;
  22045. tessellation?: number;
  22046. subdivisions?: number;
  22047. arc?: number;
  22048. faceColors?: Color4[];
  22049. faceUV?: Vector4[];
  22050. hasRings?: boolean;
  22051. enclose?: boolean;
  22052. sideOrientation?: number;
  22053. frontUVs?: Vector4;
  22054. backUVs?: Vector4;
  22055. }): VertexData;
  22056. /**
  22057. * Creates the VertexData for a torus
  22058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22059. * * diameter the diameter of the torus, optional default 1
  22060. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22061. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22063. * * 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)
  22064. * * 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)
  22065. * @returns the VertexData of the torus
  22066. */
  22067. static CreateTorus(options: {
  22068. diameter?: number;
  22069. thickness?: number;
  22070. tessellation?: number;
  22071. sideOrientation?: number;
  22072. frontUVs?: Vector4;
  22073. backUVs?: Vector4;
  22074. }): VertexData;
  22075. /**
  22076. * Creates the VertexData of the LineSystem
  22077. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22078. * - lines an array of lines, each line being an array of successive Vector3
  22079. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22080. * @returns the VertexData of the LineSystem
  22081. */
  22082. static CreateLineSystem(options: {
  22083. lines: Vector3[][];
  22084. colors?: Nullable<Color4[][]>;
  22085. }): VertexData;
  22086. /**
  22087. * Create the VertexData for a DashedLines
  22088. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22089. * - points an array successive Vector3
  22090. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22091. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22092. * - dashNb the intended total number of dashes, optional, default 200
  22093. * @returns the VertexData for the DashedLines
  22094. */
  22095. static CreateDashedLines(options: {
  22096. points: Vector3[];
  22097. dashSize?: number;
  22098. gapSize?: number;
  22099. dashNb?: number;
  22100. }): VertexData;
  22101. /**
  22102. * Creates the VertexData for a Ground
  22103. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22104. * - width the width (x direction) of the ground, optional, default 1
  22105. * - height the height (z direction) of the ground, optional, default 1
  22106. * - subdivisions the number of subdivisions per side, optional, default 1
  22107. * @returns the VertexData of the Ground
  22108. */
  22109. static CreateGround(options: {
  22110. width?: number;
  22111. height?: number;
  22112. subdivisions?: number;
  22113. subdivisionsX?: number;
  22114. subdivisionsY?: number;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22118. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22119. * * xmin the ground minimum X coordinate, optional, default -1
  22120. * * zmin the ground minimum Z coordinate, optional, default -1
  22121. * * xmax the ground maximum X coordinate, optional, default 1
  22122. * * zmax the ground maximum Z coordinate, optional, default 1
  22123. * * 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}
  22124. * * 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}
  22125. * @returns the VertexData of the TiledGround
  22126. */
  22127. static CreateTiledGround(options: {
  22128. xmin: number;
  22129. zmin: number;
  22130. xmax: number;
  22131. zmax: number;
  22132. subdivisions?: {
  22133. w: number;
  22134. h: number;
  22135. };
  22136. precision?: {
  22137. w: number;
  22138. h: number;
  22139. };
  22140. }): VertexData;
  22141. /**
  22142. * Creates the VertexData of the Ground designed from a heightmap
  22143. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22144. * * width the width (x direction) of the ground
  22145. * * height the height (z direction) of the ground
  22146. * * subdivisions the number of subdivisions per side
  22147. * * minHeight the minimum altitude on the ground, optional, default 0
  22148. * * maxHeight the maximum altitude on the ground, optional default 1
  22149. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22150. * * buffer the array holding the image color data
  22151. * * bufferWidth the width of image
  22152. * * bufferHeight the height of image
  22153. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22154. * @returns the VertexData of the Ground designed from a heightmap
  22155. */
  22156. static CreateGroundFromHeightMap(options: {
  22157. width: number;
  22158. height: number;
  22159. subdivisions: number;
  22160. minHeight: number;
  22161. maxHeight: number;
  22162. colorFilter: Color3;
  22163. buffer: Uint8Array;
  22164. bufferWidth: number;
  22165. bufferHeight: number;
  22166. alphaFilter: number;
  22167. }): VertexData;
  22168. /**
  22169. * Creates the VertexData for a Plane
  22170. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22171. * * size sets the width and height of the plane to the value of size, optional default 1
  22172. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22173. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22175. * * 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)
  22176. * * 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)
  22177. * @returns the VertexData of the box
  22178. */
  22179. static CreatePlane(options: {
  22180. size?: number;
  22181. width?: number;
  22182. height?: number;
  22183. sideOrientation?: number;
  22184. frontUVs?: Vector4;
  22185. backUVs?: Vector4;
  22186. }): VertexData;
  22187. /**
  22188. * Creates the VertexData of the Disc or regular Polygon
  22189. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22190. * * radius the radius of the disc, optional default 0.5
  22191. * * tessellation the number of polygon sides, optional, default 64
  22192. * * 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
  22193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22194. * * 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)
  22195. * * 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)
  22196. * @returns the VertexData of the box
  22197. */
  22198. static CreateDisc(options: {
  22199. radius?: number;
  22200. tessellation?: number;
  22201. arc?: number;
  22202. sideOrientation?: number;
  22203. frontUVs?: Vector4;
  22204. backUVs?: Vector4;
  22205. }): VertexData;
  22206. /**
  22207. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22208. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22209. * @param polygon a mesh built from polygonTriangulation.build()
  22210. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22211. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22212. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22213. * @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)
  22214. * @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)
  22215. * @returns the VertexData of the Polygon
  22216. */
  22217. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22218. /**
  22219. * Creates the VertexData of the IcoSphere
  22220. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22221. * * radius the radius of the IcoSphere, optional default 1
  22222. * * radiusX allows stretching in the x direction, optional, default radius
  22223. * * radiusY allows stretching in the y direction, optional, default radius
  22224. * * radiusZ allows stretching in the z direction, optional, default radius
  22225. * * flat when true creates a flat shaded mesh, optional, default true
  22226. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22227. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22228. * * 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)
  22229. * * 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)
  22230. * @returns the VertexData of the IcoSphere
  22231. */
  22232. static CreateIcoSphere(options: {
  22233. radius?: number;
  22234. radiusX?: number;
  22235. radiusY?: number;
  22236. radiusZ?: number;
  22237. flat?: boolean;
  22238. subdivisions?: number;
  22239. sideOrientation?: number;
  22240. frontUVs?: Vector4;
  22241. backUVs?: Vector4;
  22242. }): VertexData;
  22243. /**
  22244. * Creates the VertexData for a Polyhedron
  22245. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22246. * * type provided types are:
  22247. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22248. * * 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)
  22249. * * size the size of the IcoSphere, optional default 1
  22250. * * sizeX allows stretching in the x direction, optional, default size
  22251. * * sizeY allows stretching in the y direction, optional, default size
  22252. * * sizeZ allows stretching in the z direction, optional, default size
  22253. * * 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
  22254. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22256. * * flat when true creates a flat shaded mesh, optional, default true
  22257. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22258. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22259. * * 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)
  22260. * * 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)
  22261. * @returns the VertexData of the Polyhedron
  22262. */
  22263. static CreatePolyhedron(options: {
  22264. type?: number;
  22265. size?: number;
  22266. sizeX?: number;
  22267. sizeY?: number;
  22268. sizeZ?: number;
  22269. custom?: any;
  22270. faceUV?: Vector4[];
  22271. faceColors?: Color4[];
  22272. flat?: boolean;
  22273. sideOrientation?: number;
  22274. frontUVs?: Vector4;
  22275. backUVs?: Vector4;
  22276. }): VertexData;
  22277. /**
  22278. * Creates the VertexData for a TorusKnot
  22279. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22280. * * radius the radius of the torus knot, optional, default 2
  22281. * * tube the thickness of the tube, optional, default 0.5
  22282. * * radialSegments the number of sides on each tube segments, optional, default 32
  22283. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22284. * * p the number of windings around the z axis, optional, default 2
  22285. * * q the number of windings around the x axis, optional, default 3
  22286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22287. * * 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)
  22288. * * 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)
  22289. * @returns the VertexData of the Torus Knot
  22290. */
  22291. static CreateTorusKnot(options: {
  22292. radius?: number;
  22293. tube?: number;
  22294. radialSegments?: number;
  22295. tubularSegments?: number;
  22296. p?: number;
  22297. q?: number;
  22298. sideOrientation?: number;
  22299. frontUVs?: Vector4;
  22300. backUVs?: Vector4;
  22301. }): VertexData;
  22302. /**
  22303. * Compute normals for given positions and indices
  22304. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22305. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22306. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22307. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22308. * * facetNormals : optional array of facet normals (vector3)
  22309. * * facetPositions : optional array of facet positions (vector3)
  22310. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22311. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22312. * * bInfo : optional bounding info, required for facetPartitioning computation
  22313. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22314. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22315. * * useRightHandedSystem: optional boolean to for right handed system computation
  22316. * * depthSort : optional boolean to enable the facet depth sort computation
  22317. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22318. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22319. */
  22320. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22321. facetNormals?: any;
  22322. facetPositions?: any;
  22323. facetPartitioning?: any;
  22324. ratio?: number;
  22325. bInfo?: any;
  22326. bbSize?: Vector3;
  22327. subDiv?: any;
  22328. useRightHandedSystem?: boolean;
  22329. depthSort?: boolean;
  22330. distanceTo?: Vector3;
  22331. depthSortedFacets?: any;
  22332. }): void;
  22333. /** @hidden */
  22334. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22335. /**
  22336. * Applies VertexData created from the imported parameters to the geometry
  22337. * @param parsedVertexData the parsed data from an imported file
  22338. * @param geometry the geometry to apply the VertexData to
  22339. */
  22340. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22341. }
  22342. }
  22343. declare module "babylonjs/Morph/morphTarget" {
  22344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22345. import { Observable } from "babylonjs/Misc/observable";
  22346. import { Nullable, FloatArray } from "babylonjs/types";
  22347. import { Scene } from "babylonjs/scene";
  22348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22349. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22350. /**
  22351. * Defines a target to use with MorphTargetManager
  22352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22353. */
  22354. export class MorphTarget implements IAnimatable {
  22355. /** defines the name of the target */
  22356. name: string;
  22357. /**
  22358. * Gets or sets the list of animations
  22359. */
  22360. animations: import("babylonjs/Animations/animation").Animation[];
  22361. private _scene;
  22362. private _positions;
  22363. private _normals;
  22364. private _tangents;
  22365. private _uvs;
  22366. private _influence;
  22367. /**
  22368. * Observable raised when the influence changes
  22369. */
  22370. onInfluenceChanged: Observable<boolean>;
  22371. /** @hidden */
  22372. _onDataLayoutChanged: Observable<void>;
  22373. /**
  22374. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22375. */
  22376. influence: number;
  22377. /**
  22378. * Gets or sets the id of the morph Target
  22379. */
  22380. id: string;
  22381. private _animationPropertiesOverride;
  22382. /**
  22383. * Gets or sets the animation properties override
  22384. */
  22385. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22386. /**
  22387. * Creates a new MorphTarget
  22388. * @param name defines the name of the target
  22389. * @param influence defines the influence to use
  22390. * @param scene defines the scene the morphtarget belongs to
  22391. */
  22392. constructor(
  22393. /** defines the name of the target */
  22394. name: string, influence?: number, scene?: Nullable<Scene>);
  22395. /**
  22396. * Gets a boolean defining if the target contains position data
  22397. */
  22398. readonly hasPositions: boolean;
  22399. /**
  22400. * Gets a boolean defining if the target contains normal data
  22401. */
  22402. readonly hasNormals: boolean;
  22403. /**
  22404. * Gets a boolean defining if the target contains tangent data
  22405. */
  22406. readonly hasTangents: boolean;
  22407. /**
  22408. * Gets a boolean defining if the target contains texture coordinates data
  22409. */
  22410. readonly hasUVs: boolean;
  22411. /**
  22412. * Affects position data to this target
  22413. * @param data defines the position data to use
  22414. */
  22415. setPositions(data: Nullable<FloatArray>): void;
  22416. /**
  22417. * Gets the position data stored in this target
  22418. * @returns a FloatArray containing the position data (or null if not present)
  22419. */
  22420. getPositions(): Nullable<FloatArray>;
  22421. /**
  22422. * Affects normal data to this target
  22423. * @param data defines the normal data to use
  22424. */
  22425. setNormals(data: Nullable<FloatArray>): void;
  22426. /**
  22427. * Gets the normal data stored in this target
  22428. * @returns a FloatArray containing the normal data (or null if not present)
  22429. */
  22430. getNormals(): Nullable<FloatArray>;
  22431. /**
  22432. * Affects tangent data to this target
  22433. * @param data defines the tangent data to use
  22434. */
  22435. setTangents(data: Nullable<FloatArray>): void;
  22436. /**
  22437. * Gets the tangent data stored in this target
  22438. * @returns a FloatArray containing the tangent data (or null if not present)
  22439. */
  22440. getTangents(): Nullable<FloatArray>;
  22441. /**
  22442. * Affects texture coordinates data to this target
  22443. * @param data defines the texture coordinates data to use
  22444. */
  22445. setUVs(data: Nullable<FloatArray>): void;
  22446. /**
  22447. * Gets the texture coordinates data stored in this target
  22448. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22449. */
  22450. getUVs(): Nullable<FloatArray>;
  22451. /**
  22452. * Serializes the current target into a Serialization object
  22453. * @returns the serialized object
  22454. */
  22455. serialize(): any;
  22456. /**
  22457. * Returns the string "MorphTarget"
  22458. * @returns "MorphTarget"
  22459. */
  22460. getClassName(): string;
  22461. /**
  22462. * Creates a new target from serialized data
  22463. * @param serializationObject defines the serialized data to use
  22464. * @returns a new MorphTarget
  22465. */
  22466. static Parse(serializationObject: any): MorphTarget;
  22467. /**
  22468. * Creates a MorphTarget from mesh data
  22469. * @param mesh defines the source mesh
  22470. * @param name defines the name to use for the new target
  22471. * @param influence defines the influence to attach to the target
  22472. * @returns a new MorphTarget
  22473. */
  22474. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22475. }
  22476. }
  22477. declare module "babylonjs/Morph/morphTargetManager" {
  22478. import { Nullable } from "babylonjs/types";
  22479. import { Scene } from "babylonjs/scene";
  22480. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22481. /**
  22482. * This class is used to deform meshes using morphing between different targets
  22483. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22484. */
  22485. export class MorphTargetManager {
  22486. private _targets;
  22487. private _targetInfluenceChangedObservers;
  22488. private _targetDataLayoutChangedObservers;
  22489. private _activeTargets;
  22490. private _scene;
  22491. private _influences;
  22492. private _supportsNormals;
  22493. private _supportsTangents;
  22494. private _supportsUVs;
  22495. private _vertexCount;
  22496. private _uniqueId;
  22497. private _tempInfluences;
  22498. /**
  22499. * Gets or sets a boolean indicating if normals must be morphed
  22500. */
  22501. enableNormalMorphing: boolean;
  22502. /**
  22503. * Gets or sets a boolean indicating if tangents must be morphed
  22504. */
  22505. enableTangentMorphing: boolean;
  22506. /**
  22507. * Gets or sets a boolean indicating if UV must be morphed
  22508. */
  22509. enableUVMorphing: boolean;
  22510. /**
  22511. * Creates a new MorphTargetManager
  22512. * @param scene defines the current scene
  22513. */
  22514. constructor(scene?: Nullable<Scene>);
  22515. /**
  22516. * Gets the unique ID of this manager
  22517. */
  22518. readonly uniqueId: number;
  22519. /**
  22520. * Gets the number of vertices handled by this manager
  22521. */
  22522. readonly vertexCount: number;
  22523. /**
  22524. * Gets a boolean indicating if this manager supports morphing of normals
  22525. */
  22526. readonly supportsNormals: boolean;
  22527. /**
  22528. * Gets a boolean indicating if this manager supports morphing of tangents
  22529. */
  22530. readonly supportsTangents: boolean;
  22531. /**
  22532. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22533. */
  22534. readonly supportsUVs: boolean;
  22535. /**
  22536. * Gets the number of targets stored in this manager
  22537. */
  22538. readonly numTargets: number;
  22539. /**
  22540. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22541. */
  22542. readonly numInfluencers: number;
  22543. /**
  22544. * Gets the list of influences (one per target)
  22545. */
  22546. readonly influences: Float32Array;
  22547. /**
  22548. * Gets the active target at specified index. An active target is a target with an influence > 0
  22549. * @param index defines the index to check
  22550. * @returns the requested target
  22551. */
  22552. getActiveTarget(index: number): MorphTarget;
  22553. /**
  22554. * Gets the target at specified index
  22555. * @param index defines the index to check
  22556. * @returns the requested target
  22557. */
  22558. getTarget(index: number): MorphTarget;
  22559. /**
  22560. * Add a new target to this manager
  22561. * @param target defines the target to add
  22562. */
  22563. addTarget(target: MorphTarget): void;
  22564. /**
  22565. * Removes a target from the manager
  22566. * @param target defines the target to remove
  22567. */
  22568. removeTarget(target: MorphTarget): void;
  22569. /**
  22570. * Serializes the current manager into a Serialization object
  22571. * @returns the serialized object
  22572. */
  22573. serialize(): any;
  22574. private _syncActiveTargets;
  22575. /**
  22576. * Syncrhonize the targets with all the meshes using this morph target manager
  22577. */
  22578. synchronize(): void;
  22579. /**
  22580. * Creates a new MorphTargetManager from serialized data
  22581. * @param serializationObject defines the serialized data
  22582. * @param scene defines the hosting scene
  22583. * @returns the new MorphTargetManager
  22584. */
  22585. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22586. }
  22587. }
  22588. declare module "babylonjs/Meshes/meshLODLevel" {
  22589. import { Mesh } from "babylonjs/Meshes/mesh";
  22590. import { Nullable } from "babylonjs/types";
  22591. /**
  22592. * Class used to represent a specific level of detail of a mesh
  22593. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22594. */
  22595. export class MeshLODLevel {
  22596. /** Defines the distance where this level should star being displayed */
  22597. distance: number;
  22598. /** Defines the mesh to use to render this level */
  22599. mesh: Nullable<Mesh>;
  22600. /**
  22601. * Creates a new LOD level
  22602. * @param distance defines the distance where this level should star being displayed
  22603. * @param mesh defines the mesh to use to render this level
  22604. */
  22605. constructor(
  22606. /** Defines the distance where this level should star being displayed */
  22607. distance: number,
  22608. /** Defines the mesh to use to render this level */
  22609. mesh: Nullable<Mesh>);
  22610. }
  22611. }
  22612. declare module "babylonjs/Meshes/groundMesh" {
  22613. import { Scene } from "babylonjs/scene";
  22614. import { Vector3 } from "babylonjs/Maths/math.vector";
  22615. import { Mesh } from "babylonjs/Meshes/mesh";
  22616. /**
  22617. * Mesh representing the gorund
  22618. */
  22619. export class GroundMesh extends Mesh {
  22620. /** If octree should be generated */
  22621. generateOctree: boolean;
  22622. private _heightQuads;
  22623. /** @hidden */
  22624. _subdivisionsX: number;
  22625. /** @hidden */
  22626. _subdivisionsY: number;
  22627. /** @hidden */
  22628. _width: number;
  22629. /** @hidden */
  22630. _height: number;
  22631. /** @hidden */
  22632. _minX: number;
  22633. /** @hidden */
  22634. _maxX: number;
  22635. /** @hidden */
  22636. _minZ: number;
  22637. /** @hidden */
  22638. _maxZ: number;
  22639. constructor(name: string, scene: Scene);
  22640. /**
  22641. * "GroundMesh"
  22642. * @returns "GroundMesh"
  22643. */
  22644. getClassName(): string;
  22645. /**
  22646. * The minimum of x and y subdivisions
  22647. */
  22648. readonly subdivisions: number;
  22649. /**
  22650. * X subdivisions
  22651. */
  22652. readonly subdivisionsX: number;
  22653. /**
  22654. * Y subdivisions
  22655. */
  22656. readonly subdivisionsY: number;
  22657. /**
  22658. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22659. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22660. * @param chunksCount the number of subdivisions for x and y
  22661. * @param octreeBlocksSize (Default: 32)
  22662. */
  22663. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22664. /**
  22665. * Returns a height (y) value in the Worl system :
  22666. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22667. * @param x x coordinate
  22668. * @param z z coordinate
  22669. * @returns the ground y position if (x, z) are outside the ground surface.
  22670. */
  22671. getHeightAtCoordinates(x: number, z: number): number;
  22672. /**
  22673. * Returns a normalized vector (Vector3) orthogonal to the ground
  22674. * at the ground coordinates (x, z) expressed in the World system.
  22675. * @param x x coordinate
  22676. * @param z z coordinate
  22677. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22678. */
  22679. getNormalAtCoordinates(x: number, z: number): Vector3;
  22680. /**
  22681. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22682. * at the ground coordinates (x, z) expressed in the World system.
  22683. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22684. * @param x x coordinate
  22685. * @param z z coordinate
  22686. * @param ref vector to store the result
  22687. * @returns the GroundMesh.
  22688. */
  22689. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22690. /**
  22691. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22692. * if the ground has been updated.
  22693. * This can be used in the render loop.
  22694. * @returns the GroundMesh.
  22695. */
  22696. updateCoordinateHeights(): GroundMesh;
  22697. private _getFacetAt;
  22698. private _initHeightQuads;
  22699. private _computeHeightQuads;
  22700. /**
  22701. * Serializes this ground mesh
  22702. * @param serializationObject object to write serialization to
  22703. */
  22704. serialize(serializationObject: any): void;
  22705. /**
  22706. * Parses a serialized ground mesh
  22707. * @param parsedMesh the serialized mesh
  22708. * @param scene the scene to create the ground mesh in
  22709. * @returns the created ground mesh
  22710. */
  22711. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22712. }
  22713. }
  22714. declare module "babylonjs/Physics/physicsJoint" {
  22715. import { Vector3 } from "babylonjs/Maths/math.vector";
  22716. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22717. /**
  22718. * Interface for Physics-Joint data
  22719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22720. */
  22721. export interface PhysicsJointData {
  22722. /**
  22723. * The main pivot of the joint
  22724. */
  22725. mainPivot?: Vector3;
  22726. /**
  22727. * The connected pivot of the joint
  22728. */
  22729. connectedPivot?: Vector3;
  22730. /**
  22731. * The main axis of the joint
  22732. */
  22733. mainAxis?: Vector3;
  22734. /**
  22735. * The connected axis of the joint
  22736. */
  22737. connectedAxis?: Vector3;
  22738. /**
  22739. * The collision of the joint
  22740. */
  22741. collision?: boolean;
  22742. /**
  22743. * Native Oimo/Cannon/Energy data
  22744. */
  22745. nativeParams?: any;
  22746. }
  22747. /**
  22748. * This is a holder class for the physics joint created by the physics plugin
  22749. * It holds a set of functions to control the underlying joint
  22750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22751. */
  22752. export class PhysicsJoint {
  22753. /**
  22754. * The type of the physics joint
  22755. */
  22756. type: number;
  22757. /**
  22758. * The data for the physics joint
  22759. */
  22760. jointData: PhysicsJointData;
  22761. private _physicsJoint;
  22762. protected _physicsPlugin: IPhysicsEnginePlugin;
  22763. /**
  22764. * Initializes the physics joint
  22765. * @param type The type of the physics joint
  22766. * @param jointData The data for the physics joint
  22767. */
  22768. constructor(
  22769. /**
  22770. * The type of the physics joint
  22771. */
  22772. type: number,
  22773. /**
  22774. * The data for the physics joint
  22775. */
  22776. jointData: PhysicsJointData);
  22777. /**
  22778. * Gets the physics joint
  22779. */
  22780. /**
  22781. * Sets the physics joint
  22782. */
  22783. physicsJoint: any;
  22784. /**
  22785. * Sets the physics plugin
  22786. */
  22787. physicsPlugin: IPhysicsEnginePlugin;
  22788. /**
  22789. * Execute a function that is physics-plugin specific.
  22790. * @param {Function} func the function that will be executed.
  22791. * It accepts two parameters: the physics world and the physics joint
  22792. */
  22793. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22794. /**
  22795. * Distance-Joint type
  22796. */
  22797. static DistanceJoint: number;
  22798. /**
  22799. * Hinge-Joint type
  22800. */
  22801. static HingeJoint: number;
  22802. /**
  22803. * Ball-and-Socket joint type
  22804. */
  22805. static BallAndSocketJoint: number;
  22806. /**
  22807. * Wheel-Joint type
  22808. */
  22809. static WheelJoint: number;
  22810. /**
  22811. * Slider-Joint type
  22812. */
  22813. static SliderJoint: number;
  22814. /**
  22815. * Prismatic-Joint type
  22816. */
  22817. static PrismaticJoint: number;
  22818. /**
  22819. * Universal-Joint type
  22820. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22821. */
  22822. static UniversalJoint: number;
  22823. /**
  22824. * Hinge-Joint 2 type
  22825. */
  22826. static Hinge2Joint: number;
  22827. /**
  22828. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22829. */
  22830. static PointToPointJoint: number;
  22831. /**
  22832. * Spring-Joint type
  22833. */
  22834. static SpringJoint: number;
  22835. /**
  22836. * Lock-Joint type
  22837. */
  22838. static LockJoint: number;
  22839. }
  22840. /**
  22841. * A class representing a physics distance joint
  22842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22843. */
  22844. export class DistanceJoint extends PhysicsJoint {
  22845. /**
  22846. *
  22847. * @param jointData The data for the Distance-Joint
  22848. */
  22849. constructor(jointData: DistanceJointData);
  22850. /**
  22851. * Update the predefined distance.
  22852. * @param maxDistance The maximum preferred distance
  22853. * @param minDistance The minimum preferred distance
  22854. */
  22855. updateDistance(maxDistance: number, minDistance?: number): void;
  22856. }
  22857. /**
  22858. * Represents a Motor-Enabled Joint
  22859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22860. */
  22861. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22862. /**
  22863. * Initializes the Motor-Enabled Joint
  22864. * @param type The type of the joint
  22865. * @param jointData The physica joint data for the joint
  22866. */
  22867. constructor(type: number, jointData: PhysicsJointData);
  22868. /**
  22869. * Set the motor values.
  22870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22871. * @param force the force to apply
  22872. * @param maxForce max force for this motor.
  22873. */
  22874. setMotor(force?: number, maxForce?: number): void;
  22875. /**
  22876. * Set the motor's limits.
  22877. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22878. * @param upperLimit The upper limit of the motor
  22879. * @param lowerLimit The lower limit of the motor
  22880. */
  22881. setLimit(upperLimit: number, lowerLimit?: number): void;
  22882. }
  22883. /**
  22884. * This class represents a single physics Hinge-Joint
  22885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22886. */
  22887. export class HingeJoint extends MotorEnabledJoint {
  22888. /**
  22889. * Initializes the Hinge-Joint
  22890. * @param jointData The joint data for the Hinge-Joint
  22891. */
  22892. constructor(jointData: PhysicsJointData);
  22893. /**
  22894. * Set the motor values.
  22895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22896. * @param {number} force the force to apply
  22897. * @param {number} maxForce max force for this motor.
  22898. */
  22899. setMotor(force?: number, maxForce?: number): void;
  22900. /**
  22901. * Set the motor's limits.
  22902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22903. * @param upperLimit The upper limit of the motor
  22904. * @param lowerLimit The lower limit of the motor
  22905. */
  22906. setLimit(upperLimit: number, lowerLimit?: number): void;
  22907. }
  22908. /**
  22909. * This class represents a dual hinge physics joint (same as wheel joint)
  22910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22911. */
  22912. export class Hinge2Joint extends MotorEnabledJoint {
  22913. /**
  22914. * Initializes the Hinge2-Joint
  22915. * @param jointData The joint data for the Hinge2-Joint
  22916. */
  22917. constructor(jointData: PhysicsJointData);
  22918. /**
  22919. * Set the motor values.
  22920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22921. * @param {number} targetSpeed the speed the motor is to reach
  22922. * @param {number} maxForce max force for this motor.
  22923. * @param {motorIndex} the motor's index, 0 or 1.
  22924. */
  22925. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22926. /**
  22927. * Set the motor limits.
  22928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22929. * @param {number} upperLimit the upper limit
  22930. * @param {number} lowerLimit lower limit
  22931. * @param {motorIndex} the motor's index, 0 or 1.
  22932. */
  22933. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22934. }
  22935. /**
  22936. * Interface for a motor enabled joint
  22937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22938. */
  22939. export interface IMotorEnabledJoint {
  22940. /**
  22941. * Physics joint
  22942. */
  22943. physicsJoint: any;
  22944. /**
  22945. * Sets the motor of the motor-enabled joint
  22946. * @param force The force of the motor
  22947. * @param maxForce The maximum force of the motor
  22948. * @param motorIndex The index of the motor
  22949. */
  22950. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22951. /**
  22952. * Sets the limit of the motor
  22953. * @param upperLimit The upper limit of the motor
  22954. * @param lowerLimit The lower limit of the motor
  22955. * @param motorIndex The index of the motor
  22956. */
  22957. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22958. }
  22959. /**
  22960. * Joint data for a Distance-Joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export interface DistanceJointData extends PhysicsJointData {
  22964. /**
  22965. * Max distance the 2 joint objects can be apart
  22966. */
  22967. maxDistance: number;
  22968. }
  22969. /**
  22970. * Joint data from a spring joint
  22971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22972. */
  22973. export interface SpringJointData extends PhysicsJointData {
  22974. /**
  22975. * Length of the spring
  22976. */
  22977. length: number;
  22978. /**
  22979. * Stiffness of the spring
  22980. */
  22981. stiffness: number;
  22982. /**
  22983. * Damping of the spring
  22984. */
  22985. damping: number;
  22986. /** this callback will be called when applying the force to the impostors. */
  22987. forceApplicationCallback: () => void;
  22988. }
  22989. }
  22990. declare module "babylonjs/Physics/physicsRaycastResult" {
  22991. import { Vector3 } from "babylonjs/Maths/math.vector";
  22992. /**
  22993. * Holds the data for the raycast result
  22994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22995. */
  22996. export class PhysicsRaycastResult {
  22997. private _hasHit;
  22998. private _hitDistance;
  22999. private _hitNormalWorld;
  23000. private _hitPointWorld;
  23001. private _rayFromWorld;
  23002. private _rayToWorld;
  23003. /**
  23004. * Gets if there was a hit
  23005. */
  23006. readonly hasHit: boolean;
  23007. /**
  23008. * Gets the distance from the hit
  23009. */
  23010. readonly hitDistance: number;
  23011. /**
  23012. * Gets the hit normal/direction in the world
  23013. */
  23014. readonly hitNormalWorld: Vector3;
  23015. /**
  23016. * Gets the hit point in the world
  23017. */
  23018. readonly hitPointWorld: Vector3;
  23019. /**
  23020. * Gets the ray "start point" of the ray in the world
  23021. */
  23022. readonly rayFromWorld: Vector3;
  23023. /**
  23024. * Gets the ray "end point" of the ray in the world
  23025. */
  23026. readonly rayToWorld: Vector3;
  23027. /**
  23028. * Sets the hit data (normal & point in world space)
  23029. * @param hitNormalWorld defines the normal in world space
  23030. * @param hitPointWorld defines the point in world space
  23031. */
  23032. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23033. /**
  23034. * Sets the distance from the start point to the hit point
  23035. * @param distance
  23036. */
  23037. setHitDistance(distance: number): void;
  23038. /**
  23039. * Calculates the distance manually
  23040. */
  23041. calculateHitDistance(): void;
  23042. /**
  23043. * Resets all the values to default
  23044. * @param from The from point on world space
  23045. * @param to The to point on world space
  23046. */
  23047. reset(from?: Vector3, to?: Vector3): void;
  23048. }
  23049. /**
  23050. * Interface for the size containing width and height
  23051. */
  23052. interface IXYZ {
  23053. /**
  23054. * X
  23055. */
  23056. x: number;
  23057. /**
  23058. * Y
  23059. */
  23060. y: number;
  23061. /**
  23062. * Z
  23063. */
  23064. z: number;
  23065. }
  23066. }
  23067. declare module "babylonjs/Physics/IPhysicsEngine" {
  23068. import { Nullable } from "babylonjs/types";
  23069. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23071. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23072. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23073. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23074. /**
  23075. * Interface used to describe a physics joint
  23076. */
  23077. export interface PhysicsImpostorJoint {
  23078. /** Defines the main impostor to which the joint is linked */
  23079. mainImpostor: PhysicsImpostor;
  23080. /** Defines the impostor that is connected to the main impostor using this joint */
  23081. connectedImpostor: PhysicsImpostor;
  23082. /** Defines the joint itself */
  23083. joint: PhysicsJoint;
  23084. }
  23085. /** @hidden */
  23086. export interface IPhysicsEnginePlugin {
  23087. world: any;
  23088. name: string;
  23089. setGravity(gravity: Vector3): void;
  23090. setTimeStep(timeStep: number): void;
  23091. getTimeStep(): number;
  23092. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23094. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23096. removePhysicsBody(impostor: PhysicsImpostor): void;
  23097. generateJoint(joint: PhysicsImpostorJoint): void;
  23098. removeJoint(joint: PhysicsImpostorJoint): void;
  23099. isSupported(): boolean;
  23100. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23101. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23102. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23103. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23104. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23105. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23106. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23107. getBodyMass(impostor: PhysicsImpostor): number;
  23108. getBodyFriction(impostor: PhysicsImpostor): number;
  23109. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23110. getBodyRestitution(impostor: PhysicsImpostor): number;
  23111. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23112. getBodyPressure?(impostor: PhysicsImpostor): number;
  23113. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23114. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23115. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23116. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23117. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23118. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23119. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23120. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23121. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23122. sleepBody(impostor: PhysicsImpostor): void;
  23123. wakeUpBody(impostor: PhysicsImpostor): void;
  23124. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23126. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23128. getRadius(impostor: PhysicsImpostor): number;
  23129. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23130. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23131. dispose(): void;
  23132. }
  23133. /**
  23134. * Interface used to define a physics engine
  23135. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23136. */
  23137. export interface IPhysicsEngine {
  23138. /**
  23139. * Gets the gravity vector used by the simulation
  23140. */
  23141. gravity: Vector3;
  23142. /**
  23143. * Sets the gravity vector used by the simulation
  23144. * @param gravity defines the gravity vector to use
  23145. */
  23146. setGravity(gravity: Vector3): void;
  23147. /**
  23148. * Set the time step of the physics engine.
  23149. * Default is 1/60.
  23150. * To slow it down, enter 1/600 for example.
  23151. * To speed it up, 1/30
  23152. * @param newTimeStep the new timestep to apply to this world.
  23153. */
  23154. setTimeStep(newTimeStep: number): void;
  23155. /**
  23156. * Get the time step of the physics engine.
  23157. * @returns the current time step
  23158. */
  23159. getTimeStep(): number;
  23160. /**
  23161. * Release all resources
  23162. */
  23163. dispose(): void;
  23164. /**
  23165. * Gets the name of the current physics plugin
  23166. * @returns the name of the plugin
  23167. */
  23168. getPhysicsPluginName(): string;
  23169. /**
  23170. * Adding a new impostor for the impostor tracking.
  23171. * This will be done by the impostor itself.
  23172. * @param impostor the impostor to add
  23173. */
  23174. addImpostor(impostor: PhysicsImpostor): void;
  23175. /**
  23176. * Remove an impostor from the engine.
  23177. * This impostor and its mesh will not longer be updated by the physics engine.
  23178. * @param impostor the impostor to remove
  23179. */
  23180. removeImpostor(impostor: PhysicsImpostor): void;
  23181. /**
  23182. * Add a joint to the physics engine
  23183. * @param mainImpostor defines the main impostor to which the joint is added.
  23184. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23185. * @param joint defines the joint that will connect both impostors.
  23186. */
  23187. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23188. /**
  23189. * Removes a joint from the simulation
  23190. * @param mainImpostor defines the impostor used with the joint
  23191. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23192. * @param joint defines the joint to remove
  23193. */
  23194. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23195. /**
  23196. * Gets the current plugin used to run the simulation
  23197. * @returns current plugin
  23198. */
  23199. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23200. /**
  23201. * Gets the list of physic impostors
  23202. * @returns an array of PhysicsImpostor
  23203. */
  23204. getImpostors(): Array<PhysicsImpostor>;
  23205. /**
  23206. * Gets the impostor for a physics enabled object
  23207. * @param object defines the object impersonated by the impostor
  23208. * @returns the PhysicsImpostor or null if not found
  23209. */
  23210. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23211. /**
  23212. * Gets the impostor for a physics body object
  23213. * @param body defines physics body used by the impostor
  23214. * @returns the PhysicsImpostor or null if not found
  23215. */
  23216. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23217. /**
  23218. * Does a raycast in the physics world
  23219. * @param from when should the ray start?
  23220. * @param to when should the ray end?
  23221. * @returns PhysicsRaycastResult
  23222. */
  23223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23224. /**
  23225. * Called by the scene. No need to call it.
  23226. * @param delta defines the timespam between frames
  23227. */
  23228. _step(delta: number): void;
  23229. }
  23230. }
  23231. declare module "babylonjs/Physics/physicsImpostor" {
  23232. import { Nullable, IndicesArray } from "babylonjs/types";
  23233. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23236. import { Scene } from "babylonjs/scene";
  23237. import { Bone } from "babylonjs/Bones/bone";
  23238. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23239. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23240. import { Space } from "babylonjs/Maths/math.axis";
  23241. /**
  23242. * The interface for the physics imposter parameters
  23243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23244. */
  23245. export interface PhysicsImpostorParameters {
  23246. /**
  23247. * The mass of the physics imposter
  23248. */
  23249. mass: number;
  23250. /**
  23251. * The friction of the physics imposter
  23252. */
  23253. friction?: number;
  23254. /**
  23255. * The coefficient of restitution of the physics imposter
  23256. */
  23257. restitution?: number;
  23258. /**
  23259. * The native options of the physics imposter
  23260. */
  23261. nativeOptions?: any;
  23262. /**
  23263. * Specifies if the parent should be ignored
  23264. */
  23265. ignoreParent?: boolean;
  23266. /**
  23267. * Specifies if bi-directional transformations should be disabled
  23268. */
  23269. disableBidirectionalTransformation?: boolean;
  23270. /**
  23271. * The pressure inside the physics imposter, soft object only
  23272. */
  23273. pressure?: number;
  23274. /**
  23275. * The stiffness the physics imposter, soft object only
  23276. */
  23277. stiffness?: number;
  23278. /**
  23279. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23280. */
  23281. velocityIterations?: number;
  23282. /**
  23283. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23284. */
  23285. positionIterations?: number;
  23286. /**
  23287. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23288. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23289. * Add to fix multiple points
  23290. */
  23291. fixedPoints?: number;
  23292. /**
  23293. * The collision margin around a soft object
  23294. */
  23295. margin?: number;
  23296. /**
  23297. * The collision margin around a soft object
  23298. */
  23299. damping?: number;
  23300. /**
  23301. * The path for a rope based on an extrusion
  23302. */
  23303. path?: any;
  23304. /**
  23305. * The shape of an extrusion used for a rope based on an extrusion
  23306. */
  23307. shape?: any;
  23308. }
  23309. /**
  23310. * Interface for a physics-enabled object
  23311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23312. */
  23313. export interface IPhysicsEnabledObject {
  23314. /**
  23315. * The position of the physics-enabled object
  23316. */
  23317. position: Vector3;
  23318. /**
  23319. * The rotation of the physics-enabled object
  23320. */
  23321. rotationQuaternion: Nullable<Quaternion>;
  23322. /**
  23323. * The scale of the physics-enabled object
  23324. */
  23325. scaling: Vector3;
  23326. /**
  23327. * The rotation of the physics-enabled object
  23328. */
  23329. rotation?: Vector3;
  23330. /**
  23331. * The parent of the physics-enabled object
  23332. */
  23333. parent?: any;
  23334. /**
  23335. * The bounding info of the physics-enabled object
  23336. * @returns The bounding info of the physics-enabled object
  23337. */
  23338. getBoundingInfo(): BoundingInfo;
  23339. /**
  23340. * Computes the world matrix
  23341. * @param force Specifies if the world matrix should be computed by force
  23342. * @returns A world matrix
  23343. */
  23344. computeWorldMatrix(force: boolean): Matrix;
  23345. /**
  23346. * Gets the world matrix
  23347. * @returns A world matrix
  23348. */
  23349. getWorldMatrix?(): Matrix;
  23350. /**
  23351. * Gets the child meshes
  23352. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23353. * @returns An array of abstract meshes
  23354. */
  23355. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23356. /**
  23357. * Gets the vertex data
  23358. * @param kind The type of vertex data
  23359. * @returns A nullable array of numbers, or a float32 array
  23360. */
  23361. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23362. /**
  23363. * Gets the indices from the mesh
  23364. * @returns A nullable array of index arrays
  23365. */
  23366. getIndices?(): Nullable<IndicesArray>;
  23367. /**
  23368. * Gets the scene from the mesh
  23369. * @returns the indices array or null
  23370. */
  23371. getScene?(): Scene;
  23372. /**
  23373. * Gets the absolute position from the mesh
  23374. * @returns the absolute position
  23375. */
  23376. getAbsolutePosition(): Vector3;
  23377. /**
  23378. * Gets the absolute pivot point from the mesh
  23379. * @returns the absolute pivot point
  23380. */
  23381. getAbsolutePivotPoint(): Vector3;
  23382. /**
  23383. * Rotates the mesh
  23384. * @param axis The axis of rotation
  23385. * @param amount The amount of rotation
  23386. * @param space The space of the rotation
  23387. * @returns The rotation transform node
  23388. */
  23389. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23390. /**
  23391. * Translates the mesh
  23392. * @param axis The axis of translation
  23393. * @param distance The distance of translation
  23394. * @param space The space of the translation
  23395. * @returns The transform node
  23396. */
  23397. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23398. /**
  23399. * Sets the absolute position of the mesh
  23400. * @param absolutePosition The absolute position of the mesh
  23401. * @returns The transform node
  23402. */
  23403. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23404. /**
  23405. * Gets the class name of the mesh
  23406. * @returns The class name
  23407. */
  23408. getClassName(): string;
  23409. }
  23410. /**
  23411. * Represents a physics imposter
  23412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23413. */
  23414. export class PhysicsImpostor {
  23415. /**
  23416. * The physics-enabled object used as the physics imposter
  23417. */
  23418. object: IPhysicsEnabledObject;
  23419. /**
  23420. * The type of the physics imposter
  23421. */
  23422. type: number;
  23423. private _options;
  23424. private _scene?;
  23425. /**
  23426. * The default object size of the imposter
  23427. */
  23428. static DEFAULT_OBJECT_SIZE: Vector3;
  23429. /**
  23430. * The identity quaternion of the imposter
  23431. */
  23432. static IDENTITY_QUATERNION: Quaternion;
  23433. /** @hidden */
  23434. _pluginData: any;
  23435. private _physicsEngine;
  23436. private _physicsBody;
  23437. private _bodyUpdateRequired;
  23438. private _onBeforePhysicsStepCallbacks;
  23439. private _onAfterPhysicsStepCallbacks;
  23440. /** @hidden */
  23441. _onPhysicsCollideCallbacks: Array<{
  23442. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23443. otherImpostors: Array<PhysicsImpostor>;
  23444. }>;
  23445. private _deltaPosition;
  23446. private _deltaRotation;
  23447. private _deltaRotationConjugated;
  23448. /** @hidden */
  23449. _isFromLine: boolean;
  23450. private _parent;
  23451. private _isDisposed;
  23452. private static _tmpVecs;
  23453. private static _tmpQuat;
  23454. /**
  23455. * Specifies if the physics imposter is disposed
  23456. */
  23457. readonly isDisposed: boolean;
  23458. /**
  23459. * Gets the mass of the physics imposter
  23460. */
  23461. mass: number;
  23462. /**
  23463. * Gets the coefficient of friction
  23464. */
  23465. /**
  23466. * Sets the coefficient of friction
  23467. */
  23468. friction: number;
  23469. /**
  23470. * Gets the coefficient of restitution
  23471. */
  23472. /**
  23473. * Sets the coefficient of restitution
  23474. */
  23475. restitution: number;
  23476. /**
  23477. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23478. */
  23479. /**
  23480. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23481. */
  23482. pressure: number;
  23483. /**
  23484. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23485. */
  23486. /**
  23487. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23488. */
  23489. stiffness: number;
  23490. /**
  23491. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23492. */
  23493. /**
  23494. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23495. */
  23496. velocityIterations: number;
  23497. /**
  23498. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23499. */
  23500. /**
  23501. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23502. */
  23503. positionIterations: number;
  23504. /**
  23505. * The unique id of the physics imposter
  23506. * set by the physics engine when adding this impostor to the array
  23507. */
  23508. uniqueId: number;
  23509. /**
  23510. * @hidden
  23511. */
  23512. soft: boolean;
  23513. /**
  23514. * @hidden
  23515. */
  23516. segments: number;
  23517. private _joints;
  23518. /**
  23519. * Initializes the physics imposter
  23520. * @param object The physics-enabled object used as the physics imposter
  23521. * @param type The type of the physics imposter
  23522. * @param _options The options for the physics imposter
  23523. * @param _scene The Babylon scene
  23524. */
  23525. constructor(
  23526. /**
  23527. * The physics-enabled object used as the physics imposter
  23528. */
  23529. object: IPhysicsEnabledObject,
  23530. /**
  23531. * The type of the physics imposter
  23532. */
  23533. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23534. /**
  23535. * This function will completly initialize this impostor.
  23536. * It will create a new body - but only if this mesh has no parent.
  23537. * If it has, this impostor will not be used other than to define the impostor
  23538. * of the child mesh.
  23539. * @hidden
  23540. */
  23541. _init(): void;
  23542. private _getPhysicsParent;
  23543. /**
  23544. * Should a new body be generated.
  23545. * @returns boolean specifying if body initialization is required
  23546. */
  23547. isBodyInitRequired(): boolean;
  23548. /**
  23549. * Sets the updated scaling
  23550. * @param updated Specifies if the scaling is updated
  23551. */
  23552. setScalingUpdated(): void;
  23553. /**
  23554. * Force a regeneration of this or the parent's impostor's body.
  23555. * Use under cautious - This will remove all joints already implemented.
  23556. */
  23557. forceUpdate(): void;
  23558. /**
  23559. * Gets the body that holds this impostor. Either its own, or its parent.
  23560. */
  23561. /**
  23562. * Set the physics body. Used mainly by the physics engine/plugin
  23563. */
  23564. physicsBody: any;
  23565. /**
  23566. * Get the parent of the physics imposter
  23567. * @returns Physics imposter or null
  23568. */
  23569. /**
  23570. * Sets the parent of the physics imposter
  23571. */
  23572. parent: Nullable<PhysicsImpostor>;
  23573. /**
  23574. * Resets the update flags
  23575. */
  23576. resetUpdateFlags(): void;
  23577. /**
  23578. * Gets the object extend size
  23579. * @returns the object extend size
  23580. */
  23581. getObjectExtendSize(): Vector3;
  23582. /**
  23583. * Gets the object center
  23584. * @returns The object center
  23585. */
  23586. getObjectCenter(): Vector3;
  23587. /**
  23588. * Get a specific parametes from the options parameter
  23589. * @param paramName The object parameter name
  23590. * @returns The object parameter
  23591. */
  23592. getParam(paramName: string): any;
  23593. /**
  23594. * Sets a specific parameter in the options given to the physics plugin
  23595. * @param paramName The parameter name
  23596. * @param value The value of the parameter
  23597. */
  23598. setParam(paramName: string, value: number): void;
  23599. /**
  23600. * Specifically change the body's mass option. Won't recreate the physics body object
  23601. * @param mass The mass of the physics imposter
  23602. */
  23603. setMass(mass: number): void;
  23604. /**
  23605. * Gets the linear velocity
  23606. * @returns linear velocity or null
  23607. */
  23608. getLinearVelocity(): Nullable<Vector3>;
  23609. /**
  23610. * Sets the linear velocity
  23611. * @param velocity linear velocity or null
  23612. */
  23613. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23614. /**
  23615. * Gets the angular velocity
  23616. * @returns angular velocity or null
  23617. */
  23618. getAngularVelocity(): Nullable<Vector3>;
  23619. /**
  23620. * Sets the angular velocity
  23621. * @param velocity The velocity or null
  23622. */
  23623. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23624. /**
  23625. * Execute a function with the physics plugin native code
  23626. * Provide a function the will have two variables - the world object and the physics body object
  23627. * @param func The function to execute with the physics plugin native code
  23628. */
  23629. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23630. /**
  23631. * Register a function that will be executed before the physics world is stepping forward
  23632. * @param func The function to execute before the physics world is stepped forward
  23633. */
  23634. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23635. /**
  23636. * Unregister a function that will be executed before the physics world is stepping forward
  23637. * @param func The function to execute before the physics world is stepped forward
  23638. */
  23639. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23640. /**
  23641. * Register a function that will be executed after the physics step
  23642. * @param func The function to execute after physics step
  23643. */
  23644. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23645. /**
  23646. * Unregisters a function that will be executed after the physics step
  23647. * @param func The function to execute after physics step
  23648. */
  23649. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23650. /**
  23651. * register a function that will be executed when this impostor collides against a different body
  23652. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23653. * @param func Callback that is executed on collision
  23654. */
  23655. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23656. /**
  23657. * Unregisters the physics imposter on contact
  23658. * @param collideAgainst The physics object to collide against
  23659. * @param func Callback to execute on collision
  23660. */
  23661. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23662. private _tmpQuat;
  23663. private _tmpQuat2;
  23664. /**
  23665. * Get the parent rotation
  23666. * @returns The parent rotation
  23667. */
  23668. getParentsRotation(): Quaternion;
  23669. /**
  23670. * this function is executed by the physics engine.
  23671. */
  23672. beforeStep: () => void;
  23673. /**
  23674. * this function is executed by the physics engine
  23675. */
  23676. afterStep: () => void;
  23677. /**
  23678. * Legacy collision detection event support
  23679. */
  23680. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23681. /**
  23682. * event and body object due to cannon's event-based architecture.
  23683. */
  23684. onCollide: (e: {
  23685. body: any;
  23686. }) => void;
  23687. /**
  23688. * Apply a force
  23689. * @param force The force to apply
  23690. * @param contactPoint The contact point for the force
  23691. * @returns The physics imposter
  23692. */
  23693. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23694. /**
  23695. * Apply an impulse
  23696. * @param force The impulse force
  23697. * @param contactPoint The contact point for the impulse force
  23698. * @returns The physics imposter
  23699. */
  23700. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23701. /**
  23702. * A help function to create a joint
  23703. * @param otherImpostor A physics imposter used to create a joint
  23704. * @param jointType The type of joint
  23705. * @param jointData The data for the joint
  23706. * @returns The physics imposter
  23707. */
  23708. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23709. /**
  23710. * Add a joint to this impostor with a different impostor
  23711. * @param otherImpostor A physics imposter used to add a joint
  23712. * @param joint The joint to add
  23713. * @returns The physics imposter
  23714. */
  23715. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23716. /**
  23717. * Add an anchor to a cloth impostor
  23718. * @param otherImpostor rigid impostor to anchor to
  23719. * @param width ratio across width from 0 to 1
  23720. * @param height ratio up height from 0 to 1
  23721. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23722. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23723. * @returns impostor the soft imposter
  23724. */
  23725. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23726. /**
  23727. * Add a hook to a rope impostor
  23728. * @param otherImpostor rigid impostor to anchor to
  23729. * @param length ratio across rope from 0 to 1
  23730. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23731. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23732. * @returns impostor the rope imposter
  23733. */
  23734. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23735. /**
  23736. * Will keep this body still, in a sleep mode.
  23737. * @returns the physics imposter
  23738. */
  23739. sleep(): PhysicsImpostor;
  23740. /**
  23741. * Wake the body up.
  23742. * @returns The physics imposter
  23743. */
  23744. wakeUp(): PhysicsImpostor;
  23745. /**
  23746. * Clones the physics imposter
  23747. * @param newObject The physics imposter clones to this physics-enabled object
  23748. * @returns A nullable physics imposter
  23749. */
  23750. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23751. /**
  23752. * Disposes the physics imposter
  23753. */
  23754. dispose(): void;
  23755. /**
  23756. * Sets the delta position
  23757. * @param position The delta position amount
  23758. */
  23759. setDeltaPosition(position: Vector3): void;
  23760. /**
  23761. * Sets the delta rotation
  23762. * @param rotation The delta rotation amount
  23763. */
  23764. setDeltaRotation(rotation: Quaternion): void;
  23765. /**
  23766. * Gets the box size of the physics imposter and stores the result in the input parameter
  23767. * @param result Stores the box size
  23768. * @returns The physics imposter
  23769. */
  23770. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23771. /**
  23772. * Gets the radius of the physics imposter
  23773. * @returns Radius of the physics imposter
  23774. */
  23775. getRadius(): number;
  23776. /**
  23777. * Sync a bone with this impostor
  23778. * @param bone The bone to sync to the impostor.
  23779. * @param boneMesh The mesh that the bone is influencing.
  23780. * @param jointPivot The pivot of the joint / bone in local space.
  23781. * @param distToJoint Optional distance from the impostor to the joint.
  23782. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23783. */
  23784. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23785. /**
  23786. * Sync impostor to a bone
  23787. * @param bone The bone that the impostor will be synced to.
  23788. * @param boneMesh The mesh that the bone is influencing.
  23789. * @param jointPivot The pivot of the joint / bone in local space.
  23790. * @param distToJoint Optional distance from the impostor to the joint.
  23791. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23792. * @param boneAxis Optional vector3 axis the bone is aligned with
  23793. */
  23794. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23795. /**
  23796. * No-Imposter type
  23797. */
  23798. static NoImpostor: number;
  23799. /**
  23800. * Sphere-Imposter type
  23801. */
  23802. static SphereImpostor: number;
  23803. /**
  23804. * Box-Imposter type
  23805. */
  23806. static BoxImpostor: number;
  23807. /**
  23808. * Plane-Imposter type
  23809. */
  23810. static PlaneImpostor: number;
  23811. /**
  23812. * Mesh-imposter type
  23813. */
  23814. static MeshImpostor: number;
  23815. /**
  23816. * Capsule-Impostor type (Ammo.js plugin only)
  23817. */
  23818. static CapsuleImpostor: number;
  23819. /**
  23820. * Cylinder-Imposter type
  23821. */
  23822. static CylinderImpostor: number;
  23823. /**
  23824. * Particle-Imposter type
  23825. */
  23826. static ParticleImpostor: number;
  23827. /**
  23828. * Heightmap-Imposter type
  23829. */
  23830. static HeightmapImpostor: number;
  23831. /**
  23832. * ConvexHull-Impostor type (Ammo.js plugin only)
  23833. */
  23834. static ConvexHullImpostor: number;
  23835. /**
  23836. * Rope-Imposter type
  23837. */
  23838. static RopeImpostor: number;
  23839. /**
  23840. * Cloth-Imposter type
  23841. */
  23842. static ClothImpostor: number;
  23843. /**
  23844. * Softbody-Imposter type
  23845. */
  23846. static SoftbodyImpostor: number;
  23847. }
  23848. }
  23849. declare module "babylonjs/Meshes/mesh" {
  23850. import { Observable } from "babylonjs/Misc/observable";
  23851. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23852. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23853. import { Camera } from "babylonjs/Cameras/camera";
  23854. import { Scene } from "babylonjs/scene";
  23855. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23856. import { Color4 } from "babylonjs/Maths/math.color";
  23857. import { Engine } from "babylonjs/Engines/engine";
  23858. import { Node } from "babylonjs/node";
  23859. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23860. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23861. import { Buffer } from "babylonjs/Meshes/buffer";
  23862. import { Geometry } from "babylonjs/Meshes/geometry";
  23863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23865. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23866. import { Effect } from "babylonjs/Materials/effect";
  23867. import { Material } from "babylonjs/Materials/material";
  23868. import { Skeleton } from "babylonjs/Bones/skeleton";
  23869. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23870. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23871. import { Path3D } from "babylonjs/Maths/math.path";
  23872. import { Plane } from "babylonjs/Maths/math.plane";
  23873. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23874. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23875. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23876. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23877. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23878. /**
  23879. * @hidden
  23880. **/
  23881. export class _CreationDataStorage {
  23882. closePath?: boolean;
  23883. closeArray?: boolean;
  23884. idx: number[];
  23885. dashSize: number;
  23886. gapSize: number;
  23887. path3D: Path3D;
  23888. pathArray: Vector3[][];
  23889. arc: number;
  23890. radius: number;
  23891. cap: number;
  23892. tessellation: number;
  23893. }
  23894. /**
  23895. * @hidden
  23896. **/
  23897. class _InstanceDataStorage {
  23898. visibleInstances: any;
  23899. batchCache: _InstancesBatch;
  23900. instancesBufferSize: number;
  23901. instancesBuffer: Nullable<Buffer>;
  23902. instancesData: Float32Array;
  23903. overridenInstanceCount: number;
  23904. isFrozen: boolean;
  23905. previousBatch: Nullable<_InstancesBatch>;
  23906. hardwareInstancedRendering: boolean;
  23907. sideOrientation: number;
  23908. }
  23909. /**
  23910. * @hidden
  23911. **/
  23912. export class _InstancesBatch {
  23913. mustReturn: boolean;
  23914. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23915. renderSelf: boolean[];
  23916. hardwareInstancedRendering: boolean[];
  23917. }
  23918. /**
  23919. * Class used to represent renderable models
  23920. */
  23921. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23922. /**
  23923. * Mesh side orientation : usually the external or front surface
  23924. */
  23925. static readonly FRONTSIDE: number;
  23926. /**
  23927. * Mesh side orientation : usually the internal or back surface
  23928. */
  23929. static readonly BACKSIDE: number;
  23930. /**
  23931. * Mesh side orientation : both internal and external or front and back surfaces
  23932. */
  23933. static readonly DOUBLESIDE: number;
  23934. /**
  23935. * Mesh side orientation : by default, `FRONTSIDE`
  23936. */
  23937. static readonly DEFAULTSIDE: number;
  23938. /**
  23939. * Mesh cap setting : no cap
  23940. */
  23941. static readonly NO_CAP: number;
  23942. /**
  23943. * Mesh cap setting : one cap at the beginning of the mesh
  23944. */
  23945. static readonly CAP_START: number;
  23946. /**
  23947. * Mesh cap setting : one cap at the end of the mesh
  23948. */
  23949. static readonly CAP_END: number;
  23950. /**
  23951. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23952. */
  23953. static readonly CAP_ALL: number;
  23954. /**
  23955. * Mesh pattern setting : no flip or rotate
  23956. */
  23957. static readonly NO_FLIP: number;
  23958. /**
  23959. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23960. */
  23961. static readonly FLIP_TILE: number;
  23962. /**
  23963. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23964. */
  23965. static readonly ROTATE_TILE: number;
  23966. /**
  23967. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23968. */
  23969. static readonly FLIP_ROW: number;
  23970. /**
  23971. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23972. */
  23973. static readonly ROTATE_ROW: number;
  23974. /**
  23975. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23976. */
  23977. static readonly FLIP_N_ROTATE_TILE: number;
  23978. /**
  23979. * Mesh pattern setting : rotate pattern and rotate
  23980. */
  23981. static readonly FLIP_N_ROTATE_ROW: number;
  23982. /**
  23983. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23984. */
  23985. static readonly CENTER: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles on left
  23988. */
  23989. static readonly LEFT: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on right
  23992. */
  23993. static readonly RIGHT: number;
  23994. /**
  23995. * Mesh tile positioning : part tiles on top
  23996. */
  23997. static readonly TOP: number;
  23998. /**
  23999. * Mesh tile positioning : part tiles on bottom
  24000. */
  24001. static readonly BOTTOM: number;
  24002. /**
  24003. * Gets the default side orientation.
  24004. * @param orientation the orientation to value to attempt to get
  24005. * @returns the default orientation
  24006. * @hidden
  24007. */
  24008. static _GetDefaultSideOrientation(orientation?: number): number;
  24009. private _internalMeshDataInfo;
  24010. /**
  24011. * An event triggered before rendering the mesh
  24012. */
  24013. readonly onBeforeRenderObservable: Observable<Mesh>;
  24014. /**
  24015. * An event triggered before binding the mesh
  24016. */
  24017. readonly onBeforeBindObservable: Observable<Mesh>;
  24018. /**
  24019. * An event triggered after rendering the mesh
  24020. */
  24021. readonly onAfterRenderObservable: Observable<Mesh>;
  24022. /**
  24023. * An event triggered before drawing the mesh
  24024. */
  24025. readonly onBeforeDrawObservable: Observable<Mesh>;
  24026. private _onBeforeDrawObserver;
  24027. /**
  24028. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24029. */
  24030. onBeforeDraw: () => void;
  24031. /**
  24032. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24033. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24034. */
  24035. delayLoadState: number;
  24036. /**
  24037. * Gets the list of instances created from this mesh
  24038. * it is not supposed to be modified manually.
  24039. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24040. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24041. */
  24042. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24043. /**
  24044. * Gets the file containing delay loading data for this mesh
  24045. */
  24046. delayLoadingFile: string;
  24047. /** @hidden */
  24048. _binaryInfo: any;
  24049. /**
  24050. * User defined function used to change how LOD level selection is done
  24051. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24052. */
  24053. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24054. /**
  24055. * Gets or sets the morph target manager
  24056. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24057. */
  24058. morphTargetManager: Nullable<MorphTargetManager>;
  24059. /** @hidden */
  24060. _creationDataStorage: Nullable<_CreationDataStorage>;
  24061. /** @hidden */
  24062. _geometry: Nullable<Geometry>;
  24063. /** @hidden */
  24064. _delayInfo: Array<string>;
  24065. /** @hidden */
  24066. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24067. /** @hidden */
  24068. _instanceDataStorage: _InstanceDataStorage;
  24069. private _effectiveMaterial;
  24070. /** @hidden */
  24071. _shouldGenerateFlatShading: boolean;
  24072. /** @hidden */
  24073. _originalBuilderSideOrientation: number;
  24074. /**
  24075. * Use this property to change the original side orientation defined at construction time
  24076. */
  24077. overrideMaterialSideOrientation: Nullable<number>;
  24078. /**
  24079. * Gets the source mesh (the one used to clone this one from)
  24080. */
  24081. readonly source: Nullable<Mesh>;
  24082. /**
  24083. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24084. */
  24085. isUnIndexed: boolean;
  24086. /**
  24087. * @constructor
  24088. * @param name The value used by scene.getMeshByName() to do a lookup.
  24089. * @param scene The scene to add this mesh to.
  24090. * @param parent The parent of this mesh, if it has one
  24091. * @param source An optional Mesh from which geometry is shared, cloned.
  24092. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24093. * When false, achieved by calling a clone(), also passing False.
  24094. * This will make creation of children, recursive.
  24095. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24096. */
  24097. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24098. /**
  24099. * Gets the class name
  24100. * @returns the string "Mesh".
  24101. */
  24102. getClassName(): string;
  24103. /** @hidden */
  24104. readonly _isMesh: boolean;
  24105. /**
  24106. * Returns a description of this mesh
  24107. * @param fullDetails define if full details about this mesh must be used
  24108. * @returns a descriptive string representing this mesh
  24109. */
  24110. toString(fullDetails?: boolean): string;
  24111. /** @hidden */
  24112. _unBindEffect(): void;
  24113. /**
  24114. * Gets a boolean indicating if this mesh has LOD
  24115. */
  24116. readonly hasLODLevels: boolean;
  24117. /**
  24118. * Gets the list of MeshLODLevel associated with the current mesh
  24119. * @returns an array of MeshLODLevel
  24120. */
  24121. getLODLevels(): MeshLODLevel[];
  24122. private _sortLODLevels;
  24123. /**
  24124. * Add a mesh as LOD level triggered at the given distance.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24126. * @param distance The distance from the center of the object to show this level
  24127. * @param mesh The mesh to be added as LOD level (can be null)
  24128. * @return This mesh (for chaining)
  24129. */
  24130. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24131. /**
  24132. * Returns the LOD level mesh at the passed distance or null if not found.
  24133. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24134. * @param distance The distance from the center of the object to show this level
  24135. * @returns a Mesh or `null`
  24136. */
  24137. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24138. /**
  24139. * Remove a mesh from the LOD array
  24140. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24141. * @param mesh defines the mesh to be removed
  24142. * @return This mesh (for chaining)
  24143. */
  24144. removeLODLevel(mesh: Mesh): Mesh;
  24145. /**
  24146. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24147. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24148. * @param camera defines the camera to use to compute distance
  24149. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24150. * @return This mesh (for chaining)
  24151. */
  24152. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24153. /**
  24154. * Gets the mesh internal Geometry object
  24155. */
  24156. readonly geometry: Nullable<Geometry>;
  24157. /**
  24158. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24159. * @returns the total number of vertices
  24160. */
  24161. getTotalVertices(): number;
  24162. /**
  24163. * Returns the content of an associated vertex buffer
  24164. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24165. * - VertexBuffer.PositionKind
  24166. * - VertexBuffer.UVKind
  24167. * - VertexBuffer.UV2Kind
  24168. * - VertexBuffer.UV3Kind
  24169. * - VertexBuffer.UV4Kind
  24170. * - VertexBuffer.UV5Kind
  24171. * - VertexBuffer.UV6Kind
  24172. * - VertexBuffer.ColorKind
  24173. * - VertexBuffer.MatricesIndicesKind
  24174. * - VertexBuffer.MatricesIndicesExtraKind
  24175. * - VertexBuffer.MatricesWeightsKind
  24176. * - VertexBuffer.MatricesWeightsExtraKind
  24177. * @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
  24178. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24179. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24180. */
  24181. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24182. /**
  24183. * Returns the mesh VertexBuffer object from the requested `kind`
  24184. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24185. * - VertexBuffer.PositionKind
  24186. * - VertexBuffer.NormalKind
  24187. * - VertexBuffer.UVKind
  24188. * - VertexBuffer.UV2Kind
  24189. * - VertexBuffer.UV3Kind
  24190. * - VertexBuffer.UV4Kind
  24191. * - VertexBuffer.UV5Kind
  24192. * - VertexBuffer.UV6Kind
  24193. * - VertexBuffer.ColorKind
  24194. * - VertexBuffer.MatricesIndicesKind
  24195. * - VertexBuffer.MatricesIndicesExtraKind
  24196. * - VertexBuffer.MatricesWeightsKind
  24197. * - VertexBuffer.MatricesWeightsExtraKind
  24198. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24199. */
  24200. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24201. /**
  24202. * Tests if a specific vertex buffer is associated with this mesh
  24203. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24204. * - VertexBuffer.PositionKind
  24205. * - VertexBuffer.NormalKind
  24206. * - VertexBuffer.UVKind
  24207. * - VertexBuffer.UV2Kind
  24208. * - VertexBuffer.UV3Kind
  24209. * - VertexBuffer.UV4Kind
  24210. * - VertexBuffer.UV5Kind
  24211. * - VertexBuffer.UV6Kind
  24212. * - VertexBuffer.ColorKind
  24213. * - VertexBuffer.MatricesIndicesKind
  24214. * - VertexBuffer.MatricesIndicesExtraKind
  24215. * - VertexBuffer.MatricesWeightsKind
  24216. * - VertexBuffer.MatricesWeightsExtraKind
  24217. * @returns a boolean
  24218. */
  24219. isVerticesDataPresent(kind: string): boolean;
  24220. /**
  24221. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24222. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24223. * - VertexBuffer.PositionKind
  24224. * - VertexBuffer.UVKind
  24225. * - VertexBuffer.UV2Kind
  24226. * - VertexBuffer.UV3Kind
  24227. * - VertexBuffer.UV4Kind
  24228. * - VertexBuffer.UV5Kind
  24229. * - VertexBuffer.UV6Kind
  24230. * - VertexBuffer.ColorKind
  24231. * - VertexBuffer.MatricesIndicesKind
  24232. * - VertexBuffer.MatricesIndicesExtraKind
  24233. * - VertexBuffer.MatricesWeightsKind
  24234. * - VertexBuffer.MatricesWeightsExtraKind
  24235. * @returns a boolean
  24236. */
  24237. isVertexBufferUpdatable(kind: string): boolean;
  24238. /**
  24239. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24240. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24241. * - VertexBuffer.PositionKind
  24242. * - VertexBuffer.NormalKind
  24243. * - VertexBuffer.UVKind
  24244. * - VertexBuffer.UV2Kind
  24245. * - VertexBuffer.UV3Kind
  24246. * - VertexBuffer.UV4Kind
  24247. * - VertexBuffer.UV5Kind
  24248. * - VertexBuffer.UV6Kind
  24249. * - VertexBuffer.ColorKind
  24250. * - VertexBuffer.MatricesIndicesKind
  24251. * - VertexBuffer.MatricesIndicesExtraKind
  24252. * - VertexBuffer.MatricesWeightsKind
  24253. * - VertexBuffer.MatricesWeightsExtraKind
  24254. * @returns an array of strings
  24255. */
  24256. getVerticesDataKinds(): string[];
  24257. /**
  24258. * Returns a positive integer : the total number of indices in this mesh geometry.
  24259. * @returns the numner of indices or zero if the mesh has no geometry.
  24260. */
  24261. getTotalIndices(): number;
  24262. /**
  24263. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24264. * @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.
  24265. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24266. * @returns the indices array or an empty array if the mesh has no geometry
  24267. */
  24268. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24269. readonly isBlocked: boolean;
  24270. /**
  24271. * Determine if the current mesh is ready to be rendered
  24272. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24273. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24274. * @returns true if all associated assets are ready (material, textures, shaders)
  24275. */
  24276. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24277. /**
  24278. * 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.
  24279. */
  24280. readonly areNormalsFrozen: boolean;
  24281. /**
  24282. * 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.
  24283. * @returns the current mesh
  24284. */
  24285. freezeNormals(): Mesh;
  24286. /**
  24287. * 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
  24288. * @returns the current mesh
  24289. */
  24290. unfreezeNormals(): Mesh;
  24291. /**
  24292. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24293. */
  24294. overridenInstanceCount: number;
  24295. /** @hidden */
  24296. _preActivate(): Mesh;
  24297. /** @hidden */
  24298. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24299. /** @hidden */
  24300. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24301. /**
  24302. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24303. * This means the mesh underlying bounding box and sphere are recomputed.
  24304. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24305. * @returns the current mesh
  24306. */
  24307. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24308. /** @hidden */
  24309. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24310. /**
  24311. * This function will subdivide the mesh into multiple submeshes
  24312. * @param count defines the expected number of submeshes
  24313. */
  24314. subdivide(count: number): void;
  24315. /**
  24316. * Copy a FloatArray into a specific associated vertex buffer
  24317. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24318. * - VertexBuffer.PositionKind
  24319. * - VertexBuffer.UVKind
  24320. * - VertexBuffer.UV2Kind
  24321. * - VertexBuffer.UV3Kind
  24322. * - VertexBuffer.UV4Kind
  24323. * - VertexBuffer.UV5Kind
  24324. * - VertexBuffer.UV6Kind
  24325. * - VertexBuffer.ColorKind
  24326. * - VertexBuffer.MatricesIndicesKind
  24327. * - VertexBuffer.MatricesIndicesExtraKind
  24328. * - VertexBuffer.MatricesWeightsKind
  24329. * - VertexBuffer.MatricesWeightsExtraKind
  24330. * @param data defines the data source
  24331. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24332. * @param stride defines the data stride size (can be null)
  24333. * @returns the current mesh
  24334. */
  24335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24336. /**
  24337. * Flags an associated vertex buffer as updatable
  24338. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24352. */
  24353. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24354. /**
  24355. * Sets the mesh global Vertex Buffer
  24356. * @param buffer defines the buffer to use
  24357. * @returns the current mesh
  24358. */
  24359. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24360. /**
  24361. * Update a specific associated vertex buffer
  24362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24363. * - VertexBuffer.PositionKind
  24364. * - VertexBuffer.UVKind
  24365. * - VertexBuffer.UV2Kind
  24366. * - VertexBuffer.UV3Kind
  24367. * - VertexBuffer.UV4Kind
  24368. * - VertexBuffer.UV5Kind
  24369. * - VertexBuffer.UV6Kind
  24370. * - VertexBuffer.ColorKind
  24371. * - VertexBuffer.MatricesIndicesKind
  24372. * - VertexBuffer.MatricesIndicesExtraKind
  24373. * - VertexBuffer.MatricesWeightsKind
  24374. * - VertexBuffer.MatricesWeightsExtraKind
  24375. * @param data defines the data source
  24376. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24377. * @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)
  24378. * @returns the current mesh
  24379. */
  24380. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24381. /**
  24382. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24383. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24384. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24385. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24386. * @returns the current mesh
  24387. */
  24388. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24389. /**
  24390. * Creates a un-shared specific occurence of the geometry for the mesh.
  24391. * @returns the current mesh
  24392. */
  24393. makeGeometryUnique(): Mesh;
  24394. /**
  24395. * Set the index buffer of this mesh
  24396. * @param indices defines the source data
  24397. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24398. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24399. * @returns the current mesh
  24400. */
  24401. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24402. /**
  24403. * Update the current index buffer
  24404. * @param indices defines the source data
  24405. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24406. * @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)
  24407. * @returns the current mesh
  24408. */
  24409. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24410. /**
  24411. * Invert the geometry to move from a right handed system to a left handed one.
  24412. * @returns the current mesh
  24413. */
  24414. toLeftHanded(): Mesh;
  24415. /** @hidden */
  24416. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24417. /** @hidden */
  24418. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24419. /**
  24420. * Registers for this mesh a javascript function called just before the rendering process
  24421. * @param func defines the function to call before rendering this mesh
  24422. * @returns the current mesh
  24423. */
  24424. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24425. /**
  24426. * Disposes a previously registered javascript function called before the rendering
  24427. * @param func defines the function to remove
  24428. * @returns the current mesh
  24429. */
  24430. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24431. /**
  24432. * Registers for this mesh a javascript function called just after the rendering is complete
  24433. * @param func defines the function to call after rendering this mesh
  24434. * @returns the current mesh
  24435. */
  24436. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24437. /**
  24438. * Disposes a previously registered javascript function called after the rendering.
  24439. * @param func defines the function to remove
  24440. * @returns the current mesh
  24441. */
  24442. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24443. /** @hidden */
  24444. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24445. /** @hidden */
  24446. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24447. /** @hidden */
  24448. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24449. /** @hidden */
  24450. _rebuild(): void;
  24451. /** @hidden */
  24452. _freeze(): void;
  24453. /** @hidden */
  24454. _unFreeze(): void;
  24455. /**
  24456. * 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
  24457. * @param subMesh defines the subMesh to render
  24458. * @param enableAlphaMode defines if alpha mode can be changed
  24459. * @returns the current mesh
  24460. */
  24461. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24462. private _onBeforeDraw;
  24463. /**
  24464. * Renormalize the mesh and patch it up if there are no weights
  24465. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24466. * However in the case of zero weights then we set just a single influence to 1.
  24467. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24468. */
  24469. cleanMatrixWeights(): void;
  24470. private normalizeSkinFourWeights;
  24471. private normalizeSkinWeightsAndExtra;
  24472. /**
  24473. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24474. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24475. * the user know there was an issue with importing the mesh
  24476. * @returns a validation object with skinned, valid and report string
  24477. */
  24478. validateSkinning(): {
  24479. skinned: boolean;
  24480. valid: boolean;
  24481. report: string;
  24482. };
  24483. /** @hidden */
  24484. _checkDelayState(): Mesh;
  24485. private _queueLoad;
  24486. /**
  24487. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24488. * A mesh is in the frustum if its bounding box intersects the frustum
  24489. * @param frustumPlanes defines the frustum to test
  24490. * @returns true if the mesh is in the frustum planes
  24491. */
  24492. isInFrustum(frustumPlanes: Plane[]): boolean;
  24493. /**
  24494. * Sets the mesh material by the material or multiMaterial `id` property
  24495. * @param id is a string identifying the material or the multiMaterial
  24496. * @returns the current mesh
  24497. */
  24498. setMaterialByID(id: string): Mesh;
  24499. /**
  24500. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24501. * @returns an array of IAnimatable
  24502. */
  24503. getAnimatables(): IAnimatable[];
  24504. /**
  24505. * Modifies the mesh geometry according to the passed transformation matrix.
  24506. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24507. * The mesh normals are modified using the same transformation.
  24508. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24509. * @param transform defines the transform matrix to use
  24510. * @see http://doc.babylonjs.com/resources/baking_transformations
  24511. * @returns the current mesh
  24512. */
  24513. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24514. /**
  24515. * Modifies the mesh geometry according to its own current World Matrix.
  24516. * The mesh World Matrix is then reset.
  24517. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24518. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24519. * @see http://doc.babylonjs.com/resources/baking_transformations
  24520. * @returns the current mesh
  24521. */
  24522. bakeCurrentTransformIntoVertices(): Mesh;
  24523. /** @hidden */
  24524. readonly _positions: Nullable<Vector3[]>;
  24525. /** @hidden */
  24526. _resetPointsArrayCache(): Mesh;
  24527. /** @hidden */
  24528. _generatePointsArray(): boolean;
  24529. /**
  24530. * Returns a new Mesh object generated from the current mesh properties.
  24531. * This method must not get confused with createInstance()
  24532. * @param name is a string, the name given to the new mesh
  24533. * @param newParent can be any Node object (default `null`)
  24534. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24535. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24536. * @returns a new mesh
  24537. */
  24538. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24539. /**
  24540. * Releases resources associated with this mesh.
  24541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24543. */
  24544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24545. /**
  24546. * Modifies the mesh geometry according to a displacement map.
  24547. * 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.
  24548. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24549. * @param url is a string, the URL from the image file is to be downloaded.
  24550. * @param minHeight is the lower limit of the displacement.
  24551. * @param maxHeight is the upper limit of the displacement.
  24552. * @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.
  24553. * @param uvOffset is an optional vector2 used to offset UV.
  24554. * @param uvScale is an optional vector2 used to scale UV.
  24555. * @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.
  24556. * @returns the Mesh.
  24557. */
  24558. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24559. /**
  24560. * Modifies the mesh geometry according to a displacementMap buffer.
  24561. * 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.
  24562. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24563. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24564. * @param heightMapWidth is the width of the buffer image.
  24565. * @param heightMapHeight is the height of the buffer image.
  24566. * @param minHeight is the lower limit of the displacement.
  24567. * @param maxHeight is the upper limit of the displacement.
  24568. * @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.
  24569. * @param uvOffset is an optional vector2 used to offset UV.
  24570. * @param uvScale is an optional vector2 used to scale UV.
  24571. * @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.
  24572. * @returns the Mesh.
  24573. */
  24574. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24575. /**
  24576. * Modify the mesh to get a flat shading rendering.
  24577. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24578. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24579. * @returns current mesh
  24580. */
  24581. convertToFlatShadedMesh(): Mesh;
  24582. /**
  24583. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24584. * In other words, more vertices, no more indices and a single bigger VBO.
  24585. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24586. * @returns current mesh
  24587. */
  24588. convertToUnIndexedMesh(): Mesh;
  24589. /**
  24590. * Inverses facet orientations.
  24591. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24592. * @param flipNormals will also inverts the normals
  24593. * @returns current mesh
  24594. */
  24595. flipFaces(flipNormals?: boolean): Mesh;
  24596. /**
  24597. * Increase the number of facets and hence vertices in a mesh
  24598. * Vertex normals are interpolated from existing vertex normals
  24599. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24600. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24601. */
  24602. increaseVertices(numberPerEdge: number): void;
  24603. /**
  24604. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24605. * This will undo any application of covertToFlatShadedMesh
  24606. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24607. */
  24608. forceSharedVertices(): void;
  24609. /** @hidden */
  24610. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24611. /** @hidden */
  24612. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24613. /**
  24614. * Creates a new InstancedMesh object from the mesh model.
  24615. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24616. * @param name defines the name of the new instance
  24617. * @returns a new InstancedMesh
  24618. */
  24619. createInstance(name: string): InstancedMesh;
  24620. /**
  24621. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24622. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24623. * @returns the current mesh
  24624. */
  24625. synchronizeInstances(): Mesh;
  24626. /**
  24627. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24628. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24629. * This should be used together with the simplification to avoid disappearing triangles.
  24630. * @param successCallback an optional success callback to be called after the optimization finished.
  24631. * @returns the current mesh
  24632. */
  24633. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24634. /**
  24635. * Serialize current mesh
  24636. * @param serializationObject defines the object which will receive the serialization data
  24637. */
  24638. serialize(serializationObject: any): void;
  24639. /** @hidden */
  24640. _syncGeometryWithMorphTargetManager(): void;
  24641. /** @hidden */
  24642. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24643. /**
  24644. * Returns a new Mesh object parsed from the source provided.
  24645. * @param parsedMesh is the source
  24646. * @param scene defines the hosting scene
  24647. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24648. * @returns a new Mesh
  24649. */
  24650. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24651. /**
  24652. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24653. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24654. * @param name defines the name of the mesh to create
  24655. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24656. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24657. * @param closePath creates a seam between the first and the last points of each path of the path array
  24658. * @param offset is taken in account only if the `pathArray` is containing a single path
  24659. * @param scene defines the hosting scene
  24660. * @param updatable defines if the mesh must be flagged as updatable
  24661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24662. * @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)
  24663. * @returns a new Mesh
  24664. */
  24665. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24666. /**
  24667. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24668. * @param name defines the name of the mesh to create
  24669. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24670. * @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
  24671. * @param scene defines the hosting scene
  24672. * @param updatable defines if the mesh must be flagged as updatable
  24673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24674. * @returns a new Mesh
  24675. */
  24676. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24677. /**
  24678. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24679. * @param name defines the name of the mesh to create
  24680. * @param size sets the size (float) of each box side (default 1)
  24681. * @param scene defines the hosting scene
  24682. * @param updatable defines if the mesh must be flagged as updatable
  24683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24684. * @returns a new Mesh
  24685. */
  24686. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24687. /**
  24688. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24689. * @param name defines the name of the mesh to create
  24690. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24691. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24692. * @param scene defines the hosting scene
  24693. * @param updatable defines if the mesh must be flagged as updatable
  24694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24695. * @returns a new Mesh
  24696. */
  24697. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24698. /**
  24699. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24700. * @param name defines the name of the mesh to create
  24701. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24702. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24703. * @param scene defines the hosting scene
  24704. * @returns a new Mesh
  24705. */
  24706. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24707. /**
  24708. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  24711. * @param diameterTop set the top cap diameter (floats, default 1)
  24712. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24713. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24714. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24715. * @param scene defines the hosting scene
  24716. * @param updatable defines if the mesh must be flagged as updatable
  24717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24718. * @returns a new Mesh
  24719. */
  24720. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24721. /**
  24722. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24723. * @param name defines the name of the mesh to create
  24724. * @param diameter sets the diameter size (float) of the torus (default 1)
  24725. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24726. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24727. * @param scene defines the hosting scene
  24728. * @param updatable defines if the mesh must be flagged as updatable
  24729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24730. * @returns a new Mesh
  24731. */
  24732. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24733. /**
  24734. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24735. * @param name defines the name of the mesh to create
  24736. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24737. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24738. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24739. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24740. * @param p the number of windings on X axis (positive integers, default 2)
  24741. * @param q the number of windings on Y axis (positive integers, default 3)
  24742. * @param scene defines the hosting scene
  24743. * @param updatable defines if the mesh must be flagged as updatable
  24744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24745. * @returns a new Mesh
  24746. */
  24747. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24748. /**
  24749. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24750. * @param name defines the name of the mesh to create
  24751. * @param points is an array successive Vector3
  24752. * @param scene defines the hosting scene
  24753. * @param updatable defines if the mesh must be flagged as updatable
  24754. * @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).
  24755. * @returns a new Mesh
  24756. */
  24757. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24758. /**
  24759. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24760. * @param name defines the name of the mesh to create
  24761. * @param points is an array successive Vector3
  24762. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24763. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24764. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24765. * @param scene defines the hosting scene
  24766. * @param updatable defines if the mesh must be flagged as updatable
  24767. * @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)
  24768. * @returns a new Mesh
  24769. */
  24770. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24771. /**
  24772. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24773. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24774. * 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.
  24775. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24776. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24777. * Remember you can only change the shape positions, not their number when updating a polygon.
  24778. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24779. * @param name defines the name of the mesh to create
  24780. * @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
  24781. * @param scene defines the hosting scene
  24782. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24783. * @param updatable defines if the mesh must be flagged as updatable
  24784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24785. * @param earcutInjection can be used to inject your own earcut reference
  24786. * @returns a new Mesh
  24787. */
  24788. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24789. /**
  24790. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24791. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24792. * @param name defines the name of the mesh to create
  24793. * @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
  24794. * @param depth defines the height of extrusion
  24795. * @param scene defines the hosting scene
  24796. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24797. * @param updatable defines if the mesh must be flagged as updatable
  24798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24799. * @param earcutInjection can be used to inject your own earcut reference
  24800. * @returns a new Mesh
  24801. */
  24802. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24803. /**
  24804. * Creates an extruded shape mesh.
  24805. * 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
  24806. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24807. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24808. * @param name defines the name of the mesh to create
  24809. * @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
  24810. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24811. * @param scale is the value to scale the shape
  24812. * @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
  24813. * @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
  24814. * @param scene defines the hosting scene
  24815. * @param updatable defines if the mesh must be flagged as updatable
  24816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24817. * @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)
  24818. * @returns a new Mesh
  24819. */
  24820. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24821. /**
  24822. * Creates an custom extruded shape mesh.
  24823. * The custom extrusion is a parametric shape.
  24824. * It has no predefined shape. Its final shape will depend on the input parameters.
  24825. * Please consider using the same method from the MeshBuilder class instead
  24826. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24827. * @param name defines the name of the mesh to create
  24828. * @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
  24829. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24830. * @param scaleFunction is a custom Javascript function called on each path point
  24831. * @param rotationFunction is a custom Javascript function called on each path point
  24832. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24833. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24834. * @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
  24835. * @param scene defines the hosting scene
  24836. * @param updatable defines if the mesh must be flagged as updatable
  24837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24838. * @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)
  24839. * @returns a new Mesh
  24840. */
  24841. 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;
  24842. /**
  24843. * Creates lathe mesh.
  24844. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24845. * Please consider using the same method from the MeshBuilder class instead
  24846. * @param name defines the name of the mesh to create
  24847. * @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
  24848. * @param radius is the radius value of the lathe
  24849. * @param tessellation is the side number of the lathe.
  24850. * @param scene defines the hosting scene
  24851. * @param updatable defines if the mesh must be flagged as updatable
  24852. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24853. * @returns a new Mesh
  24854. */
  24855. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24856. /**
  24857. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24858. * @param name defines the name of the mesh to create
  24859. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24860. * @param scene defines the hosting scene
  24861. * @param updatable defines if the mesh must be flagged as updatable
  24862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24863. * @returns a new Mesh
  24864. */
  24865. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24866. /**
  24867. * Creates a ground mesh.
  24868. * Please consider using the same method from the MeshBuilder class instead
  24869. * @param name defines the name of the mesh to create
  24870. * @param width set the width of the ground
  24871. * @param height set the height of the ground
  24872. * @param subdivisions sets the number of subdivisions per side
  24873. * @param scene defines the hosting scene
  24874. * @param updatable defines if the mesh must be flagged as updatable
  24875. * @returns a new Mesh
  24876. */
  24877. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24878. /**
  24879. * Creates a tiled ground mesh.
  24880. * Please consider using the same method from the MeshBuilder class instead
  24881. * @param name defines the name of the mesh to create
  24882. * @param xmin set the ground minimum X coordinate
  24883. * @param zmin set the ground minimum Y coordinate
  24884. * @param xmax set the ground maximum X coordinate
  24885. * @param zmax set the ground maximum Z coordinate
  24886. * @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
  24887. * @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
  24888. * @param scene defines the hosting scene
  24889. * @param updatable defines if the mesh must be flagged as updatable
  24890. * @returns a new Mesh
  24891. */
  24892. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24893. w: number;
  24894. h: number;
  24895. }, precision: {
  24896. w: number;
  24897. h: number;
  24898. }, scene: Scene, updatable?: boolean): Mesh;
  24899. /**
  24900. * Creates a ground mesh from a height map.
  24901. * Please consider using the same method from the MeshBuilder class instead
  24902. * @see http://doc.babylonjs.com/babylon101/height_map
  24903. * @param name defines the name of the mesh to create
  24904. * @param url sets the URL of the height map image resource
  24905. * @param width set the ground width size
  24906. * @param height set the ground height size
  24907. * @param subdivisions sets the number of subdivision per side
  24908. * @param minHeight is the minimum altitude on the ground
  24909. * @param maxHeight is the maximum altitude on the ground
  24910. * @param scene defines the hosting scene
  24911. * @param updatable defines if the mesh must be flagged as updatable
  24912. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24913. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24914. * @returns a new Mesh
  24915. */
  24916. 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;
  24917. /**
  24918. * Creates a tube mesh.
  24919. * The tube is a parametric shape.
  24920. * It has no predefined shape. Its final shape will depend on the input parameters.
  24921. * Please consider using the same method from the MeshBuilder class instead
  24922. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24923. * @param name defines the name of the mesh to create
  24924. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24925. * @param radius sets the tube radius size
  24926. * @param tessellation is the number of sides on the tubular surface
  24927. * @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
  24928. * @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
  24929. * @param scene defines the hosting scene
  24930. * @param updatable defines if the mesh must be flagged as updatable
  24931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24932. * @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)
  24933. * @returns a new Mesh
  24934. */
  24935. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24936. (i: number, distance: number): number;
  24937. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24938. /**
  24939. * Creates a polyhedron mesh.
  24940. * Please consider using the same method from the MeshBuilder class instead.
  24941. * * 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
  24942. * * The parameter `size` (positive float, default 1) sets the polygon size
  24943. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24944. * * 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`
  24945. * * 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
  24946. * * 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)`)
  24947. * * 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
  24948. * * 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
  24949. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * * If you create a double-sided mesh, you can choose what parts of 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
  24951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24952. * @param name defines the name of the mesh to create
  24953. * @param options defines the options used to create the mesh
  24954. * @param scene defines the hosting scene
  24955. * @returns a new Mesh
  24956. */
  24957. static CreatePolyhedron(name: string, options: {
  24958. type?: number;
  24959. size?: number;
  24960. sizeX?: number;
  24961. sizeY?: number;
  24962. sizeZ?: number;
  24963. custom?: any;
  24964. faceUV?: Vector4[];
  24965. faceColors?: Color4[];
  24966. updatable?: boolean;
  24967. sideOrientation?: number;
  24968. }, scene: Scene): Mesh;
  24969. /**
  24970. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24971. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24972. * * 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`)
  24973. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24974. * * 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
  24975. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24976. * * If you create a double-sided mesh, you can choose what parts of 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
  24977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24978. * @param name defines the name of the mesh
  24979. * @param options defines the options used to create the mesh
  24980. * @param scene defines the hosting scene
  24981. * @returns a new Mesh
  24982. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24983. */
  24984. static CreateIcoSphere(name: string, options: {
  24985. radius?: number;
  24986. flat?: boolean;
  24987. subdivisions?: number;
  24988. sideOrientation?: number;
  24989. updatable?: boolean;
  24990. }, scene: Scene): Mesh;
  24991. /**
  24992. * Creates a decal mesh.
  24993. * Please consider using the same method from the MeshBuilder class instead.
  24994. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24995. * @param name defines the name of the mesh
  24996. * @param sourceMesh defines the mesh receiving the decal
  24997. * @param position sets the position of the decal in world coordinates
  24998. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24999. * @param size sets the decal scaling
  25000. * @param angle sets the angle to rotate the decal
  25001. * @returns a new Mesh
  25002. */
  25003. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25004. /**
  25005. * Prepare internal position array for software CPU skinning
  25006. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25007. */
  25008. setPositionsForCPUSkinning(): Float32Array;
  25009. /**
  25010. * Prepare internal normal array for software CPU skinning
  25011. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25012. */
  25013. setNormalsForCPUSkinning(): Float32Array;
  25014. /**
  25015. * Updates the vertex buffer by applying transformation from the bones
  25016. * @param skeleton defines the skeleton to apply to current mesh
  25017. * @returns the current mesh
  25018. */
  25019. applySkeleton(skeleton: Skeleton): Mesh;
  25020. /**
  25021. * 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
  25022. * @param meshes defines the list of meshes to scan
  25023. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25024. */
  25025. static MinMax(meshes: AbstractMesh[]): {
  25026. min: Vector3;
  25027. max: Vector3;
  25028. };
  25029. /**
  25030. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25031. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25032. * @returns a vector3
  25033. */
  25034. static Center(meshesOrMinMaxVector: {
  25035. min: Vector3;
  25036. max: Vector3;
  25037. } | AbstractMesh[]): Vector3;
  25038. /**
  25039. * Merge the array of meshes into a single mesh for performance reasons.
  25040. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25041. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25042. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25043. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25044. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25045. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25046. * @returns a new mesh
  25047. */
  25048. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25049. /** @hidden */
  25050. addInstance(instance: InstancedMesh): void;
  25051. /** @hidden */
  25052. removeInstance(instance: InstancedMesh): void;
  25053. }
  25054. }
  25055. declare module "babylonjs/Cameras/camera" {
  25056. import { SmartArray } from "babylonjs/Misc/smartArray";
  25057. import { Observable } from "babylonjs/Misc/observable";
  25058. import { Nullable } from "babylonjs/types";
  25059. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25060. import { Scene } from "babylonjs/scene";
  25061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25062. import { Node } from "babylonjs/node";
  25063. import { Mesh } from "babylonjs/Meshes/mesh";
  25064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25065. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25066. import { Viewport } from "babylonjs/Maths/math.viewport";
  25067. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25070. import { Ray } from "babylonjs/Culling/ray";
  25071. /**
  25072. * This is the base class of all the camera used in the application.
  25073. * @see http://doc.babylonjs.com/features/cameras
  25074. */
  25075. export class Camera extends Node {
  25076. /** @hidden */
  25077. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25078. /**
  25079. * This is the default projection mode used by the cameras.
  25080. * It helps recreating a feeling of perspective and better appreciate depth.
  25081. * This is the best way to simulate real life cameras.
  25082. */
  25083. static readonly PERSPECTIVE_CAMERA: number;
  25084. /**
  25085. * This helps creating camera with an orthographic mode.
  25086. * 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.
  25087. */
  25088. static readonly ORTHOGRAPHIC_CAMERA: number;
  25089. /**
  25090. * This is the default FOV mode for perspective cameras.
  25091. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25092. */
  25093. static readonly FOVMODE_VERTICAL_FIXED: number;
  25094. /**
  25095. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25096. */
  25097. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25098. /**
  25099. * This specifies ther is no need for a camera rig.
  25100. * Basically only one eye is rendered corresponding to the camera.
  25101. */
  25102. static readonly RIG_MODE_NONE: number;
  25103. /**
  25104. * Simulates a camera Rig with one blue eye and one red eye.
  25105. * This can be use with 3d blue and red glasses.
  25106. */
  25107. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25108. /**
  25109. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25112. /**
  25113. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25114. */
  25115. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25116. /**
  25117. * Defines that both eyes of the camera will be rendered over under each other.
  25118. */
  25119. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25120. /**
  25121. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25122. */
  25123. static readonly RIG_MODE_VR: number;
  25124. /**
  25125. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25126. */
  25127. static readonly RIG_MODE_WEBVR: number;
  25128. /**
  25129. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25130. */
  25131. static readonly RIG_MODE_CUSTOM: number;
  25132. /**
  25133. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25134. */
  25135. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25136. /**
  25137. * Define the input manager associated with the camera.
  25138. */
  25139. inputs: CameraInputsManager<Camera>;
  25140. /** @hidden */
  25141. _position: Vector3;
  25142. /**
  25143. * Define the current local position of the camera in the scene
  25144. */
  25145. position: Vector3;
  25146. /**
  25147. * The vector the camera should consider as up.
  25148. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25149. */
  25150. upVector: Vector3;
  25151. /**
  25152. * Define the current limit on the left side for an orthographic camera
  25153. * In scene unit
  25154. */
  25155. orthoLeft: Nullable<number>;
  25156. /**
  25157. * Define the current limit on the right side for an orthographic camera
  25158. * In scene unit
  25159. */
  25160. orthoRight: Nullable<number>;
  25161. /**
  25162. * Define the current limit on the bottom side for an orthographic camera
  25163. * In scene unit
  25164. */
  25165. orthoBottom: Nullable<number>;
  25166. /**
  25167. * Define the current limit on the top side for an orthographic camera
  25168. * In scene unit
  25169. */
  25170. orthoTop: Nullable<number>;
  25171. /**
  25172. * Field Of View is set in Radians. (default is 0.8)
  25173. */
  25174. fov: number;
  25175. /**
  25176. * Define the minimum distance the camera can see from.
  25177. * This is important to note that the depth buffer are not infinite and the closer it starts
  25178. * the more your scene might encounter depth fighting issue.
  25179. */
  25180. minZ: number;
  25181. /**
  25182. * Define the maximum distance the camera can see to.
  25183. * This is important to note that the depth buffer are not infinite and the further it end
  25184. * the more your scene might encounter depth fighting issue.
  25185. */
  25186. maxZ: number;
  25187. /**
  25188. * Define the default inertia of the camera.
  25189. * This helps giving a smooth feeling to the camera movement.
  25190. */
  25191. inertia: number;
  25192. /**
  25193. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25194. */
  25195. mode: number;
  25196. /**
  25197. * Define wether the camera is intermediate.
  25198. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25199. */
  25200. isIntermediate: boolean;
  25201. /**
  25202. * Define the viewport of the camera.
  25203. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25204. */
  25205. viewport: Viewport;
  25206. /**
  25207. * Restricts the camera to viewing objects with the same layerMask.
  25208. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25209. */
  25210. layerMask: number;
  25211. /**
  25212. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25213. */
  25214. fovMode: number;
  25215. /**
  25216. * Rig mode of the camera.
  25217. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25218. * This is normally controlled byt the camera themselves as internal use.
  25219. */
  25220. cameraRigMode: number;
  25221. /**
  25222. * Defines the distance between both "eyes" in case of a RIG
  25223. */
  25224. interaxialDistance: number;
  25225. /**
  25226. * Defines if stereoscopic rendering is done side by side or over under.
  25227. */
  25228. isStereoscopicSideBySide: boolean;
  25229. /**
  25230. * 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
  25231. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25232. * else in the scene. (Eg. security camera)
  25233. *
  25234. * 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)
  25235. */
  25236. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25237. /**
  25238. * When set, the camera will render to this render target instead of the default canvas
  25239. *
  25240. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25241. */
  25242. outputRenderTarget: Nullable<RenderTargetTexture>;
  25243. /**
  25244. * Observable triggered when the camera view matrix has changed.
  25245. */
  25246. onViewMatrixChangedObservable: Observable<Camera>;
  25247. /**
  25248. * Observable triggered when the camera Projection matrix has changed.
  25249. */
  25250. onProjectionMatrixChangedObservable: Observable<Camera>;
  25251. /**
  25252. * Observable triggered when the inputs have been processed.
  25253. */
  25254. onAfterCheckInputsObservable: Observable<Camera>;
  25255. /**
  25256. * Observable triggered when reset has been called and applied to the camera.
  25257. */
  25258. onRestoreStateObservable: Observable<Camera>;
  25259. /** @hidden */
  25260. _cameraRigParams: any;
  25261. /** @hidden */
  25262. _rigCameras: Camera[];
  25263. /** @hidden */
  25264. _rigPostProcess: Nullable<PostProcess>;
  25265. protected _webvrViewMatrix: Matrix;
  25266. /** @hidden */
  25267. _skipRendering: boolean;
  25268. /** @hidden */
  25269. _projectionMatrix: Matrix;
  25270. /** @hidden */
  25271. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25272. /** @hidden */
  25273. _activeMeshes: SmartArray<AbstractMesh>;
  25274. protected _globalPosition: Vector3;
  25275. /** @hidden */
  25276. _computedViewMatrix: Matrix;
  25277. private _doNotComputeProjectionMatrix;
  25278. private _transformMatrix;
  25279. private _frustumPlanes;
  25280. private _refreshFrustumPlanes;
  25281. private _storedFov;
  25282. private _stateStored;
  25283. /**
  25284. * Instantiates a new camera object.
  25285. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25286. * @see http://doc.babylonjs.com/features/cameras
  25287. * @param name Defines the name of the camera in the scene
  25288. * @param position Defines the position of the camera
  25289. * @param scene Defines the scene the camera belongs too
  25290. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25291. */
  25292. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25293. /**
  25294. * Store current camera state (fov, position, etc..)
  25295. * @returns the camera
  25296. */
  25297. storeState(): Camera;
  25298. /**
  25299. * Restores the camera state values if it has been stored. You must call storeState() first
  25300. */
  25301. protected _restoreStateValues(): boolean;
  25302. /**
  25303. * Restored camera state. You must call storeState() first.
  25304. * @returns true if restored and false otherwise
  25305. */
  25306. restoreState(): boolean;
  25307. /**
  25308. * Gets the class name of the camera.
  25309. * @returns the class name
  25310. */
  25311. getClassName(): string;
  25312. /** @hidden */
  25313. readonly _isCamera: boolean;
  25314. /**
  25315. * Gets a string representation of the camera useful for debug purpose.
  25316. * @param fullDetails Defines that a more verboe level of logging is required
  25317. * @returns the string representation
  25318. */
  25319. toString(fullDetails?: boolean): string;
  25320. /**
  25321. * Gets the current world space position of the camera.
  25322. */
  25323. readonly globalPosition: Vector3;
  25324. /**
  25325. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25326. * @returns the active meshe list
  25327. */
  25328. getActiveMeshes(): SmartArray<AbstractMesh>;
  25329. /**
  25330. * Check wether a mesh is part of the current active mesh list of the camera
  25331. * @param mesh Defines the mesh to check
  25332. * @returns true if active, false otherwise
  25333. */
  25334. isActiveMesh(mesh: Mesh): boolean;
  25335. /**
  25336. * Is this camera ready to be used/rendered
  25337. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25338. * @return true if the camera is ready
  25339. */
  25340. isReady(completeCheck?: boolean): boolean;
  25341. /** @hidden */
  25342. _initCache(): void;
  25343. /** @hidden */
  25344. _updateCache(ignoreParentClass?: boolean): void;
  25345. /** @hidden */
  25346. _isSynchronized(): boolean;
  25347. /** @hidden */
  25348. _isSynchronizedViewMatrix(): boolean;
  25349. /** @hidden */
  25350. _isSynchronizedProjectionMatrix(): boolean;
  25351. /**
  25352. * Attach the input controls to a specific dom element to get the input from.
  25353. * @param element Defines the element the controls should be listened from
  25354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25355. */
  25356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25357. /**
  25358. * Detach the current controls from the specified dom element.
  25359. * @param element Defines the element to stop listening the inputs from
  25360. */
  25361. detachControl(element: HTMLElement): void;
  25362. /**
  25363. * Update the camera state according to the different inputs gathered during the frame.
  25364. */
  25365. update(): void;
  25366. /** @hidden */
  25367. _checkInputs(): void;
  25368. /** @hidden */
  25369. readonly rigCameras: Camera[];
  25370. /**
  25371. * Gets the post process used by the rig cameras
  25372. */
  25373. readonly rigPostProcess: Nullable<PostProcess>;
  25374. /**
  25375. * Internal, gets the first post proces.
  25376. * @returns the first post process to be run on this camera.
  25377. */
  25378. _getFirstPostProcess(): Nullable<PostProcess>;
  25379. private _cascadePostProcessesToRigCams;
  25380. /**
  25381. * Attach a post process to the camera.
  25382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25383. * @param postProcess The post process to attach to the camera
  25384. * @param insertAt The position of the post process in case several of them are in use in the scene
  25385. * @returns the position the post process has been inserted at
  25386. */
  25387. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25388. /**
  25389. * Detach a post process to the camera.
  25390. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25391. * @param postProcess The post process to detach from the camera
  25392. */
  25393. detachPostProcess(postProcess: PostProcess): void;
  25394. /**
  25395. * Gets the current world matrix of the camera
  25396. */
  25397. getWorldMatrix(): Matrix;
  25398. /** @hidden */
  25399. _getViewMatrix(): Matrix;
  25400. /**
  25401. * Gets the current view matrix of the camera.
  25402. * @param force forces the camera to recompute the matrix without looking at the cached state
  25403. * @returns the view matrix
  25404. */
  25405. getViewMatrix(force?: boolean): Matrix;
  25406. /**
  25407. * Freeze the projection matrix.
  25408. * It will prevent the cache check of the camera projection compute and can speed up perf
  25409. * if no parameter of the camera are meant to change
  25410. * @param projection Defines manually a projection if necessary
  25411. */
  25412. freezeProjectionMatrix(projection?: Matrix): void;
  25413. /**
  25414. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25415. */
  25416. unfreezeProjectionMatrix(): void;
  25417. /**
  25418. * Gets the current projection matrix of the camera.
  25419. * @param force forces the camera to recompute the matrix without looking at the cached state
  25420. * @returns the projection matrix
  25421. */
  25422. getProjectionMatrix(force?: boolean): Matrix;
  25423. /**
  25424. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25425. * @returns a Matrix
  25426. */
  25427. getTransformationMatrix(): Matrix;
  25428. private _updateFrustumPlanes;
  25429. /**
  25430. * Checks if a cullable object (mesh...) is in the camera frustum
  25431. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25432. * @param target The object to check
  25433. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25434. * @returns true if the object is in frustum otherwise false
  25435. */
  25436. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25437. /**
  25438. * Checks if a cullable object (mesh...) is in the camera frustum
  25439. * Unlike isInFrustum this cheks the full bounding box
  25440. * @param target The object to check
  25441. * @returns true if the object is in frustum otherwise false
  25442. */
  25443. isCompletelyInFrustum(target: ICullable): boolean;
  25444. /**
  25445. * Gets a ray in the forward direction from the camera.
  25446. * @param length Defines the length of the ray to create
  25447. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25448. * @param origin Defines the start point of the ray which defaults to the camera position
  25449. * @returns the forward ray
  25450. */
  25451. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25452. /**
  25453. * Releases resources associated with this node.
  25454. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25455. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25456. */
  25457. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25458. /** @hidden */
  25459. _isLeftCamera: boolean;
  25460. /**
  25461. * Gets the left camera of a rig setup in case of Rigged Camera
  25462. */
  25463. readonly isLeftCamera: boolean;
  25464. /** @hidden */
  25465. _isRightCamera: boolean;
  25466. /**
  25467. * Gets the right camera of a rig setup in case of Rigged Camera
  25468. */
  25469. readonly isRightCamera: boolean;
  25470. /**
  25471. * Gets the left camera of a rig setup in case of Rigged Camera
  25472. */
  25473. readonly leftCamera: Nullable<FreeCamera>;
  25474. /**
  25475. * Gets the right camera of a rig setup in case of Rigged Camera
  25476. */
  25477. readonly rightCamera: Nullable<FreeCamera>;
  25478. /**
  25479. * Gets the left camera target of a rig setup in case of Rigged Camera
  25480. * @returns the target position
  25481. */
  25482. getLeftTarget(): Nullable<Vector3>;
  25483. /**
  25484. * Gets the right camera target of a rig setup in case of Rigged Camera
  25485. * @returns the target position
  25486. */
  25487. getRightTarget(): Nullable<Vector3>;
  25488. /**
  25489. * @hidden
  25490. */
  25491. setCameraRigMode(mode: number, rigParams: any): void;
  25492. /** @hidden */
  25493. static _setStereoscopicRigMode(camera: Camera): void;
  25494. /** @hidden */
  25495. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25496. /** @hidden */
  25497. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25498. /** @hidden */
  25499. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25500. /** @hidden */
  25501. _getVRProjectionMatrix(): Matrix;
  25502. protected _updateCameraRotationMatrix(): void;
  25503. protected _updateWebVRCameraRotationMatrix(): void;
  25504. /**
  25505. * This function MUST be overwritten by the different WebVR cameras available.
  25506. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25507. * @hidden
  25508. */
  25509. _getWebVRProjectionMatrix(): Matrix;
  25510. /**
  25511. * This function MUST be overwritten by the different WebVR cameras available.
  25512. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25513. * @hidden
  25514. */
  25515. _getWebVRViewMatrix(): Matrix;
  25516. /** @hidden */
  25517. setCameraRigParameter(name: string, value: any): void;
  25518. /**
  25519. * needs to be overridden by children so sub has required properties to be copied
  25520. * @hidden
  25521. */
  25522. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25523. /**
  25524. * May need to be overridden by children
  25525. * @hidden
  25526. */
  25527. _updateRigCameras(): void;
  25528. /** @hidden */
  25529. _setupInputs(): void;
  25530. /**
  25531. * Serialiaze the camera setup to a json represention
  25532. * @returns the JSON representation
  25533. */
  25534. serialize(): any;
  25535. /**
  25536. * Clones the current camera.
  25537. * @param name The cloned camera name
  25538. * @returns the cloned camera
  25539. */
  25540. clone(name: string): Camera;
  25541. /**
  25542. * Gets the direction of the camera relative to a given local axis.
  25543. * @param localAxis Defines the reference axis to provide a relative direction.
  25544. * @return the direction
  25545. */
  25546. getDirection(localAxis: Vector3): Vector3;
  25547. /**
  25548. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25549. * @param localAxis Defines the reference axis to provide a relative direction.
  25550. * @param result Defines the vector to store the result in
  25551. */
  25552. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25553. /**
  25554. * Gets a camera constructor for a given camera type
  25555. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25556. * @param name The name of the camera the result will be able to instantiate
  25557. * @param scene The scene the result will construct the camera in
  25558. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25559. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25560. * @returns a factory method to construc the camera
  25561. */
  25562. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25563. /**
  25564. * Compute the world matrix of the camera.
  25565. * @returns the camera workd matrix
  25566. */
  25567. computeWorldMatrix(): Matrix;
  25568. /**
  25569. * Parse a JSON and creates the camera from the parsed information
  25570. * @param parsedCamera The JSON to parse
  25571. * @param scene The scene to instantiate the camera in
  25572. * @returns the newly constructed camera
  25573. */
  25574. static Parse(parsedCamera: any, scene: Scene): Camera;
  25575. }
  25576. }
  25577. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25578. import { Nullable } from "babylonjs/types";
  25579. import { Scene } from "babylonjs/scene";
  25580. import { Vector4 } from "babylonjs/Maths/math.vector";
  25581. import { Mesh } from "babylonjs/Meshes/mesh";
  25582. /**
  25583. * Class containing static functions to help procedurally build meshes
  25584. */
  25585. export class DiscBuilder {
  25586. /**
  25587. * Creates a plane polygonal mesh. By default, this is a disc
  25588. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25589. * * 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
  25590. * * 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
  25591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25594. * @param name defines the name of the mesh
  25595. * @param options defines the options used to create the mesh
  25596. * @param scene defines the hosting scene
  25597. * @returns the plane polygonal mesh
  25598. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25599. */
  25600. static CreateDisc(name: string, options: {
  25601. radius?: number;
  25602. tessellation?: number;
  25603. arc?: number;
  25604. updatable?: boolean;
  25605. sideOrientation?: number;
  25606. frontUVs?: Vector4;
  25607. backUVs?: Vector4;
  25608. }, scene?: Nullable<Scene>): Mesh;
  25609. }
  25610. }
  25611. declare module "babylonjs/Particles/solidParticleSystem" {
  25612. import { Vector3 } from "babylonjs/Maths/math.vector";
  25613. import { Mesh } from "babylonjs/Meshes/mesh";
  25614. import { Scene, IDisposable } from "babylonjs/scene";
  25615. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25616. /**
  25617. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25618. *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.
  25619. * The SPS is also a particle system. It provides some methods to manage the particles.
  25620. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25621. *
  25622. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25623. */
  25624. export class SolidParticleSystem implements IDisposable {
  25625. /**
  25626. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25627. * Example : var p = SPS.particles[i];
  25628. */
  25629. particles: SolidParticle[];
  25630. /**
  25631. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25632. */
  25633. nbParticles: number;
  25634. /**
  25635. * If the particles must ever face the camera (default false). Useful for planar particles.
  25636. */
  25637. billboard: boolean;
  25638. /**
  25639. * Recompute normals when adding a shape
  25640. */
  25641. recomputeNormals: boolean;
  25642. /**
  25643. * This a counter ofr your own usage. It's not set by any SPS functions.
  25644. */
  25645. counter: number;
  25646. /**
  25647. * The SPS name. This name is also given to the underlying mesh.
  25648. */
  25649. name: string;
  25650. /**
  25651. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25652. */
  25653. mesh: Mesh;
  25654. /**
  25655. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25656. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25657. */
  25658. vars: any;
  25659. /**
  25660. * This array is populated when the SPS is set as 'pickable'.
  25661. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25662. * Each element of this array is an object `{idx: int, faceId: int}`.
  25663. * `idx` is the picked particle index in the `SPS.particles` array
  25664. * `faceId` is the picked face index counted within this particle.
  25665. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25666. */
  25667. pickedParticles: {
  25668. idx: number;
  25669. faceId: number;
  25670. }[];
  25671. /**
  25672. * This array is populated when `enableDepthSort` is set to true.
  25673. * Each element of this array is an instance of the class DepthSortedParticle.
  25674. */
  25675. depthSortedParticles: DepthSortedParticle[];
  25676. /**
  25677. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25678. * @hidden
  25679. */
  25680. _bSphereOnly: boolean;
  25681. /**
  25682. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25683. * @hidden
  25684. */
  25685. _bSphereRadiusFactor: number;
  25686. private _scene;
  25687. private _positions;
  25688. private _indices;
  25689. private _normals;
  25690. private _colors;
  25691. private _uvs;
  25692. private _indices32;
  25693. private _positions32;
  25694. private _normals32;
  25695. private _fixedNormal32;
  25696. private _colors32;
  25697. private _uvs32;
  25698. private _index;
  25699. private _updatable;
  25700. private _pickable;
  25701. private _isVisibilityBoxLocked;
  25702. private _alwaysVisible;
  25703. private _depthSort;
  25704. private _shapeCounter;
  25705. private _copy;
  25706. private _color;
  25707. private _computeParticleColor;
  25708. private _computeParticleTexture;
  25709. private _computeParticleRotation;
  25710. private _computeParticleVertex;
  25711. private _computeBoundingBox;
  25712. private _depthSortParticles;
  25713. private _camera;
  25714. private _mustUnrotateFixedNormals;
  25715. private _particlesIntersect;
  25716. private _needs32Bits;
  25717. /**
  25718. * Creates a SPS (Solid Particle System) object.
  25719. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25720. * @param scene (Scene) is the scene in which the SPS is added.
  25721. * @param options defines the options of the sps e.g.
  25722. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25723. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25724. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25725. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25726. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25727. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25728. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25729. */
  25730. constructor(name: string, scene: Scene, options?: {
  25731. updatable?: boolean;
  25732. isPickable?: boolean;
  25733. enableDepthSort?: boolean;
  25734. particleIntersection?: boolean;
  25735. boundingSphereOnly?: boolean;
  25736. bSphereRadiusFactor?: number;
  25737. });
  25738. /**
  25739. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25740. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25741. * @returns the created mesh
  25742. */
  25743. buildMesh(): Mesh;
  25744. /**
  25745. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25746. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25747. * Thus the particles generated from `digest()` have their property `position` set yet.
  25748. * @param mesh ( Mesh ) is the mesh to be digested
  25749. * @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
  25750. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25751. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25752. * @returns the current SPS
  25753. */
  25754. digest(mesh: Mesh, options?: {
  25755. facetNb?: number;
  25756. number?: number;
  25757. delta?: number;
  25758. }): SolidParticleSystem;
  25759. private _unrotateFixedNormals;
  25760. private _resetCopy;
  25761. private _meshBuilder;
  25762. private _posToShape;
  25763. private _uvsToShapeUV;
  25764. private _addParticle;
  25765. /**
  25766. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25767. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25768. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25769. * @param nb (positive integer) the number of particles to be created from this model
  25770. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25771. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25772. * @returns the number of shapes in the system
  25773. */
  25774. addShape(mesh: Mesh, nb: number, options?: {
  25775. positionFunction?: any;
  25776. vertexFunction?: any;
  25777. }): number;
  25778. private _rebuildParticle;
  25779. /**
  25780. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25781. * @returns the SPS.
  25782. */
  25783. rebuildMesh(): SolidParticleSystem;
  25784. /**
  25785. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25786. * This method calls `updateParticle()` for each particle of the SPS.
  25787. * For an animated SPS, it is usually called within the render loop.
  25788. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25789. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25790. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25791. * @returns the SPS.
  25792. */
  25793. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25794. /**
  25795. * Disposes the SPS.
  25796. */
  25797. dispose(): void;
  25798. /**
  25799. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25801. * @returns the SPS.
  25802. */
  25803. refreshVisibleSize(): SolidParticleSystem;
  25804. /**
  25805. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25806. * @param size the size (float) of the visibility box
  25807. * note : this doesn't lock the SPS mesh bounding box.
  25808. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25809. */
  25810. setVisibilityBox(size: number): void;
  25811. /**
  25812. * Gets whether the SPS as always visible or not
  25813. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25814. */
  25815. /**
  25816. * Sets the SPS as always visible or not
  25817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25818. */
  25819. isAlwaysVisible: boolean;
  25820. /**
  25821. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25823. */
  25824. /**
  25825. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25827. */
  25828. isVisibilityBoxLocked: boolean;
  25829. /**
  25830. * Tells to `setParticles()` to compute the particle rotations or not.
  25831. * Default value : true. The SPS is faster when it's set to false.
  25832. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25833. */
  25834. /**
  25835. * Gets if `setParticles()` computes the particle rotations or not.
  25836. * Default value : true. The SPS is faster when it's set to false.
  25837. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25838. */
  25839. computeParticleRotation: boolean;
  25840. /**
  25841. * Tells to `setParticles()` to compute the particle colors or not.
  25842. * Default value : true. The SPS is faster when it's set to false.
  25843. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25844. */
  25845. /**
  25846. * Gets if `setParticles()` computes the particle colors or not.
  25847. * Default value : true. The SPS is faster when it's set to false.
  25848. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25849. */
  25850. computeParticleColor: boolean;
  25851. /**
  25852. * Gets if `setParticles()` computes the particle textures or not.
  25853. * Default value : true. The SPS is faster when it's set to false.
  25854. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25855. */
  25856. computeParticleTexture: boolean;
  25857. /**
  25858. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25859. * Default value : false. The SPS is faster when it's set to false.
  25860. * Note : the particle custom vertex positions aren't stored values.
  25861. */
  25862. /**
  25863. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25864. * Default value : false. The SPS is faster when it's set to false.
  25865. * Note : the particle custom vertex positions aren't stored values.
  25866. */
  25867. computeParticleVertex: boolean;
  25868. /**
  25869. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25870. */
  25871. /**
  25872. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25873. */
  25874. computeBoundingBox: boolean;
  25875. /**
  25876. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25877. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25878. * Default : `true`
  25879. */
  25880. /**
  25881. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25882. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25883. * Default : `true`
  25884. */
  25885. depthSortParticles: boolean;
  25886. /**
  25887. * This function does nothing. It may be overwritten to set all the particle first values.
  25888. * The SPS doesn't call this function, you may have to call it by your own.
  25889. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25890. */
  25891. initParticles(): void;
  25892. /**
  25893. * This function does nothing. It may be overwritten to recycle a particle.
  25894. * The SPS doesn't call this function, you may have to call it by your own.
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25896. * @param particle The particle to recycle
  25897. * @returns the recycled particle
  25898. */
  25899. recycleParticle(particle: SolidParticle): SolidParticle;
  25900. /**
  25901. * Updates a particle : this function should be overwritten by the user.
  25902. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25903. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25904. * @example : just set a particle position or velocity and recycle conditions
  25905. * @param particle The particle to update
  25906. * @returns the updated particle
  25907. */
  25908. updateParticle(particle: SolidParticle): SolidParticle;
  25909. /**
  25910. * Updates a vertex of a particle : it can be overwritten by the user.
  25911. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25912. * @param particle the current particle
  25913. * @param vertex the current index of the current particle
  25914. * @param pt the index of the current vertex in the particle shape
  25915. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25916. * @example : just set a vertex particle position
  25917. * @returns the updated vertex
  25918. */
  25919. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25920. /**
  25921. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25922. * This does nothing and may be overwritten by the user.
  25923. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25924. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25925. * @param update the boolean update value actually passed to setParticles()
  25926. */
  25927. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25928. /**
  25929. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25930. * This will be passed three parameters.
  25931. * This does nothing and may be overwritten by the user.
  25932. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25933. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25934. * @param update the boolean update value actually passed to setParticles()
  25935. */
  25936. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25937. }
  25938. }
  25939. declare module "babylonjs/Particles/solidParticle" {
  25940. import { Nullable } from "babylonjs/types";
  25941. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25942. import { Color4 } from "babylonjs/Maths/math.color";
  25943. import { Mesh } from "babylonjs/Meshes/mesh";
  25944. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25945. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25946. import { Plane } from "babylonjs/Maths/math.plane";
  25947. /**
  25948. * Represents one particle of a solid particle system.
  25949. */
  25950. export class SolidParticle {
  25951. /**
  25952. * particle global index
  25953. */
  25954. idx: number;
  25955. /**
  25956. * The color of the particle
  25957. */
  25958. color: Nullable<Color4>;
  25959. /**
  25960. * The world space position of the particle.
  25961. */
  25962. position: Vector3;
  25963. /**
  25964. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25965. */
  25966. rotation: Vector3;
  25967. /**
  25968. * The world space rotation quaternion of the particle.
  25969. */
  25970. rotationQuaternion: Nullable<Quaternion>;
  25971. /**
  25972. * The scaling of the particle.
  25973. */
  25974. scaling: Vector3;
  25975. /**
  25976. * The uvs of the particle.
  25977. */
  25978. uvs: Vector4;
  25979. /**
  25980. * The current speed of the particle.
  25981. */
  25982. velocity: Vector3;
  25983. /**
  25984. * The pivot point in the particle local space.
  25985. */
  25986. pivot: Vector3;
  25987. /**
  25988. * Must the particle be translated from its pivot point in its local space ?
  25989. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25990. * Default : false
  25991. */
  25992. translateFromPivot: boolean;
  25993. /**
  25994. * Is the particle active or not ?
  25995. */
  25996. alive: boolean;
  25997. /**
  25998. * Is the particle visible or not ?
  25999. */
  26000. isVisible: boolean;
  26001. /**
  26002. * Index of this particle in the global "positions" array (Internal use)
  26003. * @hidden
  26004. */
  26005. _pos: number;
  26006. /**
  26007. * @hidden Index of this particle in the global "indices" array (Internal use)
  26008. */
  26009. _ind: number;
  26010. /**
  26011. * @hidden ModelShape of this particle (Internal use)
  26012. */
  26013. _model: ModelShape;
  26014. /**
  26015. * ModelShape id of this particle
  26016. */
  26017. shapeId: number;
  26018. /**
  26019. * Index of the particle in its shape id (Internal use)
  26020. */
  26021. idxInShape: number;
  26022. /**
  26023. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26024. */
  26025. _modelBoundingInfo: BoundingInfo;
  26026. /**
  26027. * @hidden Particle BoundingInfo object (Internal use)
  26028. */
  26029. _boundingInfo: BoundingInfo;
  26030. /**
  26031. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26032. */
  26033. _sps: SolidParticleSystem;
  26034. /**
  26035. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26036. */
  26037. _stillInvisible: boolean;
  26038. /**
  26039. * @hidden Last computed particle rotation matrix
  26040. */
  26041. _rotationMatrix: number[];
  26042. /**
  26043. * Parent particle Id, if any.
  26044. * Default null.
  26045. */
  26046. parentId: Nullable<number>;
  26047. /**
  26048. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26049. * The possible values are :
  26050. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26051. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26052. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26053. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26054. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26055. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26056. * */
  26057. cullingStrategy: number;
  26058. /**
  26059. * @hidden Internal global position in the SPS.
  26060. */
  26061. _globalPosition: Vector3;
  26062. /**
  26063. * Creates a Solid Particle object.
  26064. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26065. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26066. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26067. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26068. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26069. * @param shapeId (integer) is the model shape identifier in the SPS.
  26070. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26071. * @param sps defines the sps it is associated to
  26072. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26073. */
  26074. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26075. /**
  26076. * Legacy support, changed scale to scaling
  26077. */
  26078. /**
  26079. * Legacy support, changed scale to scaling
  26080. */
  26081. scale: Vector3;
  26082. /**
  26083. * Legacy support, changed quaternion to rotationQuaternion
  26084. */
  26085. /**
  26086. * Legacy support, changed quaternion to rotationQuaternion
  26087. */
  26088. quaternion: Nullable<Quaternion>;
  26089. /**
  26090. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26091. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26092. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26093. * @returns true if it intersects
  26094. */
  26095. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26096. /**
  26097. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26098. * A particle is in the frustum if its bounding box intersects the frustum
  26099. * @param frustumPlanes defines the frustum to test
  26100. * @returns true if the particle is in the frustum planes
  26101. */
  26102. isInFrustum(frustumPlanes: Plane[]): boolean;
  26103. /**
  26104. * get the rotation matrix of the particle
  26105. * @hidden
  26106. */
  26107. getRotationMatrix(m: Matrix): void;
  26108. }
  26109. /**
  26110. * Represents the shape of the model used by one particle of a solid particle system.
  26111. * SPS internal tool, don't use it manually.
  26112. */
  26113. export class ModelShape {
  26114. /**
  26115. * The shape id
  26116. * @hidden
  26117. */
  26118. shapeID: number;
  26119. /**
  26120. * flat array of model positions (internal use)
  26121. * @hidden
  26122. */
  26123. _shape: Vector3[];
  26124. /**
  26125. * flat array of model UVs (internal use)
  26126. * @hidden
  26127. */
  26128. _shapeUV: number[];
  26129. /**
  26130. * length of the shape in the model indices array (internal use)
  26131. * @hidden
  26132. */
  26133. _indicesLength: number;
  26134. /**
  26135. * Custom position function (internal use)
  26136. * @hidden
  26137. */
  26138. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26139. /**
  26140. * Custom vertex function (internal use)
  26141. * @hidden
  26142. */
  26143. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26144. /**
  26145. * 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.
  26146. * SPS internal tool, don't use it manually.
  26147. * @hidden
  26148. */
  26149. 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>);
  26150. }
  26151. /**
  26152. * Represents a Depth Sorted Particle in the solid particle system.
  26153. */
  26154. export class DepthSortedParticle {
  26155. /**
  26156. * Index of the particle in the "indices" array
  26157. */
  26158. ind: number;
  26159. /**
  26160. * Length of the particle shape in the "indices" array
  26161. */
  26162. indicesLength: number;
  26163. /**
  26164. * Squared distance from the particle to the camera
  26165. */
  26166. sqDistance: number;
  26167. }
  26168. }
  26169. declare module "babylonjs/Collisions/meshCollisionData" {
  26170. import { Collider } from "babylonjs/Collisions/collider";
  26171. import { Vector3 } from "babylonjs/Maths/math.vector";
  26172. import { Nullable } from "babylonjs/types";
  26173. import { Observer } from "babylonjs/Misc/observable";
  26174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26175. /**
  26176. * @hidden
  26177. */
  26178. export class _MeshCollisionData {
  26179. _checkCollisions: boolean;
  26180. _collisionMask: number;
  26181. _collisionGroup: number;
  26182. _collider: Nullable<Collider>;
  26183. _oldPositionForCollisions: Vector3;
  26184. _diffPositionForCollisions: Vector3;
  26185. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26186. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26187. }
  26188. }
  26189. declare module "babylonjs/Meshes/abstractMesh" {
  26190. import { Observable } from "babylonjs/Misc/observable";
  26191. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26192. import { Camera } from "babylonjs/Cameras/camera";
  26193. import { Scene, IDisposable } from "babylonjs/scene";
  26194. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26195. import { Node } from "babylonjs/node";
  26196. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26199. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26200. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26201. import { Material } from "babylonjs/Materials/material";
  26202. import { Light } from "babylonjs/Lights/light";
  26203. import { Skeleton } from "babylonjs/Bones/skeleton";
  26204. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26205. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26206. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26207. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26208. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26209. import { Plane } from "babylonjs/Maths/math.plane";
  26210. import { Ray } from "babylonjs/Culling/ray";
  26211. import { Collider } from "babylonjs/Collisions/collider";
  26212. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26213. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26214. /** @hidden */
  26215. class _FacetDataStorage {
  26216. facetPositions: Vector3[];
  26217. facetNormals: Vector3[];
  26218. facetPartitioning: number[][];
  26219. facetNb: number;
  26220. partitioningSubdivisions: number;
  26221. partitioningBBoxRatio: number;
  26222. facetDataEnabled: boolean;
  26223. facetParameters: any;
  26224. bbSize: Vector3;
  26225. subDiv: {
  26226. max: number;
  26227. X: number;
  26228. Y: number;
  26229. Z: number;
  26230. };
  26231. facetDepthSort: boolean;
  26232. facetDepthSortEnabled: boolean;
  26233. depthSortedIndices: IndicesArray;
  26234. depthSortedFacets: {
  26235. ind: number;
  26236. sqDistance: number;
  26237. }[];
  26238. facetDepthSortFunction: (f1: {
  26239. ind: number;
  26240. sqDistance: number;
  26241. }, f2: {
  26242. ind: number;
  26243. sqDistance: number;
  26244. }) => number;
  26245. facetDepthSortFrom: Vector3;
  26246. facetDepthSortOrigin: Vector3;
  26247. invertedMatrix: Matrix;
  26248. }
  26249. /**
  26250. * @hidden
  26251. **/
  26252. class _InternalAbstractMeshDataInfo {
  26253. _hasVertexAlpha: boolean;
  26254. _useVertexColors: boolean;
  26255. _numBoneInfluencers: number;
  26256. _applyFog: boolean;
  26257. _receiveShadows: boolean;
  26258. _facetData: _FacetDataStorage;
  26259. _visibility: number;
  26260. _skeleton: Nullable<Skeleton>;
  26261. _layerMask: number;
  26262. _computeBonesUsingShaders: boolean;
  26263. _isActive: boolean;
  26264. _onlyForInstances: boolean;
  26265. _isActiveIntermediate: boolean;
  26266. _onlyForInstancesIntermediate: boolean;
  26267. }
  26268. /**
  26269. * Class used to store all common mesh properties
  26270. */
  26271. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26272. /** No occlusion */
  26273. static OCCLUSION_TYPE_NONE: number;
  26274. /** Occlusion set to optimisitic */
  26275. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26276. /** Occlusion set to strict */
  26277. static OCCLUSION_TYPE_STRICT: number;
  26278. /** Use an accurante occlusion algorithm */
  26279. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26280. /** Use a conservative occlusion algorithm */
  26281. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26282. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26283. * Test order :
  26284. * Is the bounding sphere outside the frustum ?
  26285. * If not, are the bounding box vertices outside the frustum ?
  26286. * It not, then the cullable object is in the frustum.
  26287. */
  26288. static readonly CULLINGSTRATEGY_STANDARD: number;
  26289. /** Culling strategy : Bounding Sphere Only.
  26290. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26291. * It's also less accurate than the standard because some not visible objects can still be selected.
  26292. * Test : is the bounding sphere outside the frustum ?
  26293. * If not, then the cullable object is in the frustum.
  26294. */
  26295. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26296. /** Culling strategy : Optimistic Inclusion.
  26297. * This in an inclusion test first, then the standard exclusion test.
  26298. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26299. * 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.
  26300. * Anyway, it's as accurate as the standard strategy.
  26301. * Test :
  26302. * Is the cullable object bounding sphere center in the frustum ?
  26303. * If not, apply the default culling strategy.
  26304. */
  26305. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26306. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26307. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26308. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26309. * 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.
  26310. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26311. * Test :
  26312. * Is the cullable object bounding sphere center in the frustum ?
  26313. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26314. */
  26315. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26316. /**
  26317. * No billboard
  26318. */
  26319. static readonly BILLBOARDMODE_NONE: number;
  26320. /** Billboard on X axis */
  26321. static readonly BILLBOARDMODE_X: number;
  26322. /** Billboard on Y axis */
  26323. static readonly BILLBOARDMODE_Y: number;
  26324. /** Billboard on Z axis */
  26325. static readonly BILLBOARDMODE_Z: number;
  26326. /** Billboard on all axes */
  26327. static readonly BILLBOARDMODE_ALL: number;
  26328. /** @hidden */
  26329. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26330. /**
  26331. * The culling strategy to use to check whether the mesh must be rendered or not.
  26332. * This value can be changed at any time and will be used on the next render mesh selection.
  26333. * The possible values are :
  26334. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26335. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26336. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26337. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26338. * Please read each static variable documentation to get details about the culling process.
  26339. * */
  26340. cullingStrategy: number;
  26341. /**
  26342. * Gets the number of facets in the mesh
  26343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26344. */
  26345. readonly facetNb: number;
  26346. /**
  26347. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26349. */
  26350. partitioningSubdivisions: number;
  26351. /**
  26352. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26353. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26355. */
  26356. partitioningBBoxRatio: number;
  26357. /**
  26358. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26359. * Works only for updatable meshes.
  26360. * Doesn't work with multi-materials
  26361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26362. */
  26363. mustDepthSortFacets: boolean;
  26364. /**
  26365. * The location (Vector3) where the facet depth sort must be computed from.
  26366. * By default, the active camera position.
  26367. * Used only when facet depth sort is enabled
  26368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26369. */
  26370. facetDepthSortFrom: Vector3;
  26371. /**
  26372. * gets a boolean indicating if facetData is enabled
  26373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26374. */
  26375. readonly isFacetDataEnabled: boolean;
  26376. /** @hidden */
  26377. _updateNonUniformScalingState(value: boolean): boolean;
  26378. /**
  26379. * An event triggered when this mesh collides with another one
  26380. */
  26381. onCollideObservable: Observable<AbstractMesh>;
  26382. /** Set a function to call when this mesh collides with another one */
  26383. onCollide: () => void;
  26384. /**
  26385. * An event triggered when the collision's position changes
  26386. */
  26387. onCollisionPositionChangeObservable: Observable<Vector3>;
  26388. /** Set a function to call when the collision's position changes */
  26389. onCollisionPositionChange: () => void;
  26390. /**
  26391. * An event triggered when material is changed
  26392. */
  26393. onMaterialChangedObservable: Observable<AbstractMesh>;
  26394. /**
  26395. * Gets or sets the orientation for POV movement & rotation
  26396. */
  26397. definedFacingForward: boolean;
  26398. /** @hidden */
  26399. _occlusionQuery: Nullable<WebGLQuery>;
  26400. /** @hidden */
  26401. _renderingGroup: Nullable<RenderingGroup>;
  26402. /**
  26403. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26404. */
  26405. /**
  26406. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26407. */
  26408. visibility: number;
  26409. /** Gets or sets the alpha index used to sort transparent meshes
  26410. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26411. */
  26412. alphaIndex: number;
  26413. /**
  26414. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26415. */
  26416. isVisible: boolean;
  26417. /**
  26418. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26419. */
  26420. isPickable: boolean;
  26421. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26422. showSubMeshesBoundingBox: boolean;
  26423. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26425. */
  26426. isBlocker: boolean;
  26427. /**
  26428. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26429. */
  26430. enablePointerMoveEvents: boolean;
  26431. /**
  26432. * Specifies the rendering group id for this mesh (0 by default)
  26433. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26434. */
  26435. renderingGroupId: number;
  26436. private _material;
  26437. /** Gets or sets current material */
  26438. material: Nullable<Material>;
  26439. /**
  26440. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26441. * @see http://doc.babylonjs.com/babylon101/shadows
  26442. */
  26443. receiveShadows: boolean;
  26444. /** Defines color to use when rendering outline */
  26445. outlineColor: Color3;
  26446. /** Define width to use when rendering outline */
  26447. outlineWidth: number;
  26448. /** Defines color to use when rendering overlay */
  26449. overlayColor: Color3;
  26450. /** Defines alpha to use when rendering overlay */
  26451. overlayAlpha: number;
  26452. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26453. hasVertexAlpha: boolean;
  26454. /** 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) */
  26455. useVertexColors: boolean;
  26456. /**
  26457. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26458. */
  26459. computeBonesUsingShaders: boolean;
  26460. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26461. numBoneInfluencers: number;
  26462. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26463. applyFog: boolean;
  26464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26465. useOctreeForRenderingSelection: boolean;
  26466. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26467. useOctreeForPicking: boolean;
  26468. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26469. useOctreeForCollisions: boolean;
  26470. /**
  26471. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26472. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26473. */
  26474. layerMask: number;
  26475. /**
  26476. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26477. */
  26478. alwaysSelectAsActiveMesh: boolean;
  26479. /**
  26480. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26481. */
  26482. doNotSyncBoundingInfo: boolean;
  26483. /**
  26484. * Gets or sets the current action manager
  26485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26486. */
  26487. actionManager: Nullable<AbstractActionManager>;
  26488. private _meshCollisionData;
  26489. /**
  26490. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26492. */
  26493. ellipsoid: Vector3;
  26494. /**
  26495. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26497. */
  26498. ellipsoidOffset: Vector3;
  26499. /**
  26500. * Gets or sets a collision mask used to mask collisions (default is -1).
  26501. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26502. */
  26503. collisionMask: number;
  26504. /**
  26505. * Gets or sets the current collision group mask (-1 by default).
  26506. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26507. */
  26508. collisionGroup: number;
  26509. /**
  26510. * Defines edge width used when edgesRenderer is enabled
  26511. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26512. */
  26513. edgesWidth: number;
  26514. /**
  26515. * Defines edge color used when edgesRenderer is enabled
  26516. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26517. */
  26518. edgesColor: Color4;
  26519. /** @hidden */
  26520. _edgesRenderer: Nullable<IEdgesRenderer>;
  26521. /** @hidden */
  26522. _masterMesh: Nullable<AbstractMesh>;
  26523. /** @hidden */
  26524. _boundingInfo: Nullable<BoundingInfo>;
  26525. /** @hidden */
  26526. _renderId: number;
  26527. /**
  26528. * Gets or sets the list of subMeshes
  26529. * @see http://doc.babylonjs.com/how_to/multi_materials
  26530. */
  26531. subMeshes: SubMesh[];
  26532. /** @hidden */
  26533. _intersectionsInProgress: AbstractMesh[];
  26534. /** @hidden */
  26535. _unIndexed: boolean;
  26536. /** @hidden */
  26537. _lightSources: Light[];
  26538. /** Gets the list of lights affecting that mesh */
  26539. readonly lightSources: Light[];
  26540. /** @hidden */
  26541. readonly _positions: Nullable<Vector3[]>;
  26542. /** @hidden */
  26543. _waitingData: {
  26544. lods: Nullable<any>;
  26545. actions: Nullable<any>;
  26546. freezeWorldMatrix: Nullable<boolean>;
  26547. };
  26548. /** @hidden */
  26549. _bonesTransformMatrices: Nullable<Float32Array>;
  26550. /** @hidden */
  26551. _transformMatrixTexture: Nullable<RawTexture>;
  26552. /**
  26553. * Gets or sets a skeleton to apply skining transformations
  26554. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26555. */
  26556. skeleton: Nullable<Skeleton>;
  26557. /**
  26558. * An event triggered when the mesh is rebuilt.
  26559. */
  26560. onRebuildObservable: Observable<AbstractMesh>;
  26561. /**
  26562. * Creates a new AbstractMesh
  26563. * @param name defines the name of the mesh
  26564. * @param scene defines the hosting scene
  26565. */
  26566. constructor(name: string, scene?: Nullable<Scene>);
  26567. /**
  26568. * Returns the string "AbstractMesh"
  26569. * @returns "AbstractMesh"
  26570. */
  26571. getClassName(): string;
  26572. /**
  26573. * Gets a string representation of the current mesh
  26574. * @param fullDetails defines a boolean indicating if full details must be included
  26575. * @returns a string representation of the current mesh
  26576. */
  26577. toString(fullDetails?: boolean): string;
  26578. /**
  26579. * @hidden
  26580. */
  26581. protected _getEffectiveParent(): Nullable<Node>;
  26582. /** @hidden */
  26583. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26584. /** @hidden */
  26585. _rebuild(): void;
  26586. /** @hidden */
  26587. _resyncLightSources(): void;
  26588. /** @hidden */
  26589. _resyncLighSource(light: Light): void;
  26590. /** @hidden */
  26591. _unBindEffect(): void;
  26592. /** @hidden */
  26593. _removeLightSource(light: Light): void;
  26594. private _markSubMeshesAsDirty;
  26595. /** @hidden */
  26596. _markSubMeshesAsLightDirty(): void;
  26597. /** @hidden */
  26598. _markSubMeshesAsAttributesDirty(): void;
  26599. /** @hidden */
  26600. _markSubMeshesAsMiscDirty(): void;
  26601. /**
  26602. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26603. */
  26604. scaling: Vector3;
  26605. /**
  26606. * Returns true if the mesh is blocked. Implemented by child classes
  26607. */
  26608. readonly isBlocked: boolean;
  26609. /**
  26610. * Returns the mesh itself by default. Implemented by child classes
  26611. * @param camera defines the camera to use to pick the right LOD level
  26612. * @returns the currentAbstractMesh
  26613. */
  26614. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26615. /**
  26616. * Returns 0 by default. Implemented by child classes
  26617. * @returns an integer
  26618. */
  26619. getTotalVertices(): number;
  26620. /**
  26621. * Returns a positive integer : the total number of indices in this mesh geometry.
  26622. * @returns the numner of indices or zero if the mesh has no geometry.
  26623. */
  26624. getTotalIndices(): number;
  26625. /**
  26626. * Returns null by default. Implemented by child classes
  26627. * @returns null
  26628. */
  26629. getIndices(): Nullable<IndicesArray>;
  26630. /**
  26631. * Returns the array of the requested vertex data kind. Implemented by child classes
  26632. * @param kind defines the vertex data kind to use
  26633. * @returns null
  26634. */
  26635. getVerticesData(kind: string): Nullable<FloatArray>;
  26636. /**
  26637. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26638. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26639. * Note that a new underlying VertexBuffer object is created each call.
  26640. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26641. * @param kind defines vertex data kind:
  26642. * * VertexBuffer.PositionKind
  26643. * * VertexBuffer.UVKind
  26644. * * VertexBuffer.UV2Kind
  26645. * * VertexBuffer.UV3Kind
  26646. * * VertexBuffer.UV4Kind
  26647. * * VertexBuffer.UV5Kind
  26648. * * VertexBuffer.UV6Kind
  26649. * * VertexBuffer.ColorKind
  26650. * * VertexBuffer.MatricesIndicesKind
  26651. * * VertexBuffer.MatricesIndicesExtraKind
  26652. * * VertexBuffer.MatricesWeightsKind
  26653. * * VertexBuffer.MatricesWeightsExtraKind
  26654. * @param data defines the data source
  26655. * @param updatable defines if the data must be flagged as updatable (or static)
  26656. * @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
  26657. * @returns the current mesh
  26658. */
  26659. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26660. /**
  26661. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26662. * If the mesh has no geometry, it is simply returned as it is.
  26663. * @param kind defines vertex data kind:
  26664. * * VertexBuffer.PositionKind
  26665. * * VertexBuffer.UVKind
  26666. * * VertexBuffer.UV2Kind
  26667. * * VertexBuffer.UV3Kind
  26668. * * VertexBuffer.UV4Kind
  26669. * * VertexBuffer.UV5Kind
  26670. * * VertexBuffer.UV6Kind
  26671. * * VertexBuffer.ColorKind
  26672. * * VertexBuffer.MatricesIndicesKind
  26673. * * VertexBuffer.MatricesIndicesExtraKind
  26674. * * VertexBuffer.MatricesWeightsKind
  26675. * * VertexBuffer.MatricesWeightsExtraKind
  26676. * @param data defines the data source
  26677. * @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
  26678. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26679. * @returns the current mesh
  26680. */
  26681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26682. /**
  26683. * Sets the mesh indices,
  26684. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26685. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26686. * @param totalVertices Defines the total number of vertices
  26687. * @returns the current mesh
  26688. */
  26689. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26690. /**
  26691. * Gets a boolean indicating if specific vertex data is present
  26692. * @param kind defines the vertex data kind to use
  26693. * @returns true is data kind is present
  26694. */
  26695. isVerticesDataPresent(kind: string): boolean;
  26696. /**
  26697. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26698. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26699. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26700. * @returns a BoundingInfo
  26701. */
  26702. getBoundingInfo(): BoundingInfo;
  26703. /**
  26704. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26705. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26706. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26707. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26708. * @returns the current mesh
  26709. */
  26710. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26711. /**
  26712. * Overwrite the current bounding info
  26713. * @param boundingInfo defines the new bounding info
  26714. * @returns the current mesh
  26715. */
  26716. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26717. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26718. readonly useBones: boolean;
  26719. /** @hidden */
  26720. _preActivate(): void;
  26721. /** @hidden */
  26722. _preActivateForIntermediateRendering(renderId: number): void;
  26723. /** @hidden */
  26724. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26725. /** @hidden */
  26726. _postActivate(): void;
  26727. /** @hidden */
  26728. _freeze(): void;
  26729. /** @hidden */
  26730. _unFreeze(): void;
  26731. /**
  26732. * Gets the current world matrix
  26733. * @returns a Matrix
  26734. */
  26735. getWorldMatrix(): Matrix;
  26736. /** @hidden */
  26737. _getWorldMatrixDeterminant(): number;
  26738. /**
  26739. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26740. */
  26741. readonly isAnInstance: boolean;
  26742. /**
  26743. * Perform relative position change from the point of view of behind the front of the mesh.
  26744. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26745. * Supports definition of mesh facing forward or backward
  26746. * @param amountRight defines the distance on the right axis
  26747. * @param amountUp defines the distance on the up axis
  26748. * @param amountForward defines the distance on the forward axis
  26749. * @returns the current mesh
  26750. */
  26751. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26752. /**
  26753. * Calculate relative position change from the point of view of behind the front of the mesh.
  26754. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26755. * Supports definition of mesh facing forward or backward
  26756. * @param amountRight defines the distance on the right axis
  26757. * @param amountUp defines the distance on the up axis
  26758. * @param amountForward defines the distance on the forward axis
  26759. * @returns the new displacement vector
  26760. */
  26761. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26762. /**
  26763. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26764. * Supports definition of mesh facing forward or backward
  26765. * @param flipBack defines the flip
  26766. * @param twirlClockwise defines the twirl
  26767. * @param tiltRight defines the tilt
  26768. * @returns the current mesh
  26769. */
  26770. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26771. /**
  26772. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26773. * Supports definition of mesh facing forward or backward.
  26774. * @param flipBack defines the flip
  26775. * @param twirlClockwise defines the twirl
  26776. * @param tiltRight defines the tilt
  26777. * @returns the new rotation vector
  26778. */
  26779. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26780. /**
  26781. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26782. * This means the mesh underlying bounding box and sphere are recomputed.
  26783. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26784. * @returns the current mesh
  26785. */
  26786. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26787. /** @hidden */
  26788. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26789. /** @hidden */
  26790. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26791. /** @hidden */
  26792. _updateBoundingInfo(): AbstractMesh;
  26793. /** @hidden */
  26794. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26795. /** @hidden */
  26796. protected _afterComputeWorldMatrix(): void;
  26797. /** @hidden */
  26798. readonly _effectiveMesh: AbstractMesh;
  26799. /**
  26800. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26801. * A mesh is in the frustum if its bounding box intersects the frustum
  26802. * @param frustumPlanes defines the frustum to test
  26803. * @returns true if the mesh is in the frustum planes
  26804. */
  26805. isInFrustum(frustumPlanes: Plane[]): boolean;
  26806. /**
  26807. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26808. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26809. * @param frustumPlanes defines the frustum to test
  26810. * @returns true if the mesh is completely in the frustum planes
  26811. */
  26812. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26813. /**
  26814. * True if the mesh intersects another mesh or a SolidParticle object
  26815. * @param mesh defines a target mesh or SolidParticle to test
  26816. * @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)
  26817. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26818. * @returns true if there is an intersection
  26819. */
  26820. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26821. /**
  26822. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26823. * @param point defines the point to test
  26824. * @returns true if there is an intersection
  26825. */
  26826. intersectsPoint(point: Vector3): boolean;
  26827. /**
  26828. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26829. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26830. */
  26831. checkCollisions: boolean;
  26832. /**
  26833. * Gets Collider object used to compute collisions (not physics)
  26834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26835. */
  26836. readonly collider: Nullable<Collider>;
  26837. /**
  26838. * Move the mesh using collision engine
  26839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26840. * @param displacement defines the requested displacement vector
  26841. * @returns the current mesh
  26842. */
  26843. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26844. private _onCollisionPositionChange;
  26845. /** @hidden */
  26846. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26847. /** @hidden */
  26848. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26849. /** @hidden */
  26850. _checkCollision(collider: Collider): AbstractMesh;
  26851. /** @hidden */
  26852. _generatePointsArray(): boolean;
  26853. /**
  26854. * Checks if the passed Ray intersects with the mesh
  26855. * @param ray defines the ray to use
  26856. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26857. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26858. * @returns the picking info
  26859. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26860. */
  26861. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26862. /**
  26863. * Clones the current mesh
  26864. * @param name defines the mesh name
  26865. * @param newParent defines the new mesh parent
  26866. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26867. * @returns the new mesh
  26868. */
  26869. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26870. /**
  26871. * Disposes all the submeshes of the current meshnp
  26872. * @returns the current mesh
  26873. */
  26874. releaseSubMeshes(): AbstractMesh;
  26875. /**
  26876. * Releases resources associated with this abstract mesh.
  26877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26879. */
  26880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26881. /**
  26882. * Adds the passed mesh as a child to the current mesh
  26883. * @param mesh defines the child mesh
  26884. * @returns the current mesh
  26885. */
  26886. addChild(mesh: AbstractMesh): AbstractMesh;
  26887. /**
  26888. * Removes the passed mesh from the current mesh children list
  26889. * @param mesh defines the child mesh
  26890. * @returns the current mesh
  26891. */
  26892. removeChild(mesh: AbstractMesh): AbstractMesh;
  26893. /** @hidden */
  26894. private _initFacetData;
  26895. /**
  26896. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26897. * This method can be called within the render loop.
  26898. * 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
  26899. * @returns the current mesh
  26900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26901. */
  26902. updateFacetData(): AbstractMesh;
  26903. /**
  26904. * Returns the facetLocalNormals array.
  26905. * The normals are expressed in the mesh local spac
  26906. * @returns an array of Vector3
  26907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26908. */
  26909. getFacetLocalNormals(): Vector3[];
  26910. /**
  26911. * Returns the facetLocalPositions array.
  26912. * The facet positions are expressed in the mesh local space
  26913. * @returns an array of Vector3
  26914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26915. */
  26916. getFacetLocalPositions(): Vector3[];
  26917. /**
  26918. * Returns the facetLocalPartioning array
  26919. * @returns an array of array of numbers
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26921. */
  26922. getFacetLocalPartitioning(): number[][];
  26923. /**
  26924. * Returns the i-th facet position in the world system.
  26925. * This method allocates a new Vector3 per call
  26926. * @param i defines the facet index
  26927. * @returns a new Vector3
  26928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26929. */
  26930. getFacetPosition(i: number): Vector3;
  26931. /**
  26932. * Sets the reference Vector3 with the i-th facet position in the world system
  26933. * @param i defines the facet index
  26934. * @param ref defines the target vector
  26935. * @returns the current mesh
  26936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26937. */
  26938. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26939. /**
  26940. * Returns the i-th facet normal in the world system.
  26941. * This method allocates a new Vector3 per call
  26942. * @param i defines the facet index
  26943. * @returns a new Vector3
  26944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26945. */
  26946. getFacetNormal(i: number): Vector3;
  26947. /**
  26948. * Sets the reference Vector3 with the i-th facet normal in the world system
  26949. * @param i defines the facet index
  26950. * @param ref defines the target vector
  26951. * @returns the current mesh
  26952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26953. */
  26954. getFacetNormalToRef(i: number, ref: Vector3): this;
  26955. /**
  26956. * 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)
  26957. * @param x defines x coordinate
  26958. * @param y defines y coordinate
  26959. * @param z defines z coordinate
  26960. * @returns the array of facet indexes
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26962. */
  26963. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26964. /**
  26965. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26966. * @param projected sets as the (x,y,z) world projection on the facet
  26967. * @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
  26968. * @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
  26969. * @param x defines x coordinate
  26970. * @param y defines y coordinate
  26971. * @param z defines z coordinate
  26972. * @returns the face index if found (or null instead)
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26974. */
  26975. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26976. /**
  26977. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26978. * @param projected sets as the (x,y,z) local projection on the facet
  26979. * @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
  26980. * @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
  26981. * @param x defines x coordinate
  26982. * @param y defines y coordinate
  26983. * @param z defines z coordinate
  26984. * @returns the face index if found (or null instead)
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26986. */
  26987. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26988. /**
  26989. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26990. * @returns the parameters
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getFacetDataParameters(): any;
  26994. /**
  26995. * Disables the feature FacetData and frees the related memory
  26996. * @returns the current mesh
  26997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26998. */
  26999. disableFacetData(): AbstractMesh;
  27000. /**
  27001. * Updates the AbstractMesh indices array
  27002. * @param indices defines the data source
  27003. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27004. * @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)
  27005. * @returns the current mesh
  27006. */
  27007. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27008. /**
  27009. * Creates new normals data for the mesh
  27010. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27011. * @returns the current mesh
  27012. */
  27013. createNormals(updatable: boolean): AbstractMesh;
  27014. /**
  27015. * Align the mesh with a normal
  27016. * @param normal defines the normal to use
  27017. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27018. * @returns the current mesh
  27019. */
  27020. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27021. /** @hidden */
  27022. _checkOcclusionQuery(): boolean;
  27023. /**
  27024. * Disables the mesh edge rendering mode
  27025. * @returns the currentAbstractMesh
  27026. */
  27027. disableEdgesRendering(): AbstractMesh;
  27028. /**
  27029. * Enables the edge rendering mode on the mesh.
  27030. * This mode makes the mesh edges visible
  27031. * @param epsilon defines the maximal distance between two angles to detect a face
  27032. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27033. * @returns the currentAbstractMesh
  27034. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27035. */
  27036. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27037. }
  27038. }
  27039. declare module "babylonjs/Actions/actionEvent" {
  27040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27041. import { Nullable } from "babylonjs/types";
  27042. import { Sprite } from "babylonjs/Sprites/sprite";
  27043. import { Scene } from "babylonjs/scene";
  27044. import { Vector2 } from "babylonjs/Maths/math.vector";
  27045. /**
  27046. * Interface used to define ActionEvent
  27047. */
  27048. export interface IActionEvent {
  27049. /** The mesh or sprite that triggered the action */
  27050. source: any;
  27051. /** The X mouse cursor position at the time of the event */
  27052. pointerX: number;
  27053. /** The Y mouse cursor position at the time of the event */
  27054. pointerY: number;
  27055. /** The mesh that is currently pointed at (can be null) */
  27056. meshUnderPointer: Nullable<AbstractMesh>;
  27057. /** the original (browser) event that triggered the ActionEvent */
  27058. sourceEvent?: any;
  27059. /** additional data for the event */
  27060. additionalData?: any;
  27061. }
  27062. /**
  27063. * ActionEvent is the event being sent when an action is triggered.
  27064. */
  27065. export class ActionEvent implements IActionEvent {
  27066. /** The mesh or sprite that triggered the action */
  27067. source: any;
  27068. /** The X mouse cursor position at the time of the event */
  27069. pointerX: number;
  27070. /** The Y mouse cursor position at the time of the event */
  27071. pointerY: number;
  27072. /** The mesh that is currently pointed at (can be null) */
  27073. meshUnderPointer: Nullable<AbstractMesh>;
  27074. /** the original (browser) event that triggered the ActionEvent */
  27075. sourceEvent?: any;
  27076. /** additional data for the event */
  27077. additionalData?: any;
  27078. /**
  27079. * Creates a new ActionEvent
  27080. * @param source The mesh or sprite that triggered the action
  27081. * @param pointerX The X mouse cursor position at the time of the event
  27082. * @param pointerY The Y mouse cursor position at the time of the event
  27083. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27084. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27085. * @param additionalData additional data for the event
  27086. */
  27087. constructor(
  27088. /** The mesh or sprite that triggered the action */
  27089. source: any,
  27090. /** The X mouse cursor position at the time of the event */
  27091. pointerX: number,
  27092. /** The Y mouse cursor position at the time of the event */
  27093. pointerY: number,
  27094. /** The mesh that is currently pointed at (can be null) */
  27095. meshUnderPointer: Nullable<AbstractMesh>,
  27096. /** the original (browser) event that triggered the ActionEvent */
  27097. sourceEvent?: any,
  27098. /** additional data for the event */
  27099. additionalData?: any);
  27100. /**
  27101. * Helper function to auto-create an ActionEvent from a source mesh.
  27102. * @param source The source mesh that triggered the event
  27103. * @param evt The original (browser) event
  27104. * @param additionalData additional data for the event
  27105. * @returns the new ActionEvent
  27106. */
  27107. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27108. /**
  27109. * Helper function to auto-create an ActionEvent from a source sprite
  27110. * @param source The source sprite that triggered the event
  27111. * @param scene Scene associated with the sprite
  27112. * @param evt The original (browser) event
  27113. * @param additionalData additional data for the event
  27114. * @returns the new ActionEvent
  27115. */
  27116. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27117. /**
  27118. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27119. * @param scene the scene where the event occurred
  27120. * @param evt The original (browser) event
  27121. * @returns the new ActionEvent
  27122. */
  27123. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27124. /**
  27125. * Helper function to auto-create an ActionEvent from a primitive
  27126. * @param prim defines the target primitive
  27127. * @param pointerPos defines the pointer position
  27128. * @param evt The original (browser) event
  27129. * @param additionalData additional data for the event
  27130. * @returns the new ActionEvent
  27131. */
  27132. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27133. }
  27134. }
  27135. declare module "babylonjs/Actions/abstractActionManager" {
  27136. import { IDisposable } from "babylonjs/scene";
  27137. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27138. import { IAction } from "babylonjs/Actions/action";
  27139. import { Nullable } from "babylonjs/types";
  27140. /**
  27141. * Abstract class used to decouple action Manager from scene and meshes.
  27142. * Do not instantiate.
  27143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27144. */
  27145. export abstract class AbstractActionManager implements IDisposable {
  27146. /** Gets the list of active triggers */
  27147. static Triggers: {
  27148. [key: string]: number;
  27149. };
  27150. /** Gets the cursor to use when hovering items */
  27151. hoverCursor: string;
  27152. /** Gets the list of actions */
  27153. actions: IAction[];
  27154. /**
  27155. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27156. */
  27157. isRecursive: boolean;
  27158. /**
  27159. * Releases all associated resources
  27160. */
  27161. abstract dispose(): void;
  27162. /**
  27163. * Does this action manager has pointer triggers
  27164. */
  27165. abstract readonly hasPointerTriggers: boolean;
  27166. /**
  27167. * Does this action manager has pick triggers
  27168. */
  27169. abstract readonly hasPickTriggers: boolean;
  27170. /**
  27171. * Process a specific trigger
  27172. * @param trigger defines the trigger to process
  27173. * @param evt defines the event details to be processed
  27174. */
  27175. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27176. /**
  27177. * Does this action manager handles actions of any of the given triggers
  27178. * @param triggers defines the triggers to be tested
  27179. * @return a boolean indicating whether one (or more) of the triggers is handled
  27180. */
  27181. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27182. /**
  27183. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27184. * speed.
  27185. * @param triggerA defines the trigger to be tested
  27186. * @param triggerB defines the trigger to be tested
  27187. * @return a boolean indicating whether one (or more) of the triggers is handled
  27188. */
  27189. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27190. /**
  27191. * Does this action manager handles actions of a given trigger
  27192. * @param trigger defines the trigger to be tested
  27193. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27194. * @return whether the trigger is handled
  27195. */
  27196. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27197. /**
  27198. * Serialize this manager to a JSON object
  27199. * @param name defines the property name to store this manager
  27200. * @returns a JSON representation of this manager
  27201. */
  27202. abstract serialize(name: string): any;
  27203. /**
  27204. * Registers an action to this action manager
  27205. * @param action defines the action to be registered
  27206. * @return the action amended (prepared) after registration
  27207. */
  27208. abstract registerAction(action: IAction): Nullable<IAction>;
  27209. /**
  27210. * Unregisters an action to this action manager
  27211. * @param action defines the action to be unregistered
  27212. * @return a boolean indicating whether the action has been unregistered
  27213. */
  27214. abstract unregisterAction(action: IAction): Boolean;
  27215. /**
  27216. * Does exist one action manager with at least one trigger
  27217. **/
  27218. static readonly HasTriggers: boolean;
  27219. /**
  27220. * Does exist one action manager with at least one pick trigger
  27221. **/
  27222. static readonly HasPickTriggers: boolean;
  27223. /**
  27224. * Does exist one action manager that handles actions of a given trigger
  27225. * @param trigger defines the trigger to be tested
  27226. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27227. **/
  27228. static HasSpecificTrigger(trigger: number): boolean;
  27229. }
  27230. }
  27231. declare module "babylonjs/node" {
  27232. import { Scene } from "babylonjs/scene";
  27233. import { Nullable } from "babylonjs/types";
  27234. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27235. import { Engine } from "babylonjs/Engines/engine";
  27236. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27237. import { Observable } from "babylonjs/Misc/observable";
  27238. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27239. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27240. import { Animatable } from "babylonjs/Animations/animatable";
  27241. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27242. import { Animation } from "babylonjs/Animations/animation";
  27243. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27245. /**
  27246. * Defines how a node can be built from a string name.
  27247. */
  27248. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27249. /**
  27250. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27251. */
  27252. export class Node implements IBehaviorAware<Node> {
  27253. /** @hidden */
  27254. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27255. private static _NodeConstructors;
  27256. /**
  27257. * Add a new node constructor
  27258. * @param type defines the type name of the node to construct
  27259. * @param constructorFunc defines the constructor function
  27260. */
  27261. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27262. /**
  27263. * Returns a node constructor based on type name
  27264. * @param type defines the type name
  27265. * @param name defines the new node name
  27266. * @param scene defines the hosting scene
  27267. * @param options defines optional options to transmit to constructors
  27268. * @returns the new constructor or null
  27269. */
  27270. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27271. /**
  27272. * Gets or sets the name of the node
  27273. */
  27274. name: string;
  27275. /**
  27276. * Gets or sets the id of the node
  27277. */
  27278. id: string;
  27279. /**
  27280. * Gets or sets the unique id of the node
  27281. */
  27282. uniqueId: number;
  27283. /**
  27284. * Gets or sets a string used to store user defined state for the node
  27285. */
  27286. state: string;
  27287. /**
  27288. * Gets or sets an object used to store user defined information for the node
  27289. */
  27290. metadata: any;
  27291. /**
  27292. * For internal use only. Please do not use.
  27293. */
  27294. reservedDataStore: any;
  27295. /**
  27296. * List of inspectable custom properties (used by the Inspector)
  27297. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27298. */
  27299. inspectableCustomProperties: IInspectable[];
  27300. /**
  27301. * Gets or sets a boolean used to define if the node must be serialized
  27302. */
  27303. doNotSerialize: boolean;
  27304. /** @hidden */
  27305. _isDisposed: boolean;
  27306. /**
  27307. * Gets a list of Animations associated with the node
  27308. */
  27309. animations: import("babylonjs/Animations/animation").Animation[];
  27310. protected _ranges: {
  27311. [name: string]: Nullable<AnimationRange>;
  27312. };
  27313. /**
  27314. * Callback raised when the node is ready to be used
  27315. */
  27316. onReady: Nullable<(node: Node) => void>;
  27317. private _isEnabled;
  27318. private _isParentEnabled;
  27319. private _isReady;
  27320. /** @hidden */
  27321. _currentRenderId: number;
  27322. private _parentUpdateId;
  27323. /** @hidden */
  27324. _childUpdateId: number;
  27325. /** @hidden */
  27326. _waitingParentId: Nullable<string>;
  27327. /** @hidden */
  27328. _scene: Scene;
  27329. /** @hidden */
  27330. _cache: any;
  27331. private _parentNode;
  27332. private _children;
  27333. /** @hidden */
  27334. _worldMatrix: Matrix;
  27335. /** @hidden */
  27336. _worldMatrixDeterminant: number;
  27337. /** @hidden */
  27338. _worldMatrixDeterminantIsDirty: boolean;
  27339. /** @hidden */
  27340. private _sceneRootNodesIndex;
  27341. /**
  27342. * Gets a boolean indicating if the node has been disposed
  27343. * @returns true if the node was disposed
  27344. */
  27345. isDisposed(): boolean;
  27346. /**
  27347. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27348. * @see https://doc.babylonjs.com/how_to/parenting
  27349. */
  27350. parent: Nullable<Node>;
  27351. private addToSceneRootNodes;
  27352. private removeFromSceneRootNodes;
  27353. private _animationPropertiesOverride;
  27354. /**
  27355. * Gets or sets the animation properties override
  27356. */
  27357. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27358. /**
  27359. * Gets a string idenfifying the name of the class
  27360. * @returns "Node" string
  27361. */
  27362. getClassName(): string;
  27363. /** @hidden */
  27364. readonly _isNode: boolean;
  27365. /**
  27366. * An event triggered when the mesh is disposed
  27367. */
  27368. onDisposeObservable: Observable<Node>;
  27369. private _onDisposeObserver;
  27370. /**
  27371. * Sets a callback that will be raised when the node will be disposed
  27372. */
  27373. onDispose: () => void;
  27374. /**
  27375. * Creates a new Node
  27376. * @param name the name and id to be given to this node
  27377. * @param scene the scene this node will be added to
  27378. * @param addToRootNodes the node will be added to scene.rootNodes
  27379. */
  27380. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27381. /**
  27382. * Gets the scene of the node
  27383. * @returns a scene
  27384. */
  27385. getScene(): Scene;
  27386. /**
  27387. * Gets the engine of the node
  27388. * @returns a Engine
  27389. */
  27390. getEngine(): Engine;
  27391. private _behaviors;
  27392. /**
  27393. * Attach a behavior to the node
  27394. * @see http://doc.babylonjs.com/features/behaviour
  27395. * @param behavior defines the behavior to attach
  27396. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27397. * @returns the current Node
  27398. */
  27399. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27400. /**
  27401. * Remove an attached behavior
  27402. * @see http://doc.babylonjs.com/features/behaviour
  27403. * @param behavior defines the behavior to attach
  27404. * @returns the current Node
  27405. */
  27406. removeBehavior(behavior: Behavior<Node>): Node;
  27407. /**
  27408. * Gets the list of attached behaviors
  27409. * @see http://doc.babylonjs.com/features/behaviour
  27410. */
  27411. readonly behaviors: Behavior<Node>[];
  27412. /**
  27413. * Gets an attached behavior by name
  27414. * @param name defines the name of the behavior to look for
  27415. * @see http://doc.babylonjs.com/features/behaviour
  27416. * @returns null if behavior was not found else the requested behavior
  27417. */
  27418. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27419. /**
  27420. * Returns the latest update of the World matrix
  27421. * @returns a Matrix
  27422. */
  27423. getWorldMatrix(): Matrix;
  27424. /** @hidden */
  27425. _getWorldMatrixDeterminant(): number;
  27426. /**
  27427. * Returns directly the latest state of the mesh World matrix.
  27428. * A Matrix is returned.
  27429. */
  27430. readonly worldMatrixFromCache: Matrix;
  27431. /** @hidden */
  27432. _initCache(): void;
  27433. /** @hidden */
  27434. updateCache(force?: boolean): void;
  27435. /** @hidden */
  27436. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27437. /** @hidden */
  27438. _updateCache(ignoreParentClass?: boolean): void;
  27439. /** @hidden */
  27440. _isSynchronized(): boolean;
  27441. /** @hidden */
  27442. _markSyncedWithParent(): void;
  27443. /** @hidden */
  27444. isSynchronizedWithParent(): boolean;
  27445. /** @hidden */
  27446. isSynchronized(): boolean;
  27447. /**
  27448. * Is this node ready to be used/rendered
  27449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27450. * @return true if the node is ready
  27451. */
  27452. isReady(completeCheck?: boolean): boolean;
  27453. /**
  27454. * Is this node enabled?
  27455. * 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
  27456. * @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
  27457. * @return whether this node (and its parent) is enabled
  27458. */
  27459. isEnabled(checkAncestors?: boolean): boolean;
  27460. /** @hidden */
  27461. protected _syncParentEnabledState(): void;
  27462. /**
  27463. * Set the enabled state of this node
  27464. * @param value defines the new enabled state
  27465. */
  27466. setEnabled(value: boolean): void;
  27467. /**
  27468. * Is this node a descendant of the given node?
  27469. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27470. * @param ancestor defines the parent node to inspect
  27471. * @returns a boolean indicating if this node is a descendant of the given node
  27472. */
  27473. isDescendantOf(ancestor: Node): boolean;
  27474. /** @hidden */
  27475. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27476. /**
  27477. * Will return all nodes that have this node as ascendant
  27478. * @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
  27479. * @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
  27480. * @return all children nodes of all types
  27481. */
  27482. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27483. /**
  27484. * Get all child-meshes of this node
  27485. * @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)
  27486. * @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
  27487. * @returns an array of AbstractMesh
  27488. */
  27489. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27490. /**
  27491. * Get all direct children of this node
  27492. * @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
  27493. * @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)
  27494. * @returns an array of Node
  27495. */
  27496. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27497. /** @hidden */
  27498. _setReady(state: boolean): void;
  27499. /**
  27500. * Get an animation by name
  27501. * @param name defines the name of the animation to look for
  27502. * @returns null if not found else the requested animation
  27503. */
  27504. getAnimationByName(name: string): Nullable<Animation>;
  27505. /**
  27506. * Creates an animation range for this node
  27507. * @param name defines the name of the range
  27508. * @param from defines the starting key
  27509. * @param to defines the end key
  27510. */
  27511. createAnimationRange(name: string, from: number, to: number): void;
  27512. /**
  27513. * Delete a specific animation range
  27514. * @param name defines the name of the range to delete
  27515. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27516. */
  27517. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27518. /**
  27519. * Get an animation range by name
  27520. * @param name defines the name of the animation range to look for
  27521. * @returns null if not found else the requested animation range
  27522. */
  27523. getAnimationRange(name: string): Nullable<AnimationRange>;
  27524. /**
  27525. * Gets the list of all animation ranges defined on this node
  27526. * @returns an array
  27527. */
  27528. getAnimationRanges(): Nullable<AnimationRange>[];
  27529. /**
  27530. * Will start the animation sequence
  27531. * @param name defines the range frames for animation sequence
  27532. * @param loop defines if the animation should loop (false by default)
  27533. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27534. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27535. * @returns the object created for this animation. If range does not exist, it will return null
  27536. */
  27537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27538. /**
  27539. * Serialize animation ranges into a JSON compatible object
  27540. * @returns serialization object
  27541. */
  27542. serializeAnimationRanges(): any;
  27543. /**
  27544. * Computes the world matrix of the node
  27545. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27546. * @returns the world matrix
  27547. */
  27548. computeWorldMatrix(force?: boolean): Matrix;
  27549. /**
  27550. * Releases resources associated with this node.
  27551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27553. */
  27554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27555. /**
  27556. * Parse animation range data from a serialization object and store them into a given node
  27557. * @param node defines where to store the animation ranges
  27558. * @param parsedNode defines the serialization object to read data from
  27559. * @param scene defines the hosting scene
  27560. */
  27561. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27562. /**
  27563. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27564. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27565. * @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
  27566. * @returns the new bounding vectors
  27567. */
  27568. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27569. min: Vector3;
  27570. max: Vector3;
  27571. };
  27572. }
  27573. }
  27574. declare module "babylonjs/Animations/animation" {
  27575. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27576. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27577. import { Color3 } from "babylonjs/Maths/math.color";
  27578. import { Nullable } from "babylonjs/types";
  27579. import { Scene } from "babylonjs/scene";
  27580. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27581. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27582. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27583. import { Node } from "babylonjs/node";
  27584. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27585. import { Size } from "babylonjs/Maths/math.size";
  27586. import { Animatable } from "babylonjs/Animations/animatable";
  27587. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27588. /**
  27589. * @hidden
  27590. */
  27591. export class _IAnimationState {
  27592. key: number;
  27593. repeatCount: number;
  27594. workValue?: any;
  27595. loopMode?: number;
  27596. offsetValue?: any;
  27597. highLimitValue?: any;
  27598. }
  27599. /**
  27600. * Class used to store any kind of animation
  27601. */
  27602. export class Animation {
  27603. /**Name of the animation */
  27604. name: string;
  27605. /**Property to animate */
  27606. targetProperty: string;
  27607. /**The frames per second of the animation */
  27608. framePerSecond: number;
  27609. /**The data type of the animation */
  27610. dataType: number;
  27611. /**The loop mode of the animation */
  27612. loopMode?: number | undefined;
  27613. /**Specifies if blending should be enabled */
  27614. enableBlending?: boolean | undefined;
  27615. /**
  27616. * Use matrix interpolation instead of using direct key value when animating matrices
  27617. */
  27618. static AllowMatricesInterpolation: boolean;
  27619. /**
  27620. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27621. */
  27622. static AllowMatrixDecomposeForInterpolation: boolean;
  27623. /**
  27624. * Stores the key frames of the animation
  27625. */
  27626. private _keys;
  27627. /**
  27628. * Stores the easing function of the animation
  27629. */
  27630. private _easingFunction;
  27631. /**
  27632. * @hidden Internal use only
  27633. */
  27634. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27635. /**
  27636. * The set of event that will be linked to this animation
  27637. */
  27638. private _events;
  27639. /**
  27640. * Stores an array of target property paths
  27641. */
  27642. targetPropertyPath: string[];
  27643. /**
  27644. * Stores the blending speed of the animation
  27645. */
  27646. blendingSpeed: number;
  27647. /**
  27648. * Stores the animation ranges for the animation
  27649. */
  27650. private _ranges;
  27651. /**
  27652. * @hidden Internal use
  27653. */
  27654. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27655. /**
  27656. * Sets up an animation
  27657. * @param property The property to animate
  27658. * @param animationType The animation type to apply
  27659. * @param framePerSecond The frames per second of the animation
  27660. * @param easingFunction The easing function used in the animation
  27661. * @returns The created animation
  27662. */
  27663. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27664. /**
  27665. * Create and start an animation on a node
  27666. * @param name defines the name of the global animation that will be run on all nodes
  27667. * @param node defines the root node where the animation will take place
  27668. * @param targetProperty defines property to animate
  27669. * @param framePerSecond defines the number of frame per second yo use
  27670. * @param totalFrame defines the number of frames in total
  27671. * @param from defines the initial value
  27672. * @param to defines the final value
  27673. * @param loopMode defines which loop mode you want to use (off by default)
  27674. * @param easingFunction defines the easing function to use (linear by default)
  27675. * @param onAnimationEnd defines the callback to call when animation end
  27676. * @returns the animatable created for this animation
  27677. */
  27678. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27679. /**
  27680. * Create and start an animation on a node and its descendants
  27681. * @param name defines the name of the global animation that will be run on all nodes
  27682. * @param node defines the root node where the animation will take place
  27683. * @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
  27684. * @param targetProperty defines property to animate
  27685. * @param framePerSecond defines the number of frame per second to use
  27686. * @param totalFrame defines the number of frames in total
  27687. * @param from defines the initial value
  27688. * @param to defines the final value
  27689. * @param loopMode defines which loop mode you want to use (off by default)
  27690. * @param easingFunction defines the easing function to use (linear by default)
  27691. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27692. * @returns the list of animatables created for all nodes
  27693. * @example https://www.babylonjs-playground.com/#MH0VLI
  27694. */
  27695. 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[]>;
  27696. /**
  27697. * Creates a new animation, merges it with the existing animations and starts it
  27698. * @param name Name of the animation
  27699. * @param node Node which contains the scene that begins the animations
  27700. * @param targetProperty Specifies which property to animate
  27701. * @param framePerSecond The frames per second of the animation
  27702. * @param totalFrame The total number of frames
  27703. * @param from The frame at the beginning of the animation
  27704. * @param to The frame at the end of the animation
  27705. * @param loopMode Specifies the loop mode of the animation
  27706. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27707. * @param onAnimationEnd Callback to run once the animation is complete
  27708. * @returns Nullable animation
  27709. */
  27710. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27711. /**
  27712. * Transition property of an host to the target Value
  27713. * @param property The property to transition
  27714. * @param targetValue The target Value of the property
  27715. * @param host The object where the property to animate belongs
  27716. * @param scene Scene used to run the animation
  27717. * @param frameRate Framerate (in frame/s) to use
  27718. * @param transition The transition type we want to use
  27719. * @param duration The duration of the animation, in milliseconds
  27720. * @param onAnimationEnd Callback trigger at the end of the animation
  27721. * @returns Nullable animation
  27722. */
  27723. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27724. /**
  27725. * Return the array of runtime animations currently using this animation
  27726. */
  27727. readonly runtimeAnimations: RuntimeAnimation[];
  27728. /**
  27729. * Specifies if any of the runtime animations are currently running
  27730. */
  27731. readonly hasRunningRuntimeAnimations: boolean;
  27732. /**
  27733. * Initializes the animation
  27734. * @param name Name of the animation
  27735. * @param targetProperty Property to animate
  27736. * @param framePerSecond The frames per second of the animation
  27737. * @param dataType The data type of the animation
  27738. * @param loopMode The loop mode of the animation
  27739. * @param enableBlending Specifies if blending should be enabled
  27740. */
  27741. constructor(
  27742. /**Name of the animation */
  27743. name: string,
  27744. /**Property to animate */
  27745. targetProperty: string,
  27746. /**The frames per second of the animation */
  27747. framePerSecond: number,
  27748. /**The data type of the animation */
  27749. dataType: number,
  27750. /**The loop mode of the animation */
  27751. loopMode?: number | undefined,
  27752. /**Specifies if blending should be enabled */
  27753. enableBlending?: boolean | undefined);
  27754. /**
  27755. * Converts the animation to a string
  27756. * @param fullDetails support for multiple levels of logging within scene loading
  27757. * @returns String form of the animation
  27758. */
  27759. toString(fullDetails?: boolean): string;
  27760. /**
  27761. * Add an event to this animation
  27762. * @param event Event to add
  27763. */
  27764. addEvent(event: AnimationEvent): void;
  27765. /**
  27766. * Remove all events found at the given frame
  27767. * @param frame The frame to remove events from
  27768. */
  27769. removeEvents(frame: number): void;
  27770. /**
  27771. * Retrieves all the events from the animation
  27772. * @returns Events from the animation
  27773. */
  27774. getEvents(): AnimationEvent[];
  27775. /**
  27776. * Creates an animation range
  27777. * @param name Name of the animation range
  27778. * @param from Starting frame of the animation range
  27779. * @param to Ending frame of the animation
  27780. */
  27781. createRange(name: string, from: number, to: number): void;
  27782. /**
  27783. * Deletes an animation range by name
  27784. * @param name Name of the animation range to delete
  27785. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27786. */
  27787. deleteRange(name: string, deleteFrames?: boolean): void;
  27788. /**
  27789. * Gets the animation range by name, or null if not defined
  27790. * @param name Name of the animation range
  27791. * @returns Nullable animation range
  27792. */
  27793. getRange(name: string): Nullable<AnimationRange>;
  27794. /**
  27795. * Gets the key frames from the animation
  27796. * @returns The key frames of the animation
  27797. */
  27798. getKeys(): Array<IAnimationKey>;
  27799. /**
  27800. * Gets the highest frame rate of the animation
  27801. * @returns Highest frame rate of the animation
  27802. */
  27803. getHighestFrame(): number;
  27804. /**
  27805. * Gets the easing function of the animation
  27806. * @returns Easing function of the animation
  27807. */
  27808. getEasingFunction(): IEasingFunction;
  27809. /**
  27810. * Sets the easing function of the animation
  27811. * @param easingFunction A custom mathematical formula for animation
  27812. */
  27813. setEasingFunction(easingFunction: EasingFunction): void;
  27814. /**
  27815. * Interpolates a scalar linearly
  27816. * @param startValue Start value of the animation curve
  27817. * @param endValue End value of the animation curve
  27818. * @param gradient Scalar amount to interpolate
  27819. * @returns Interpolated scalar value
  27820. */
  27821. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27822. /**
  27823. * Interpolates a scalar cubically
  27824. * @param startValue Start value of the animation curve
  27825. * @param outTangent End tangent of the animation
  27826. * @param endValue End value of the animation curve
  27827. * @param inTangent Start tangent of the animation curve
  27828. * @param gradient Scalar amount to interpolate
  27829. * @returns Interpolated scalar value
  27830. */
  27831. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27832. /**
  27833. * Interpolates a quaternion using a spherical linear interpolation
  27834. * @param startValue Start value of the animation curve
  27835. * @param endValue End value of the animation curve
  27836. * @param gradient Scalar amount to interpolate
  27837. * @returns Interpolated quaternion value
  27838. */
  27839. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27840. /**
  27841. * Interpolates a quaternion cubically
  27842. * @param startValue Start value of the animation curve
  27843. * @param outTangent End tangent of the animation curve
  27844. * @param endValue End value of the animation curve
  27845. * @param inTangent Start tangent of the animation curve
  27846. * @param gradient Scalar amount to interpolate
  27847. * @returns Interpolated quaternion value
  27848. */
  27849. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27850. /**
  27851. * Interpolates a Vector3 linearl
  27852. * @param startValue Start value of the animation curve
  27853. * @param endValue End value of the animation curve
  27854. * @param gradient Scalar amount to interpolate
  27855. * @returns Interpolated scalar value
  27856. */
  27857. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27858. /**
  27859. * Interpolates a Vector3 cubically
  27860. * @param startValue Start value of the animation curve
  27861. * @param outTangent End tangent of the animation
  27862. * @param endValue End value of the animation curve
  27863. * @param inTangent Start tangent of the animation curve
  27864. * @param gradient Scalar amount to interpolate
  27865. * @returns InterpolatedVector3 value
  27866. */
  27867. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27868. /**
  27869. * Interpolates a Vector2 linearly
  27870. * @param startValue Start value of the animation curve
  27871. * @param endValue End value of the animation curve
  27872. * @param gradient Scalar amount to interpolate
  27873. * @returns Interpolated Vector2 value
  27874. */
  27875. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27876. /**
  27877. * Interpolates a Vector2 cubically
  27878. * @param startValue Start value of the animation curve
  27879. * @param outTangent End tangent of the animation
  27880. * @param endValue End value of the animation curve
  27881. * @param inTangent Start tangent of the animation curve
  27882. * @param gradient Scalar amount to interpolate
  27883. * @returns Interpolated Vector2 value
  27884. */
  27885. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27886. /**
  27887. * Interpolates a size linearly
  27888. * @param startValue Start value of the animation curve
  27889. * @param endValue End value of the animation curve
  27890. * @param gradient Scalar amount to interpolate
  27891. * @returns Interpolated Size value
  27892. */
  27893. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27894. /**
  27895. * Interpolates a Color3 linearly
  27896. * @param startValue Start value of the animation curve
  27897. * @param endValue End value of the animation curve
  27898. * @param gradient Scalar amount to interpolate
  27899. * @returns Interpolated Color3 value
  27900. */
  27901. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27902. /**
  27903. * @hidden Internal use only
  27904. */
  27905. _getKeyValue(value: any): any;
  27906. /**
  27907. * @hidden Internal use only
  27908. */
  27909. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27910. /**
  27911. * Defines the function to use to interpolate matrices
  27912. * @param startValue defines the start matrix
  27913. * @param endValue defines the end matrix
  27914. * @param gradient defines the gradient between both matrices
  27915. * @param result defines an optional target matrix where to store the interpolation
  27916. * @returns the interpolated matrix
  27917. */
  27918. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27919. /**
  27920. * Makes a copy of the animation
  27921. * @returns Cloned animation
  27922. */
  27923. clone(): Animation;
  27924. /**
  27925. * Sets the key frames of the animation
  27926. * @param values The animation key frames to set
  27927. */
  27928. setKeys(values: Array<IAnimationKey>): void;
  27929. /**
  27930. * Serializes the animation to an object
  27931. * @returns Serialized object
  27932. */
  27933. serialize(): any;
  27934. /**
  27935. * Float animation type
  27936. */
  27937. private static _ANIMATIONTYPE_FLOAT;
  27938. /**
  27939. * Vector3 animation type
  27940. */
  27941. private static _ANIMATIONTYPE_VECTOR3;
  27942. /**
  27943. * Quaternion animation type
  27944. */
  27945. private static _ANIMATIONTYPE_QUATERNION;
  27946. /**
  27947. * Matrix animation type
  27948. */
  27949. private static _ANIMATIONTYPE_MATRIX;
  27950. /**
  27951. * Color3 animation type
  27952. */
  27953. private static _ANIMATIONTYPE_COLOR3;
  27954. /**
  27955. * Vector2 animation type
  27956. */
  27957. private static _ANIMATIONTYPE_VECTOR2;
  27958. /**
  27959. * Size animation type
  27960. */
  27961. private static _ANIMATIONTYPE_SIZE;
  27962. /**
  27963. * Relative Loop Mode
  27964. */
  27965. private static _ANIMATIONLOOPMODE_RELATIVE;
  27966. /**
  27967. * Cycle Loop Mode
  27968. */
  27969. private static _ANIMATIONLOOPMODE_CYCLE;
  27970. /**
  27971. * Constant Loop Mode
  27972. */
  27973. private static _ANIMATIONLOOPMODE_CONSTANT;
  27974. /**
  27975. * Get the float animation type
  27976. */
  27977. static readonly ANIMATIONTYPE_FLOAT: number;
  27978. /**
  27979. * Get the Vector3 animation type
  27980. */
  27981. static readonly ANIMATIONTYPE_VECTOR3: number;
  27982. /**
  27983. * Get the Vector2 animation type
  27984. */
  27985. static readonly ANIMATIONTYPE_VECTOR2: number;
  27986. /**
  27987. * Get the Size animation type
  27988. */
  27989. static readonly ANIMATIONTYPE_SIZE: number;
  27990. /**
  27991. * Get the Quaternion animation type
  27992. */
  27993. static readonly ANIMATIONTYPE_QUATERNION: number;
  27994. /**
  27995. * Get the Matrix animation type
  27996. */
  27997. static readonly ANIMATIONTYPE_MATRIX: number;
  27998. /**
  27999. * Get the Color3 animation type
  28000. */
  28001. static readonly ANIMATIONTYPE_COLOR3: number;
  28002. /**
  28003. * Get the Relative Loop Mode
  28004. */
  28005. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28006. /**
  28007. * Get the Cycle Loop Mode
  28008. */
  28009. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28010. /**
  28011. * Get the Constant Loop Mode
  28012. */
  28013. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28014. /** @hidden */
  28015. static _UniversalLerp(left: any, right: any, amount: number): any;
  28016. /**
  28017. * Parses an animation object and creates an animation
  28018. * @param parsedAnimation Parsed animation object
  28019. * @returns Animation object
  28020. */
  28021. static Parse(parsedAnimation: any): Animation;
  28022. /**
  28023. * Appends the serialized animations from the source animations
  28024. * @param source Source containing the animations
  28025. * @param destination Target to store the animations
  28026. */
  28027. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28028. }
  28029. }
  28030. declare module "babylonjs/Animations/animatable.interface" {
  28031. import { Nullable } from "babylonjs/types";
  28032. import { Animation } from "babylonjs/Animations/animation";
  28033. /**
  28034. * Interface containing an array of animations
  28035. */
  28036. export interface IAnimatable {
  28037. /**
  28038. * Array of animations
  28039. */
  28040. animations: Nullable<Array<Animation>>;
  28041. }
  28042. }
  28043. declare module "babylonjs/Materials/fresnelParameters" {
  28044. import { Color3 } from "babylonjs/Maths/math.color";
  28045. /**
  28046. * This represents all the required information to add a fresnel effect on a material:
  28047. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28048. */
  28049. export class FresnelParameters {
  28050. private _isEnabled;
  28051. /**
  28052. * Define if the fresnel effect is enable or not.
  28053. */
  28054. isEnabled: boolean;
  28055. /**
  28056. * Define the color used on edges (grazing angle)
  28057. */
  28058. leftColor: Color3;
  28059. /**
  28060. * Define the color used on center
  28061. */
  28062. rightColor: Color3;
  28063. /**
  28064. * Define bias applied to computed fresnel term
  28065. */
  28066. bias: number;
  28067. /**
  28068. * Defined the power exponent applied to fresnel term
  28069. */
  28070. power: number;
  28071. /**
  28072. * Clones the current fresnel and its valuues
  28073. * @returns a clone fresnel configuration
  28074. */
  28075. clone(): FresnelParameters;
  28076. /**
  28077. * Serializes the current fresnel parameters to a JSON representation.
  28078. * @return the JSON serialization
  28079. */
  28080. serialize(): any;
  28081. /**
  28082. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28083. * @param parsedFresnelParameters Define the JSON representation
  28084. * @returns the parsed parameters
  28085. */
  28086. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28087. }
  28088. }
  28089. declare module "babylonjs/Misc/decorators" {
  28090. import { Nullable } from "babylonjs/types";
  28091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28092. import { Scene } from "babylonjs/scene";
  28093. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28094. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28095. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28096. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28097. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28098. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28099. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28100. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28101. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28102. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28103. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28104. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28105. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28106. /**
  28107. * Decorator used to define property that can be serialized as reference to a camera
  28108. * @param sourceName defines the name of the property to decorate
  28109. */
  28110. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28111. /**
  28112. * Class used to help serialization objects
  28113. */
  28114. export class SerializationHelper {
  28115. /** @hidden */
  28116. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28117. /** @hidden */
  28118. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28119. /** @hidden */
  28120. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28121. /** @hidden */
  28122. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28123. /**
  28124. * Appends the serialized animations from the source animations
  28125. * @param source Source containing the animations
  28126. * @param destination Target to store the animations
  28127. */
  28128. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28129. /**
  28130. * Static function used to serialized a specific entity
  28131. * @param entity defines the entity to serialize
  28132. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28133. * @returns a JSON compatible object representing the serialization of the entity
  28134. */
  28135. static Serialize<T>(entity: T, serializationObject?: any): any;
  28136. /**
  28137. * Creates a new entity from a serialization data object
  28138. * @param creationFunction defines a function used to instanciated the new entity
  28139. * @param source defines the source serialization data
  28140. * @param scene defines the hosting scene
  28141. * @param rootUrl defines the root url for resources
  28142. * @returns a new entity
  28143. */
  28144. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28145. /**
  28146. * Clones an object
  28147. * @param creationFunction defines the function used to instanciate the new object
  28148. * @param source defines the source object
  28149. * @returns the cloned object
  28150. */
  28151. static Clone<T>(creationFunction: () => T, source: T): T;
  28152. /**
  28153. * Instanciates a new object based on a source one (some data will be shared between both object)
  28154. * @param creationFunction defines the function used to instanciate the new object
  28155. * @param source defines the source object
  28156. * @returns the new object
  28157. */
  28158. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28159. }
  28160. }
  28161. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28162. import { Nullable } from "babylonjs/types";
  28163. /**
  28164. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28165. */
  28166. export interface CubeMapInfo {
  28167. /**
  28168. * The pixel array for the front face.
  28169. * This is stored in format, left to right, up to down format.
  28170. */
  28171. front: Nullable<ArrayBufferView>;
  28172. /**
  28173. * The pixel array for the back face.
  28174. * This is stored in format, left to right, up to down format.
  28175. */
  28176. back: Nullable<ArrayBufferView>;
  28177. /**
  28178. * The pixel array for the left face.
  28179. * This is stored in format, left to right, up to down format.
  28180. */
  28181. left: Nullable<ArrayBufferView>;
  28182. /**
  28183. * The pixel array for the right face.
  28184. * This is stored in format, left to right, up to down format.
  28185. */
  28186. right: Nullable<ArrayBufferView>;
  28187. /**
  28188. * The pixel array for the up face.
  28189. * This is stored in format, left to right, up to down format.
  28190. */
  28191. up: Nullable<ArrayBufferView>;
  28192. /**
  28193. * The pixel array for the down face.
  28194. * This is stored in format, left to right, up to down format.
  28195. */
  28196. down: Nullable<ArrayBufferView>;
  28197. /**
  28198. * The size of the cubemap stored.
  28199. *
  28200. * Each faces will be size * size pixels.
  28201. */
  28202. size: number;
  28203. /**
  28204. * The format of the texture.
  28205. *
  28206. * RGBA, RGB.
  28207. */
  28208. format: number;
  28209. /**
  28210. * The type of the texture data.
  28211. *
  28212. * UNSIGNED_INT, FLOAT.
  28213. */
  28214. type: number;
  28215. /**
  28216. * Specifies whether the texture is in gamma space.
  28217. */
  28218. gammaSpace: boolean;
  28219. }
  28220. /**
  28221. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28222. */
  28223. export class PanoramaToCubeMapTools {
  28224. private static FACE_FRONT;
  28225. private static FACE_BACK;
  28226. private static FACE_RIGHT;
  28227. private static FACE_LEFT;
  28228. private static FACE_DOWN;
  28229. private static FACE_UP;
  28230. /**
  28231. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28232. *
  28233. * @param float32Array The source data.
  28234. * @param inputWidth The width of the input panorama.
  28235. * @param inputHeight The height of the input panorama.
  28236. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28237. * @return The cubemap data
  28238. */
  28239. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28240. private static CreateCubemapTexture;
  28241. private static CalcProjectionSpherical;
  28242. }
  28243. }
  28244. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28245. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28247. import { Nullable } from "babylonjs/types";
  28248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28249. /**
  28250. * Helper class dealing with the extraction of spherical polynomial dataArray
  28251. * from a cube map.
  28252. */
  28253. export class CubeMapToSphericalPolynomialTools {
  28254. private static FileFaces;
  28255. /**
  28256. * Converts a texture to the according Spherical Polynomial data.
  28257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28258. *
  28259. * @param texture The texture to extract the information from.
  28260. * @return The Spherical Polynomial data.
  28261. */
  28262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28263. /**
  28264. * Converts a cubemap to the according Spherical Polynomial data.
  28265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28266. *
  28267. * @param cubeInfo The Cube map to extract the information from.
  28268. * @return The Spherical Polynomial data.
  28269. */
  28270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/guid" {
  28274. /**
  28275. * Class used to manipulate GUIDs
  28276. */
  28277. export class GUID {
  28278. /**
  28279. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28280. * Be aware Math.random() could cause collisions, but:
  28281. * "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"
  28282. * @returns a pseudo random id
  28283. */
  28284. static RandomId(): string;
  28285. }
  28286. }
  28287. declare module "babylonjs/Materials/Textures/baseTexture" {
  28288. import { Observable } from "babylonjs/Misc/observable";
  28289. import { Nullable } from "babylonjs/types";
  28290. import { Scene } from "babylonjs/scene";
  28291. import { Matrix } from "babylonjs/Maths/math.vector";
  28292. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28293. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28294. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28295. import { ISize } from "babylonjs/Maths/math.size";
  28296. /**
  28297. * Base class of all the textures in babylon.
  28298. * It groups all the common properties the materials, post process, lights... might need
  28299. * in order to make a correct use of the texture.
  28300. */
  28301. export class BaseTexture implements IAnimatable {
  28302. /**
  28303. * Default anisotropic filtering level for the application.
  28304. * It is set to 4 as a good tradeoff between perf and quality.
  28305. */
  28306. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28307. /**
  28308. * Gets or sets the unique id of the texture
  28309. */
  28310. uniqueId: number;
  28311. /**
  28312. * Define the name of the texture.
  28313. */
  28314. name: string;
  28315. /**
  28316. * Gets or sets an object used to store user defined information.
  28317. */
  28318. metadata: any;
  28319. /**
  28320. * For internal use only. Please do not use.
  28321. */
  28322. reservedDataStore: any;
  28323. private _hasAlpha;
  28324. /**
  28325. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28326. */
  28327. hasAlpha: boolean;
  28328. /**
  28329. * Defines if the alpha value should be determined via the rgb values.
  28330. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28331. */
  28332. getAlphaFromRGB: boolean;
  28333. /**
  28334. * Intensity or strength of the texture.
  28335. * It is commonly used by materials to fine tune the intensity of the texture
  28336. */
  28337. level: number;
  28338. /**
  28339. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28340. * This is part of the texture as textures usually maps to one uv set.
  28341. */
  28342. coordinatesIndex: number;
  28343. private _coordinatesMode;
  28344. /**
  28345. * How a texture is mapped.
  28346. *
  28347. * | Value | Type | Description |
  28348. * | ----- | ----------------------------------- | ----------- |
  28349. * | 0 | EXPLICIT_MODE | |
  28350. * | 1 | SPHERICAL_MODE | |
  28351. * | 2 | PLANAR_MODE | |
  28352. * | 3 | CUBIC_MODE | |
  28353. * | 4 | PROJECTION_MODE | |
  28354. * | 5 | SKYBOX_MODE | |
  28355. * | 6 | INVCUBIC_MODE | |
  28356. * | 7 | EQUIRECTANGULAR_MODE | |
  28357. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28358. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28359. */
  28360. coordinatesMode: number;
  28361. /**
  28362. * | Value | Type | Description |
  28363. * | ----- | ------------------ | ----------- |
  28364. * | 0 | CLAMP_ADDRESSMODE | |
  28365. * | 1 | WRAP_ADDRESSMODE | |
  28366. * | 2 | MIRROR_ADDRESSMODE | |
  28367. */
  28368. wrapU: number;
  28369. /**
  28370. * | Value | Type | Description |
  28371. * | ----- | ------------------ | ----------- |
  28372. * | 0 | CLAMP_ADDRESSMODE | |
  28373. * | 1 | WRAP_ADDRESSMODE | |
  28374. * | 2 | MIRROR_ADDRESSMODE | |
  28375. */
  28376. wrapV: number;
  28377. /**
  28378. * | Value | Type | Description |
  28379. * | ----- | ------------------ | ----------- |
  28380. * | 0 | CLAMP_ADDRESSMODE | |
  28381. * | 1 | WRAP_ADDRESSMODE | |
  28382. * | 2 | MIRROR_ADDRESSMODE | |
  28383. */
  28384. wrapR: number;
  28385. /**
  28386. * With compliant hardware and browser (supporting anisotropic filtering)
  28387. * this defines the level of anisotropic filtering in the texture.
  28388. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28389. */
  28390. anisotropicFilteringLevel: number;
  28391. /**
  28392. * Define if the texture is a cube texture or if false a 2d texture.
  28393. */
  28394. isCube: boolean;
  28395. /**
  28396. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28397. */
  28398. is3D: boolean;
  28399. /**
  28400. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28401. * HDR texture are usually stored in linear space.
  28402. * This only impacts the PBR and Background materials
  28403. */
  28404. gammaSpace: boolean;
  28405. /**
  28406. * Gets whether or not the texture contains RGBD data.
  28407. */
  28408. readonly isRGBD: boolean;
  28409. /**
  28410. * Is Z inverted in the texture (useful in a cube texture).
  28411. */
  28412. invertZ: boolean;
  28413. /**
  28414. * Are mip maps generated for this texture or not.
  28415. */
  28416. readonly noMipmap: boolean;
  28417. /**
  28418. * @hidden
  28419. */
  28420. lodLevelInAlpha: boolean;
  28421. /**
  28422. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28423. */
  28424. lodGenerationOffset: number;
  28425. /**
  28426. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28427. */
  28428. lodGenerationScale: number;
  28429. /**
  28430. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28431. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28432. * average roughness values.
  28433. */
  28434. linearSpecularLOD: boolean;
  28435. /**
  28436. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28437. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28438. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28439. */
  28440. irradianceTexture: Nullable<BaseTexture>;
  28441. /**
  28442. * Define if the texture is a render target.
  28443. */
  28444. isRenderTarget: boolean;
  28445. /**
  28446. * Define the unique id of the texture in the scene.
  28447. */
  28448. readonly uid: string;
  28449. /**
  28450. * Return a string representation of the texture.
  28451. * @returns the texture as a string
  28452. */
  28453. toString(): string;
  28454. /**
  28455. * Get the class name of the texture.
  28456. * @returns "BaseTexture"
  28457. */
  28458. getClassName(): string;
  28459. /**
  28460. * Define the list of animation attached to the texture.
  28461. */
  28462. animations: import("babylonjs/Animations/animation").Animation[];
  28463. /**
  28464. * An event triggered when the texture is disposed.
  28465. */
  28466. onDisposeObservable: Observable<BaseTexture>;
  28467. private _onDisposeObserver;
  28468. /**
  28469. * Callback triggered when the texture has been disposed.
  28470. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28471. */
  28472. onDispose: () => void;
  28473. /**
  28474. * Define the current state of the loading sequence when in delayed load mode.
  28475. */
  28476. delayLoadState: number;
  28477. private _scene;
  28478. /** @hidden */
  28479. _texture: Nullable<InternalTexture>;
  28480. private _uid;
  28481. /**
  28482. * Define if the texture is preventinga material to render or not.
  28483. * If not and the texture is not ready, the engine will use a default black texture instead.
  28484. */
  28485. readonly isBlocking: boolean;
  28486. /**
  28487. * Instantiates a new BaseTexture.
  28488. * Base class of all the textures in babylon.
  28489. * It groups all the common properties the materials, post process, lights... might need
  28490. * in order to make a correct use of the texture.
  28491. * @param scene Define the scene the texture blongs to
  28492. */
  28493. constructor(scene: Nullable<Scene>);
  28494. /**
  28495. * Get the scene the texture belongs to.
  28496. * @returns the scene or null if undefined
  28497. */
  28498. getScene(): Nullable<Scene>;
  28499. /**
  28500. * Get the texture transform matrix used to offset tile the texture for istance.
  28501. * @returns the transformation matrix
  28502. */
  28503. getTextureMatrix(): Matrix;
  28504. /**
  28505. * Get the texture reflection matrix used to rotate/transform the reflection.
  28506. * @returns the reflection matrix
  28507. */
  28508. getReflectionTextureMatrix(): Matrix;
  28509. /**
  28510. * Get the underlying lower level texture from Babylon.
  28511. * @returns the insternal texture
  28512. */
  28513. getInternalTexture(): Nullable<InternalTexture>;
  28514. /**
  28515. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28516. * @returns true if ready or not blocking
  28517. */
  28518. isReadyOrNotBlocking(): boolean;
  28519. /**
  28520. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28521. * @returns true if fully ready
  28522. */
  28523. isReady(): boolean;
  28524. private _cachedSize;
  28525. /**
  28526. * Get the size of the texture.
  28527. * @returns the texture size.
  28528. */
  28529. getSize(): ISize;
  28530. /**
  28531. * Get the base size of the texture.
  28532. * It can be different from the size if the texture has been resized for POT for instance
  28533. * @returns the base size
  28534. */
  28535. getBaseSize(): ISize;
  28536. /**
  28537. * Update the sampling mode of the texture.
  28538. * Default is Trilinear mode.
  28539. *
  28540. * | Value | Type | Description |
  28541. * | ----- | ------------------ | ----------- |
  28542. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28543. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28544. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28545. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28546. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28547. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28548. * | 7 | NEAREST_LINEAR | |
  28549. * | 8 | NEAREST_NEAREST | |
  28550. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28551. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28552. * | 11 | LINEAR_LINEAR | |
  28553. * | 12 | LINEAR_NEAREST | |
  28554. *
  28555. * > _mag_: magnification filter (close to the viewer)
  28556. * > _min_: minification filter (far from the viewer)
  28557. * > _mip_: filter used between mip map levels
  28558. *@param samplingMode Define the new sampling mode of the texture
  28559. */
  28560. updateSamplingMode(samplingMode: number): void;
  28561. /**
  28562. * Scales the texture if is `canRescale()`
  28563. * @param ratio the resize factor we want to use to rescale
  28564. */
  28565. scale(ratio: number): void;
  28566. /**
  28567. * Get if the texture can rescale.
  28568. */
  28569. readonly canRescale: boolean;
  28570. /** @hidden */
  28571. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28572. /** @hidden */
  28573. _rebuild(): void;
  28574. /**
  28575. * Triggers the load sequence in delayed load mode.
  28576. */
  28577. delayLoad(): void;
  28578. /**
  28579. * Clones the texture.
  28580. * @returns the cloned texture
  28581. */
  28582. clone(): Nullable<BaseTexture>;
  28583. /**
  28584. * Get the texture underlying type (INT, FLOAT...)
  28585. */
  28586. readonly textureType: number;
  28587. /**
  28588. * Get the texture underlying format (RGB, RGBA...)
  28589. */
  28590. readonly textureFormat: number;
  28591. /**
  28592. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28593. * This will returns an RGBA array buffer containing either in values (0-255) or
  28594. * float values (0-1) depending of the underlying buffer type.
  28595. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28596. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28597. * @param buffer defines a user defined buffer to fill with data (can be null)
  28598. * @returns The Array buffer containing the pixels data.
  28599. */
  28600. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28601. /**
  28602. * Release and destroy the underlying lower level texture aka internalTexture.
  28603. */
  28604. releaseInternalTexture(): void;
  28605. /**
  28606. * Get the polynomial representation of the texture data.
  28607. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28608. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28609. */
  28610. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28611. /** @hidden */
  28612. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28613. /** @hidden */
  28614. readonly _lodTextureMid: Nullable<BaseTexture>;
  28615. /** @hidden */
  28616. readonly _lodTextureLow: Nullable<BaseTexture>;
  28617. /**
  28618. * Dispose the texture and release its associated resources.
  28619. */
  28620. dispose(): void;
  28621. /**
  28622. * Serialize the texture into a JSON representation that can be parsed later on.
  28623. * @returns the JSON representation of the texture
  28624. */
  28625. serialize(): any;
  28626. /**
  28627. * Helper function to be called back once a list of texture contains only ready textures.
  28628. * @param textures Define the list of textures to wait for
  28629. * @param callback Define the callback triggered once the entire list will be ready
  28630. */
  28631. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28632. }
  28633. }
  28634. declare module "babylonjs/Materials/Textures/internalTexture" {
  28635. import { Observable } from "babylonjs/Misc/observable";
  28636. import { Nullable, int } from "babylonjs/types";
  28637. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28638. import { Engine } from "babylonjs/Engines/engine";
  28639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28640. /**
  28641. * Class used to store data associated with WebGL texture data for the engine
  28642. * This class should not be used directly
  28643. */
  28644. export class InternalTexture {
  28645. /** @hidden */
  28646. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28647. /**
  28648. * The source of the texture data is unknown
  28649. */
  28650. static DATASOURCE_UNKNOWN: number;
  28651. /**
  28652. * Texture data comes from an URL
  28653. */
  28654. static DATASOURCE_URL: number;
  28655. /**
  28656. * Texture data is only used for temporary storage
  28657. */
  28658. static DATASOURCE_TEMP: number;
  28659. /**
  28660. * Texture data comes from raw data (ArrayBuffer)
  28661. */
  28662. static DATASOURCE_RAW: number;
  28663. /**
  28664. * Texture content is dynamic (video or dynamic texture)
  28665. */
  28666. static DATASOURCE_DYNAMIC: number;
  28667. /**
  28668. * Texture content is generated by rendering to it
  28669. */
  28670. static DATASOURCE_RENDERTARGET: number;
  28671. /**
  28672. * Texture content is part of a multi render target process
  28673. */
  28674. static DATASOURCE_MULTIRENDERTARGET: number;
  28675. /**
  28676. * Texture data comes from a cube data file
  28677. */
  28678. static DATASOURCE_CUBE: number;
  28679. /**
  28680. * Texture data comes from a raw cube data
  28681. */
  28682. static DATASOURCE_CUBERAW: number;
  28683. /**
  28684. * Texture data come from a prefiltered cube data file
  28685. */
  28686. static DATASOURCE_CUBEPREFILTERED: number;
  28687. /**
  28688. * Texture content is raw 3D data
  28689. */
  28690. static DATASOURCE_RAW3D: number;
  28691. /**
  28692. * Texture content is a depth texture
  28693. */
  28694. static DATASOURCE_DEPTHTEXTURE: number;
  28695. /**
  28696. * Texture data comes from a raw cube data encoded with RGBD
  28697. */
  28698. static DATASOURCE_CUBERAW_RGBD: number;
  28699. /**
  28700. * Defines if the texture is ready
  28701. */
  28702. isReady: boolean;
  28703. /**
  28704. * Defines if the texture is a cube texture
  28705. */
  28706. isCube: boolean;
  28707. /**
  28708. * Defines if the texture contains 3D data
  28709. */
  28710. is3D: boolean;
  28711. /**
  28712. * Defines if the texture contains multiview data
  28713. */
  28714. isMultiview: boolean;
  28715. /**
  28716. * Gets the URL used to load this texture
  28717. */
  28718. url: string;
  28719. /**
  28720. * Gets the sampling mode of the texture
  28721. */
  28722. samplingMode: number;
  28723. /**
  28724. * Gets a boolean indicating if the texture needs mipmaps generation
  28725. */
  28726. generateMipMaps: boolean;
  28727. /**
  28728. * Gets the number of samples used by the texture (WebGL2+ only)
  28729. */
  28730. samples: number;
  28731. /**
  28732. * Gets the type of the texture (int, float...)
  28733. */
  28734. type: number;
  28735. /**
  28736. * Gets the format of the texture (RGB, RGBA...)
  28737. */
  28738. format: number;
  28739. /**
  28740. * Observable called when the texture is loaded
  28741. */
  28742. onLoadedObservable: Observable<InternalTexture>;
  28743. /**
  28744. * Gets the width of the texture
  28745. */
  28746. width: number;
  28747. /**
  28748. * Gets the height of the texture
  28749. */
  28750. height: number;
  28751. /**
  28752. * Gets the depth of the texture
  28753. */
  28754. depth: number;
  28755. /**
  28756. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28757. */
  28758. baseWidth: number;
  28759. /**
  28760. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28761. */
  28762. baseHeight: number;
  28763. /**
  28764. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28765. */
  28766. baseDepth: number;
  28767. /**
  28768. * Gets a boolean indicating if the texture is inverted on Y axis
  28769. */
  28770. invertY: boolean;
  28771. /** @hidden */
  28772. _invertVScale: boolean;
  28773. /** @hidden */
  28774. _associatedChannel: number;
  28775. /** @hidden */
  28776. _dataSource: number;
  28777. /** @hidden */
  28778. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28779. /** @hidden */
  28780. _bufferView: Nullable<ArrayBufferView>;
  28781. /** @hidden */
  28782. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28783. /** @hidden */
  28784. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28785. /** @hidden */
  28786. _size: number;
  28787. /** @hidden */
  28788. _extension: string;
  28789. /** @hidden */
  28790. _files: Nullable<string[]>;
  28791. /** @hidden */
  28792. _workingCanvas: Nullable<HTMLCanvasElement>;
  28793. /** @hidden */
  28794. _workingContext: Nullable<CanvasRenderingContext2D>;
  28795. /** @hidden */
  28796. _framebuffer: Nullable<WebGLFramebuffer>;
  28797. /** @hidden */
  28798. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28799. /** @hidden */
  28800. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28801. /** @hidden */
  28802. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28803. /** @hidden */
  28804. _attachments: Nullable<number[]>;
  28805. /** @hidden */
  28806. _cachedCoordinatesMode: Nullable<number>;
  28807. /** @hidden */
  28808. _cachedWrapU: Nullable<number>;
  28809. /** @hidden */
  28810. _cachedWrapV: Nullable<number>;
  28811. /** @hidden */
  28812. _cachedWrapR: Nullable<number>;
  28813. /** @hidden */
  28814. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28815. /** @hidden */
  28816. _isDisabled: boolean;
  28817. /** @hidden */
  28818. _compression: Nullable<string>;
  28819. /** @hidden */
  28820. _generateStencilBuffer: boolean;
  28821. /** @hidden */
  28822. _generateDepthBuffer: boolean;
  28823. /** @hidden */
  28824. _comparisonFunction: number;
  28825. /** @hidden */
  28826. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28827. /** @hidden */
  28828. _lodGenerationScale: number;
  28829. /** @hidden */
  28830. _lodGenerationOffset: number;
  28831. /** @hidden */
  28832. _colorTextureArray: Nullable<WebGLTexture>;
  28833. /** @hidden */
  28834. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28835. /** @hidden */
  28836. _lodTextureHigh: Nullable<BaseTexture>;
  28837. /** @hidden */
  28838. _lodTextureMid: Nullable<BaseTexture>;
  28839. /** @hidden */
  28840. _lodTextureLow: Nullable<BaseTexture>;
  28841. /** @hidden */
  28842. _isRGBD: boolean;
  28843. /** @hidden */
  28844. _linearSpecularLOD: boolean;
  28845. /** @hidden */
  28846. _irradianceTexture: Nullable<BaseTexture>;
  28847. /** @hidden */
  28848. _webGLTexture: Nullable<WebGLTexture>;
  28849. /** @hidden */
  28850. _references: number;
  28851. private _engine;
  28852. /**
  28853. * Gets the Engine the texture belongs to.
  28854. * @returns The babylon engine
  28855. */
  28856. getEngine(): Engine;
  28857. /**
  28858. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28859. */
  28860. readonly dataSource: number;
  28861. /**
  28862. * Creates a new InternalTexture
  28863. * @param engine defines the engine to use
  28864. * @param dataSource defines the type of data that will be used
  28865. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28866. */
  28867. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28868. /**
  28869. * Increments the number of references (ie. the number of Texture that point to it)
  28870. */
  28871. incrementReferences(): void;
  28872. /**
  28873. * Change the size of the texture (not the size of the content)
  28874. * @param width defines the new width
  28875. * @param height defines the new height
  28876. * @param depth defines the new depth (1 by default)
  28877. */
  28878. updateSize(width: int, height: int, depth?: int): void;
  28879. /** @hidden */
  28880. _rebuild(): void;
  28881. /** @hidden */
  28882. _swapAndDie(target: InternalTexture): void;
  28883. /**
  28884. * Dispose the current allocated resources
  28885. */
  28886. dispose(): void;
  28887. }
  28888. }
  28889. declare module "babylonjs/Materials/effect" {
  28890. import { Observable } from "babylonjs/Misc/observable";
  28891. import { Nullable } from "babylonjs/types";
  28892. import { IDisposable } from "babylonjs/scene";
  28893. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28894. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28895. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28896. import { Engine } from "babylonjs/Engines/engine";
  28897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28899. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28902. /**
  28903. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28904. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28905. */
  28906. export class EffectFallbacks {
  28907. private _defines;
  28908. private _currentRank;
  28909. private _maxRank;
  28910. private _mesh;
  28911. /**
  28912. * Removes the fallback from the bound mesh.
  28913. */
  28914. unBindMesh(): void;
  28915. /**
  28916. * Adds a fallback on the specified property.
  28917. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28918. * @param define The name of the define in the shader
  28919. */
  28920. addFallback(rank: number, define: string): void;
  28921. /**
  28922. * Sets the mesh to use CPU skinning when needing to fallback.
  28923. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28924. * @param mesh The mesh to use the fallbacks.
  28925. */
  28926. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28927. /**
  28928. * Checks to see if more fallbacks are still availible.
  28929. */
  28930. readonly isMoreFallbacks: boolean;
  28931. /**
  28932. * Removes the defines that should be removed when falling back.
  28933. * @param currentDefines defines the current define statements for the shader.
  28934. * @param effect defines the current effect we try to compile
  28935. * @returns The resulting defines with defines of the current rank removed.
  28936. */
  28937. reduce(currentDefines: string, effect: Effect): string;
  28938. }
  28939. /**
  28940. * Options to be used when creating an effect.
  28941. */
  28942. export class EffectCreationOptions {
  28943. /**
  28944. * Atrributes that will be used in the shader.
  28945. */
  28946. attributes: string[];
  28947. /**
  28948. * Uniform varible names that will be set in the shader.
  28949. */
  28950. uniformsNames: string[];
  28951. /**
  28952. * Uniform buffer varible names that will be set in the shader.
  28953. */
  28954. uniformBuffersNames: string[];
  28955. /**
  28956. * Sampler texture variable names that will be set in the shader.
  28957. */
  28958. samplers: string[];
  28959. /**
  28960. * Define statements that will be set in the shader.
  28961. */
  28962. defines: any;
  28963. /**
  28964. * Possible fallbacks for this effect to improve performance when needed.
  28965. */
  28966. fallbacks: Nullable<EffectFallbacks>;
  28967. /**
  28968. * Callback that will be called when the shader is compiled.
  28969. */
  28970. onCompiled: Nullable<(effect: Effect) => void>;
  28971. /**
  28972. * Callback that will be called if an error occurs during shader compilation.
  28973. */
  28974. onError: Nullable<(effect: Effect, errors: string) => void>;
  28975. /**
  28976. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28977. */
  28978. indexParameters: any;
  28979. /**
  28980. * Max number of lights that can be used in the shader.
  28981. */
  28982. maxSimultaneousLights: number;
  28983. /**
  28984. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28985. */
  28986. transformFeedbackVaryings: Nullable<string[]>;
  28987. }
  28988. /**
  28989. * Effect containing vertex and fragment shader that can be executed on an object.
  28990. */
  28991. export class Effect implements IDisposable {
  28992. /**
  28993. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28994. */
  28995. static ShadersRepository: string;
  28996. /**
  28997. * Name of the effect.
  28998. */
  28999. name: any;
  29000. /**
  29001. * String container all the define statements that should be set on the shader.
  29002. */
  29003. defines: string;
  29004. /**
  29005. * Callback that will be called when the shader is compiled.
  29006. */
  29007. onCompiled: Nullable<(effect: Effect) => void>;
  29008. /**
  29009. * Callback that will be called if an error occurs during shader compilation.
  29010. */
  29011. onError: Nullable<(effect: Effect, errors: string) => void>;
  29012. /**
  29013. * Callback that will be called when effect is bound.
  29014. */
  29015. onBind: Nullable<(effect: Effect) => void>;
  29016. /**
  29017. * Unique ID of the effect.
  29018. */
  29019. uniqueId: number;
  29020. /**
  29021. * Observable that will be called when the shader is compiled.
  29022. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29023. */
  29024. onCompileObservable: Observable<Effect>;
  29025. /**
  29026. * Observable that will be called if an error occurs during shader compilation.
  29027. */
  29028. onErrorObservable: Observable<Effect>;
  29029. /** @hidden */
  29030. _onBindObservable: Nullable<Observable<Effect>>;
  29031. /**
  29032. * Observable that will be called when effect is bound.
  29033. */
  29034. readonly onBindObservable: Observable<Effect>;
  29035. /** @hidden */
  29036. _bonesComputationForcedToCPU: boolean;
  29037. private static _uniqueIdSeed;
  29038. private _engine;
  29039. private _uniformBuffersNames;
  29040. private _uniformsNames;
  29041. private _samplerList;
  29042. private _samplers;
  29043. private _isReady;
  29044. private _compilationError;
  29045. private _attributesNames;
  29046. private _attributes;
  29047. private _uniforms;
  29048. /**
  29049. * Key for the effect.
  29050. * @hidden
  29051. */
  29052. _key: string;
  29053. private _indexParameters;
  29054. private _fallbacks;
  29055. private _vertexSourceCode;
  29056. private _fragmentSourceCode;
  29057. private _vertexSourceCodeOverride;
  29058. private _fragmentSourceCodeOverride;
  29059. private _transformFeedbackVaryings;
  29060. /**
  29061. * Compiled shader to webGL program.
  29062. * @hidden
  29063. */
  29064. _pipelineContext: Nullable<IPipelineContext>;
  29065. private _valueCache;
  29066. private static _baseCache;
  29067. /**
  29068. * Instantiates an effect.
  29069. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29070. * @param baseName Name of the effect.
  29071. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29072. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29073. * @param samplers List of sampler variables that will be passed to the shader.
  29074. * @param engine Engine to be used to render the effect
  29075. * @param defines Define statements to be added to the shader.
  29076. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29077. * @param onCompiled Callback that will be called when the shader is compiled.
  29078. * @param onError Callback that will be called if an error occurs during shader compilation.
  29079. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29080. */
  29081. 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);
  29082. private _useFinalCode;
  29083. /**
  29084. * Unique key for this effect
  29085. */
  29086. readonly key: string;
  29087. /**
  29088. * If the effect has been compiled and prepared.
  29089. * @returns if the effect is compiled and prepared.
  29090. */
  29091. isReady(): boolean;
  29092. /**
  29093. * The engine the effect was initialized with.
  29094. * @returns the engine.
  29095. */
  29096. getEngine(): Engine;
  29097. /**
  29098. * The pipeline context for this effect
  29099. * @returns the associated pipeline context
  29100. */
  29101. getPipelineContext(): Nullable<IPipelineContext>;
  29102. /**
  29103. * The set of names of attribute variables for the shader.
  29104. * @returns An array of attribute names.
  29105. */
  29106. getAttributesNames(): string[];
  29107. /**
  29108. * Returns the attribute at the given index.
  29109. * @param index The index of the attribute.
  29110. * @returns The location of the attribute.
  29111. */
  29112. getAttributeLocation(index: number): number;
  29113. /**
  29114. * Returns the attribute based on the name of the variable.
  29115. * @param name of the attribute to look up.
  29116. * @returns the attribute location.
  29117. */
  29118. getAttributeLocationByName(name: string): number;
  29119. /**
  29120. * The number of attributes.
  29121. * @returns the numnber of attributes.
  29122. */
  29123. getAttributesCount(): number;
  29124. /**
  29125. * Gets the index of a uniform variable.
  29126. * @param uniformName of the uniform to look up.
  29127. * @returns the index.
  29128. */
  29129. getUniformIndex(uniformName: string): number;
  29130. /**
  29131. * Returns the attribute based on the name of the variable.
  29132. * @param uniformName of the uniform to look up.
  29133. * @returns the location of the uniform.
  29134. */
  29135. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29136. /**
  29137. * Returns an array of sampler variable names
  29138. * @returns The array of sampler variable neames.
  29139. */
  29140. getSamplers(): string[];
  29141. /**
  29142. * The error from the last compilation.
  29143. * @returns the error string.
  29144. */
  29145. getCompilationError(): string;
  29146. /**
  29147. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29148. * @param func The callback to be used.
  29149. */
  29150. executeWhenCompiled(func: (effect: Effect) => void): void;
  29151. private _checkIsReady;
  29152. /** @hidden */
  29153. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29154. /** @hidden */
  29155. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29156. /** @hidden */
  29157. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29158. /**
  29159. * Recompiles the webGL program
  29160. * @param vertexSourceCode The source code for the vertex shader.
  29161. * @param fragmentSourceCode The source code for the fragment shader.
  29162. * @param onCompiled Callback called when completed.
  29163. * @param onError Callback called on error.
  29164. * @hidden
  29165. */
  29166. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29167. /**
  29168. * Prepares the effect
  29169. * @hidden
  29170. */
  29171. _prepareEffect(): void;
  29172. /**
  29173. * Checks if the effect is supported. (Must be called after compilation)
  29174. */
  29175. readonly isSupported: boolean;
  29176. /**
  29177. * Binds a texture to the engine to be used as output of the shader.
  29178. * @param channel Name of the output variable.
  29179. * @param texture Texture to bind.
  29180. * @hidden
  29181. */
  29182. _bindTexture(channel: string, texture: InternalTexture): void;
  29183. /**
  29184. * Sets a texture on the engine to be used in the shader.
  29185. * @param channel Name of the sampler variable.
  29186. * @param texture Texture to set.
  29187. */
  29188. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29189. /**
  29190. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29191. * @param channel Name of the sampler variable.
  29192. * @param texture Texture to set.
  29193. */
  29194. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29195. /**
  29196. * Sets an array of textures on the engine to be used in the shader.
  29197. * @param channel Name of the variable.
  29198. * @param textures Textures to set.
  29199. */
  29200. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29201. /**
  29202. * 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)
  29203. * @param channel Name of the sampler variable.
  29204. * @param postProcess Post process to get the input texture from.
  29205. */
  29206. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29207. /**
  29208. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29209. * 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)
  29210. * @param channel Name of the sampler variable.
  29211. * @param postProcess Post process to get the output texture from.
  29212. */
  29213. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29214. /** @hidden */
  29215. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29216. /** @hidden */
  29217. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29218. /** @hidden */
  29219. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29220. /** @hidden */
  29221. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29222. /**
  29223. * Binds a buffer to a uniform.
  29224. * @param buffer Buffer to bind.
  29225. * @param name Name of the uniform variable to bind to.
  29226. */
  29227. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29228. /**
  29229. * Binds block to a uniform.
  29230. * @param blockName Name of the block to bind.
  29231. * @param index Index to bind.
  29232. */
  29233. bindUniformBlock(blockName: string, index: number): void;
  29234. /**
  29235. * Sets an interger value on a uniform variable.
  29236. * @param uniformName Name of the variable.
  29237. * @param value Value to be set.
  29238. * @returns this effect.
  29239. */
  29240. setInt(uniformName: string, value: number): Effect;
  29241. /**
  29242. * Sets an int array on a uniform variable.
  29243. * @param uniformName Name of the variable.
  29244. * @param array array to be set.
  29245. * @returns this effect.
  29246. */
  29247. setIntArray(uniformName: string, array: Int32Array): Effect;
  29248. /**
  29249. * 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)
  29250. * @param uniformName Name of the variable.
  29251. * @param array array to be set.
  29252. * @returns this effect.
  29253. */
  29254. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29255. /**
  29256. * 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)
  29257. * @param uniformName Name of the variable.
  29258. * @param array array to be set.
  29259. * @returns this effect.
  29260. */
  29261. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29262. /**
  29263. * 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)
  29264. * @param uniformName Name of the variable.
  29265. * @param array array to be set.
  29266. * @returns this effect.
  29267. */
  29268. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29269. /**
  29270. * Sets an float array on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param array array to be set.
  29273. * @returns this effect.
  29274. */
  29275. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29276. /**
  29277. * 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)
  29278. * @param uniformName Name of the variable.
  29279. * @param array array to be set.
  29280. * @returns this effect.
  29281. */
  29282. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29283. /**
  29284. * 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)
  29285. * @param uniformName Name of the variable.
  29286. * @param array array to be set.
  29287. * @returns this effect.
  29288. */
  29289. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29290. /**
  29291. * 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)
  29292. * @param uniformName Name of the variable.
  29293. * @param array array to be set.
  29294. * @returns this effect.
  29295. */
  29296. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29297. /**
  29298. * Sets an array on a uniform variable.
  29299. * @param uniformName Name of the variable.
  29300. * @param array array to be set.
  29301. * @returns this effect.
  29302. */
  29303. setArray(uniformName: string, array: number[]): Effect;
  29304. /**
  29305. * 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)
  29306. * @param uniformName Name of the variable.
  29307. * @param array array to be set.
  29308. * @returns this effect.
  29309. */
  29310. setArray2(uniformName: string, array: number[]): Effect;
  29311. /**
  29312. * 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)
  29313. * @param uniformName Name of the variable.
  29314. * @param array array to be set.
  29315. * @returns this effect.
  29316. */
  29317. setArray3(uniformName: string, array: number[]): Effect;
  29318. /**
  29319. * 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)
  29320. * @param uniformName Name of the variable.
  29321. * @param array array to be set.
  29322. * @returns this effect.
  29323. */
  29324. setArray4(uniformName: string, array: number[]): Effect;
  29325. /**
  29326. * Sets matrices on a uniform variable.
  29327. * @param uniformName Name of the variable.
  29328. * @param matrices matrices to be set.
  29329. * @returns this effect.
  29330. */
  29331. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29332. /**
  29333. * Sets matrix on a uniform variable.
  29334. * @param uniformName Name of the variable.
  29335. * @param matrix matrix to be set.
  29336. * @returns this effect.
  29337. */
  29338. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29339. /**
  29340. * 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)
  29341. * @param uniformName Name of the variable.
  29342. * @param matrix matrix to be set.
  29343. * @returns this effect.
  29344. */
  29345. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29346. /**
  29347. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29348. * @param uniformName Name of the variable.
  29349. * @param matrix matrix to be set.
  29350. * @returns this effect.
  29351. */
  29352. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29353. /**
  29354. * Sets a float on a uniform variable.
  29355. * @param uniformName Name of the variable.
  29356. * @param value value to be set.
  29357. * @returns this effect.
  29358. */
  29359. setFloat(uniformName: string, value: number): Effect;
  29360. /**
  29361. * Sets a boolean on a uniform variable.
  29362. * @param uniformName Name of the variable.
  29363. * @param bool value to be set.
  29364. * @returns this effect.
  29365. */
  29366. setBool(uniformName: string, bool: boolean): Effect;
  29367. /**
  29368. * Sets a Vector2 on a uniform variable.
  29369. * @param uniformName Name of the variable.
  29370. * @param vector2 vector2 to be set.
  29371. * @returns this effect.
  29372. */
  29373. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29374. /**
  29375. * Sets a float2 on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param x First float in float2.
  29378. * @param y Second float in float2.
  29379. * @returns this effect.
  29380. */
  29381. setFloat2(uniformName: string, x: number, y: number): Effect;
  29382. /**
  29383. * Sets a Vector3 on a uniform variable.
  29384. * @param uniformName Name of the variable.
  29385. * @param vector3 Value to be set.
  29386. * @returns this effect.
  29387. */
  29388. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29389. /**
  29390. * Sets a float3 on a uniform variable.
  29391. * @param uniformName Name of the variable.
  29392. * @param x First float in float3.
  29393. * @param y Second float in float3.
  29394. * @param z Third float in float3.
  29395. * @returns this effect.
  29396. */
  29397. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29398. /**
  29399. * Sets a Vector4 on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param vector4 Value to be set.
  29402. * @returns this effect.
  29403. */
  29404. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29405. /**
  29406. * Sets a float4 on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param x First float in float4.
  29409. * @param y Second float in float4.
  29410. * @param z Third float in float4.
  29411. * @param w Fourth float in float4.
  29412. * @returns this effect.
  29413. */
  29414. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29415. /**
  29416. * Sets a Color3 on a uniform variable.
  29417. * @param uniformName Name of the variable.
  29418. * @param color3 Value to be set.
  29419. * @returns this effect.
  29420. */
  29421. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29422. /**
  29423. * Sets a Color4 on a uniform variable.
  29424. * @param uniformName Name of the variable.
  29425. * @param color3 Value to be set.
  29426. * @param alpha Alpha value to be set.
  29427. * @returns this effect.
  29428. */
  29429. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29430. /**
  29431. * Sets a Color4 on a uniform variable
  29432. * @param uniformName defines the name of the variable
  29433. * @param color4 defines the value to be set
  29434. * @returns this effect.
  29435. */
  29436. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29437. /** Release all associated resources */
  29438. dispose(): void;
  29439. /**
  29440. * This function will add a new shader to the shader store
  29441. * @param name the name of the shader
  29442. * @param pixelShader optional pixel shader content
  29443. * @param vertexShader optional vertex shader content
  29444. */
  29445. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29446. /**
  29447. * Store of each shader (The can be looked up using effect.key)
  29448. */
  29449. static ShadersStore: {
  29450. [key: string]: string;
  29451. };
  29452. /**
  29453. * Store of each included file for a shader (The can be looked up using effect.key)
  29454. */
  29455. static IncludesShadersStore: {
  29456. [key: string]: string;
  29457. };
  29458. /**
  29459. * Resets the cache of effects.
  29460. */
  29461. static ResetCache(): void;
  29462. }
  29463. }
  29464. declare module "babylonjs/Materials/uniformBuffer" {
  29465. import { Nullable, FloatArray } from "babylonjs/types";
  29466. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29467. import { Engine } from "babylonjs/Engines/engine";
  29468. import { Effect } from "babylonjs/Materials/effect";
  29469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29470. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29471. import { Color3 } from "babylonjs/Maths/math.color";
  29472. /**
  29473. * Uniform buffer objects.
  29474. *
  29475. * Handles blocks of uniform on the GPU.
  29476. *
  29477. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29478. *
  29479. * For more information, please refer to :
  29480. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29481. */
  29482. export class UniformBuffer {
  29483. private _engine;
  29484. private _buffer;
  29485. private _data;
  29486. private _bufferData;
  29487. private _dynamic?;
  29488. private _uniformLocations;
  29489. private _uniformSizes;
  29490. private _uniformLocationPointer;
  29491. private _needSync;
  29492. private _noUBO;
  29493. private _currentEffect;
  29494. private static _MAX_UNIFORM_SIZE;
  29495. private static _tempBuffer;
  29496. /**
  29497. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29498. * This is dynamic to allow compat with webgl 1 and 2.
  29499. * You will need to pass the name of the uniform as well as the value.
  29500. */
  29501. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29502. /**
  29503. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29504. * This is dynamic to allow compat with webgl 1 and 2.
  29505. * You will need to pass the name of the uniform as well as the value.
  29506. */
  29507. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29508. /**
  29509. * Lambda to Update a single float in a uniform buffer.
  29510. * This is dynamic to allow compat with webgl 1 and 2.
  29511. * You will need to pass the name of the uniform as well as the value.
  29512. */
  29513. updateFloat: (name: string, x: number) => void;
  29514. /**
  29515. * Lambda to Update a vec2 of float in a uniform buffer.
  29516. * This is dynamic to allow compat with webgl 1 and 2.
  29517. * You will need to pass the name of the uniform as well as the value.
  29518. */
  29519. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29520. /**
  29521. * Lambda to Update a vec3 of float in a uniform buffer.
  29522. * This is dynamic to allow compat with webgl 1 and 2.
  29523. * You will need to pass the name of the uniform as well as the value.
  29524. */
  29525. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29526. /**
  29527. * Lambda to Update a vec4 of float in a uniform buffer.
  29528. * This is dynamic to allow compat with webgl 1 and 2.
  29529. * You will need to pass the name of the uniform as well as the value.
  29530. */
  29531. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29532. /**
  29533. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29534. * This is dynamic to allow compat with webgl 1 and 2.
  29535. * You will need to pass the name of the uniform as well as the value.
  29536. */
  29537. updateMatrix: (name: string, mat: Matrix) => void;
  29538. /**
  29539. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29540. * This is dynamic to allow compat with webgl 1 and 2.
  29541. * You will need to pass the name of the uniform as well as the value.
  29542. */
  29543. updateVector3: (name: string, vector: Vector3) => void;
  29544. /**
  29545. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29546. * This is dynamic to allow compat with webgl 1 and 2.
  29547. * You will need to pass the name of the uniform as well as the value.
  29548. */
  29549. updateVector4: (name: string, vector: Vector4) => void;
  29550. /**
  29551. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29552. * This is dynamic to allow compat with webgl 1 and 2.
  29553. * You will need to pass the name of the uniform as well as the value.
  29554. */
  29555. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29556. /**
  29557. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29558. * This is dynamic to allow compat with webgl 1 and 2.
  29559. * You will need to pass the name of the uniform as well as the value.
  29560. */
  29561. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29562. /**
  29563. * Instantiates a new Uniform buffer objects.
  29564. *
  29565. * Handles blocks of uniform on the GPU.
  29566. *
  29567. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29568. *
  29569. * For more information, please refer to :
  29570. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29571. * @param engine Define the engine the buffer is associated with
  29572. * @param data Define the data contained in the buffer
  29573. * @param dynamic Define if the buffer is updatable
  29574. */
  29575. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29576. /**
  29577. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29578. * or just falling back on setUniformXXX calls.
  29579. */
  29580. readonly useUbo: boolean;
  29581. /**
  29582. * Indicates if the WebGL underlying uniform buffer is in sync
  29583. * with the javascript cache data.
  29584. */
  29585. readonly isSync: boolean;
  29586. /**
  29587. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29588. * Also, a dynamic UniformBuffer will disable cache verification and always
  29589. * update the underlying WebGL uniform buffer to the GPU.
  29590. * @returns if Dynamic, otherwise false
  29591. */
  29592. isDynamic(): boolean;
  29593. /**
  29594. * The data cache on JS side.
  29595. * @returns the underlying data as a float array
  29596. */
  29597. getData(): Float32Array;
  29598. /**
  29599. * The underlying WebGL Uniform buffer.
  29600. * @returns the webgl buffer
  29601. */
  29602. getBuffer(): Nullable<DataBuffer>;
  29603. /**
  29604. * std140 layout specifies how to align data within an UBO structure.
  29605. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29606. * for specs.
  29607. */
  29608. private _fillAlignment;
  29609. /**
  29610. * Adds an uniform in the buffer.
  29611. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29612. * for the layout to be correct !
  29613. * @param name Name of the uniform, as used in the uniform block in the shader.
  29614. * @param size Data size, or data directly.
  29615. */
  29616. addUniform(name: string, size: number | number[]): void;
  29617. /**
  29618. * Adds a Matrix 4x4 to the uniform buffer.
  29619. * @param name Name of the uniform, as used in the uniform block in the shader.
  29620. * @param mat A 4x4 matrix.
  29621. */
  29622. addMatrix(name: string, mat: Matrix): void;
  29623. /**
  29624. * Adds a vec2 to the uniform buffer.
  29625. * @param name Name of the uniform, as used in the uniform block in the shader.
  29626. * @param x Define the x component value of the vec2
  29627. * @param y Define the y component value of the vec2
  29628. */
  29629. addFloat2(name: string, x: number, y: number): void;
  29630. /**
  29631. * Adds a vec3 to the uniform buffer.
  29632. * @param name Name of the uniform, as used in the uniform block in the shader.
  29633. * @param x Define the x component value of the vec3
  29634. * @param y Define the y component value of the vec3
  29635. * @param z Define the z component value of the vec3
  29636. */
  29637. addFloat3(name: string, x: number, y: number, z: number): void;
  29638. /**
  29639. * Adds a vec3 to the uniform buffer.
  29640. * @param name Name of the uniform, as used in the uniform block in the shader.
  29641. * @param color Define the vec3 from a Color
  29642. */
  29643. addColor3(name: string, color: Color3): void;
  29644. /**
  29645. * Adds a vec4 to the uniform buffer.
  29646. * @param name Name of the uniform, as used in the uniform block in the shader.
  29647. * @param color Define the rgb components from a Color
  29648. * @param alpha Define the a component of the vec4
  29649. */
  29650. addColor4(name: string, color: Color3, alpha: 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 vector Define the vec3 components from a Vector
  29655. */
  29656. addVector3(name: string, vector: Vector3): void;
  29657. /**
  29658. * Adds a Matrix 3x3 to the uniform buffer.
  29659. * @param name Name of the uniform, as used in the uniform block in the shader.
  29660. */
  29661. addMatrix3x3(name: string): void;
  29662. /**
  29663. * Adds a Matrix 2x2 to the uniform buffer.
  29664. * @param name Name of the uniform, as used in the uniform block in the shader.
  29665. */
  29666. addMatrix2x2(name: string): void;
  29667. /**
  29668. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29669. */
  29670. create(): void;
  29671. /** @hidden */
  29672. _rebuild(): void;
  29673. /**
  29674. * Updates the WebGL Uniform Buffer on the GPU.
  29675. * If the `dynamic` flag is set to true, no cache comparison is done.
  29676. * Otherwise, the buffer will be updated only if the cache differs.
  29677. */
  29678. update(): void;
  29679. /**
  29680. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29681. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29682. * @param data Define the flattened data
  29683. * @param size Define the size of the data.
  29684. */
  29685. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29686. private _updateMatrix3x3ForUniform;
  29687. private _updateMatrix3x3ForEffect;
  29688. private _updateMatrix2x2ForEffect;
  29689. private _updateMatrix2x2ForUniform;
  29690. private _updateFloatForEffect;
  29691. private _updateFloatForUniform;
  29692. private _updateFloat2ForEffect;
  29693. private _updateFloat2ForUniform;
  29694. private _updateFloat3ForEffect;
  29695. private _updateFloat3ForUniform;
  29696. private _updateFloat4ForEffect;
  29697. private _updateFloat4ForUniform;
  29698. private _updateMatrixForEffect;
  29699. private _updateMatrixForUniform;
  29700. private _updateVector3ForEffect;
  29701. private _updateVector3ForUniform;
  29702. private _updateVector4ForEffect;
  29703. private _updateVector4ForUniform;
  29704. private _updateColor3ForEffect;
  29705. private _updateColor3ForUniform;
  29706. private _updateColor4ForEffect;
  29707. private _updateColor4ForUniform;
  29708. /**
  29709. * Sets a sampler uniform on the effect.
  29710. * @param name Define the name of the sampler.
  29711. * @param texture Define the texture to set in the sampler
  29712. */
  29713. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29714. /**
  29715. * Directly updates the value of the uniform in the cache AND on the GPU.
  29716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29717. * @param data Define the flattened data
  29718. */
  29719. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29720. /**
  29721. * Binds this uniform buffer to an effect.
  29722. * @param effect Define the effect to bind the buffer to
  29723. * @param name Name of the uniform block in the shader.
  29724. */
  29725. bindToEffect(effect: Effect, name: string): void;
  29726. /**
  29727. * Disposes the uniform buffer.
  29728. */
  29729. dispose(): void;
  29730. }
  29731. }
  29732. declare module "babylonjs/Audio/analyser" {
  29733. import { Scene } from "babylonjs/scene";
  29734. /**
  29735. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29737. */
  29738. export class Analyser {
  29739. /**
  29740. * Gets or sets the smoothing
  29741. * @ignorenaming
  29742. */
  29743. SMOOTHING: number;
  29744. /**
  29745. * Gets or sets the FFT table size
  29746. * @ignorenaming
  29747. */
  29748. FFT_SIZE: number;
  29749. /**
  29750. * Gets or sets the bar graph amplitude
  29751. * @ignorenaming
  29752. */
  29753. BARGRAPHAMPLITUDE: number;
  29754. /**
  29755. * Gets or sets the position of the debug canvas
  29756. * @ignorenaming
  29757. */
  29758. DEBUGCANVASPOS: {
  29759. x: number;
  29760. y: number;
  29761. };
  29762. /**
  29763. * Gets or sets the debug canvas size
  29764. * @ignorenaming
  29765. */
  29766. DEBUGCANVASSIZE: {
  29767. width: number;
  29768. height: number;
  29769. };
  29770. private _byteFreqs;
  29771. private _byteTime;
  29772. private _floatFreqs;
  29773. private _webAudioAnalyser;
  29774. private _debugCanvas;
  29775. private _debugCanvasContext;
  29776. private _scene;
  29777. private _registerFunc;
  29778. private _audioEngine;
  29779. /**
  29780. * Creates a new analyser
  29781. * @param scene defines hosting scene
  29782. */
  29783. constructor(scene: Scene);
  29784. /**
  29785. * Get the number of data values you will have to play with for the visualization
  29786. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29787. * @returns a number
  29788. */
  29789. getFrequencyBinCount(): number;
  29790. /**
  29791. * Gets the current frequency data as a byte array
  29792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29793. * @returns a Uint8Array
  29794. */
  29795. getByteFrequencyData(): Uint8Array;
  29796. /**
  29797. * Gets the current waveform as a byte array
  29798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29799. * @returns a Uint8Array
  29800. */
  29801. getByteTimeDomainData(): Uint8Array;
  29802. /**
  29803. * Gets the current frequency data as a float array
  29804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29805. * @returns a Float32Array
  29806. */
  29807. getFloatFrequencyData(): Float32Array;
  29808. /**
  29809. * Renders the debug canvas
  29810. */
  29811. drawDebugCanvas(): void;
  29812. /**
  29813. * Stops rendering the debug canvas and removes it
  29814. */
  29815. stopDebugCanvas(): void;
  29816. /**
  29817. * Connects two audio nodes
  29818. * @param inputAudioNode defines first node to connect
  29819. * @param outputAudioNode defines second node to connect
  29820. */
  29821. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29822. /**
  29823. * Releases all associated resources
  29824. */
  29825. dispose(): void;
  29826. }
  29827. }
  29828. declare module "babylonjs/Audio/audioEngine" {
  29829. import { IDisposable } from "babylonjs/scene";
  29830. import { Analyser } from "babylonjs/Audio/analyser";
  29831. import { Nullable } from "babylonjs/types";
  29832. import { Observable } from "babylonjs/Misc/observable";
  29833. /**
  29834. * This represents an audio engine and it is responsible
  29835. * to play, synchronize and analyse sounds throughout the application.
  29836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29837. */
  29838. export interface IAudioEngine extends IDisposable {
  29839. /**
  29840. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29841. */
  29842. readonly canUseWebAudio: boolean;
  29843. /**
  29844. * Gets the current AudioContext if available.
  29845. */
  29846. readonly audioContext: Nullable<AudioContext>;
  29847. /**
  29848. * The master gain node defines the global audio volume of your audio engine.
  29849. */
  29850. readonly masterGain: GainNode;
  29851. /**
  29852. * Gets whether or not mp3 are supported by your browser.
  29853. */
  29854. readonly isMP3supported: boolean;
  29855. /**
  29856. * Gets whether or not ogg are supported by your browser.
  29857. */
  29858. readonly isOGGsupported: boolean;
  29859. /**
  29860. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29861. * @ignoreNaming
  29862. */
  29863. WarnedWebAudioUnsupported: boolean;
  29864. /**
  29865. * Defines if the audio engine relies on a custom unlocked button.
  29866. * In this case, the embedded button will not be displayed.
  29867. */
  29868. useCustomUnlockedButton: boolean;
  29869. /**
  29870. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29871. */
  29872. readonly unlocked: boolean;
  29873. /**
  29874. * Event raised when audio has been unlocked on the browser.
  29875. */
  29876. onAudioUnlockedObservable: Observable<AudioEngine>;
  29877. /**
  29878. * Event raised when audio has been locked on the browser.
  29879. */
  29880. onAudioLockedObservable: Observable<AudioEngine>;
  29881. /**
  29882. * Flags the audio engine in Locked state.
  29883. * This happens due to new browser policies preventing audio to autoplay.
  29884. */
  29885. lock(): void;
  29886. /**
  29887. * Unlocks the audio engine once a user action has been done on the dom.
  29888. * This is helpful to resume play once browser policies have been satisfied.
  29889. */
  29890. unlock(): void;
  29891. }
  29892. /**
  29893. * This represents the default audio engine used in babylon.
  29894. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29896. */
  29897. export class AudioEngine implements IAudioEngine {
  29898. private _audioContext;
  29899. private _audioContextInitialized;
  29900. private _muteButton;
  29901. private _hostElement;
  29902. /**
  29903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29904. */
  29905. canUseWebAudio: boolean;
  29906. /**
  29907. * The master gain node defines the global audio volume of your audio engine.
  29908. */
  29909. masterGain: GainNode;
  29910. /**
  29911. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29912. * @ignoreNaming
  29913. */
  29914. WarnedWebAudioUnsupported: boolean;
  29915. /**
  29916. * Gets whether or not mp3 are supported by your browser.
  29917. */
  29918. isMP3supported: boolean;
  29919. /**
  29920. * Gets whether or not ogg are supported by your browser.
  29921. */
  29922. isOGGsupported: boolean;
  29923. /**
  29924. * Gets whether audio has been unlocked on the device.
  29925. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29926. * a user interaction has happened.
  29927. */
  29928. unlocked: boolean;
  29929. /**
  29930. * Defines if the audio engine relies on a custom unlocked button.
  29931. * In this case, the embedded button will not be displayed.
  29932. */
  29933. useCustomUnlockedButton: boolean;
  29934. /**
  29935. * Event raised when audio has been unlocked on the browser.
  29936. */
  29937. onAudioUnlockedObservable: Observable<AudioEngine>;
  29938. /**
  29939. * Event raised when audio has been locked on the browser.
  29940. */
  29941. onAudioLockedObservable: Observable<AudioEngine>;
  29942. /**
  29943. * Gets the current AudioContext if available.
  29944. */
  29945. readonly audioContext: Nullable<AudioContext>;
  29946. private _connectedAnalyser;
  29947. /**
  29948. * Instantiates a new audio engine.
  29949. *
  29950. * There should be only one per page as some browsers restrict the number
  29951. * of audio contexts you can create.
  29952. * @param hostElement defines the host element where to display the mute icon if necessary
  29953. */
  29954. constructor(hostElement?: Nullable<HTMLElement>);
  29955. /**
  29956. * Flags the audio engine in Locked state.
  29957. * This happens due to new browser policies preventing audio to autoplay.
  29958. */
  29959. lock(): void;
  29960. /**
  29961. * Unlocks the audio engine once a user action has been done on the dom.
  29962. * This is helpful to resume play once browser policies have been satisfied.
  29963. */
  29964. unlock(): void;
  29965. private _resumeAudioContext;
  29966. private _initializeAudioContext;
  29967. private _tryToRun;
  29968. private _triggerRunningState;
  29969. private _triggerSuspendedState;
  29970. private _displayMuteButton;
  29971. private _moveButtonToTopLeft;
  29972. private _onResize;
  29973. private _hideMuteButton;
  29974. /**
  29975. * Destroy and release the resources associated with the audio ccontext.
  29976. */
  29977. dispose(): void;
  29978. /**
  29979. * Gets the global volume sets on the master gain.
  29980. * @returns the global volume if set or -1 otherwise
  29981. */
  29982. getGlobalVolume(): number;
  29983. /**
  29984. * Sets the global volume of your experience (sets on the master gain).
  29985. * @param newVolume Defines the new global volume of the application
  29986. */
  29987. setGlobalVolume(newVolume: number): void;
  29988. /**
  29989. * Connect the audio engine to an audio analyser allowing some amazing
  29990. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29992. * @param analyser The analyser to connect to the engine
  29993. */
  29994. connectToAnalyser(analyser: Analyser): void;
  29995. }
  29996. }
  29997. declare module "babylonjs/Loading/loadingScreen" {
  29998. /**
  29999. * Interface used to present a loading screen while loading a scene
  30000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30001. */
  30002. export interface ILoadingScreen {
  30003. /**
  30004. * Function called to display the loading screen
  30005. */
  30006. displayLoadingUI: () => void;
  30007. /**
  30008. * Function called to hide the loading screen
  30009. */
  30010. hideLoadingUI: () => void;
  30011. /**
  30012. * Gets or sets the color to use for the background
  30013. */
  30014. loadingUIBackgroundColor: string;
  30015. /**
  30016. * Gets or sets the text to display while loading
  30017. */
  30018. loadingUIText: string;
  30019. }
  30020. /**
  30021. * Class used for the default loading screen
  30022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30023. */
  30024. export class DefaultLoadingScreen implements ILoadingScreen {
  30025. private _renderingCanvas;
  30026. private _loadingText;
  30027. private _loadingDivBackgroundColor;
  30028. private _loadingDiv;
  30029. private _loadingTextDiv;
  30030. /** Gets or sets the logo url to use for the default loading screen */
  30031. static DefaultLogoUrl: string;
  30032. /** Gets or sets the spinner url to use for the default loading screen */
  30033. static DefaultSpinnerUrl: string;
  30034. /**
  30035. * Creates a new default loading screen
  30036. * @param _renderingCanvas defines the canvas used to render the scene
  30037. * @param _loadingText defines the default text to display
  30038. * @param _loadingDivBackgroundColor defines the default background color
  30039. */
  30040. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30041. /**
  30042. * Function called to display the loading screen
  30043. */
  30044. displayLoadingUI(): void;
  30045. /**
  30046. * Function called to hide the loading screen
  30047. */
  30048. hideLoadingUI(): void;
  30049. /**
  30050. * Gets or sets the text to display while loading
  30051. */
  30052. loadingUIText: string;
  30053. /**
  30054. * Gets or sets the color to use for the background
  30055. */
  30056. loadingUIBackgroundColor: string;
  30057. private _resizeLoadingUI;
  30058. }
  30059. }
  30060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30062. import { Engine } from "babylonjs/Engines/engine";
  30063. import { Nullable } from "babylonjs/types";
  30064. /** @hidden */
  30065. export class WebGLPipelineContext implements IPipelineContext {
  30066. engine: Engine;
  30067. program: Nullable<WebGLProgram>;
  30068. context?: WebGLRenderingContext;
  30069. vertexShader?: WebGLShader;
  30070. fragmentShader?: WebGLShader;
  30071. isParallelCompiled: boolean;
  30072. onCompiled?: () => void;
  30073. transformFeedback?: WebGLTransformFeedback | null;
  30074. readonly isAsync: boolean;
  30075. readonly isReady: boolean;
  30076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30077. }
  30078. }
  30079. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30080. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30081. /** @hidden */
  30082. export class WebGLDataBuffer extends DataBuffer {
  30083. private _buffer;
  30084. constructor(resource: WebGLBuffer);
  30085. readonly underlyingResource: any;
  30086. }
  30087. }
  30088. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30089. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30090. /** @hidden */
  30091. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30092. attributeProcessor(attribute: string): string;
  30093. varyingProcessor(varying: string, isFragment: boolean): string;
  30094. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30095. }
  30096. }
  30097. declare module "babylonjs/Misc/perfCounter" {
  30098. /**
  30099. * This class is used to track a performance counter which is number based.
  30100. * The user has access to many properties which give statistics of different nature.
  30101. *
  30102. * The implementer can track two kinds of Performance Counter: time and count.
  30103. * 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.
  30104. * 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.
  30105. */
  30106. export class PerfCounter {
  30107. /**
  30108. * Gets or sets a global boolean to turn on and off all the counters
  30109. */
  30110. static Enabled: boolean;
  30111. /**
  30112. * Returns the smallest value ever
  30113. */
  30114. readonly min: number;
  30115. /**
  30116. * Returns the biggest value ever
  30117. */
  30118. readonly max: number;
  30119. /**
  30120. * Returns the average value since the performance counter is running
  30121. */
  30122. readonly average: number;
  30123. /**
  30124. * Returns the average value of the last second the counter was monitored
  30125. */
  30126. readonly lastSecAverage: number;
  30127. /**
  30128. * Returns the current value
  30129. */
  30130. readonly current: number;
  30131. /**
  30132. * Gets the accumulated total
  30133. */
  30134. readonly total: number;
  30135. /**
  30136. * Gets the total value count
  30137. */
  30138. readonly count: number;
  30139. /**
  30140. * Creates a new counter
  30141. */
  30142. constructor();
  30143. /**
  30144. * Call this method to start monitoring a new frame.
  30145. * 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.
  30146. */
  30147. fetchNewFrame(): void;
  30148. /**
  30149. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30150. * @param newCount the count value to add to the monitored count
  30151. * @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.
  30152. */
  30153. addCount(newCount: number, fetchResult: boolean): void;
  30154. /**
  30155. * Start monitoring this performance counter
  30156. */
  30157. beginMonitoring(): void;
  30158. /**
  30159. * Compute the time lapsed since the previous beginMonitoring() call.
  30160. * @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
  30161. */
  30162. endMonitoring(newFrame?: boolean): void;
  30163. private _fetchResult;
  30164. private _startMonitoringTime;
  30165. private _min;
  30166. private _max;
  30167. private _average;
  30168. private _current;
  30169. private _totalValueCount;
  30170. private _totalAccumulated;
  30171. private _lastSecAverage;
  30172. private _lastSecAccumulated;
  30173. private _lastSecTime;
  30174. private _lastSecValueCount;
  30175. }
  30176. }
  30177. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30178. /**
  30179. * Interface for any object that can request an animation frame
  30180. */
  30181. export interface ICustomAnimationFrameRequester {
  30182. /**
  30183. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30184. */
  30185. renderFunction?: Function;
  30186. /**
  30187. * Called to request the next frame to render to
  30188. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30189. */
  30190. requestAnimationFrame: Function;
  30191. /**
  30192. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30193. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30194. */
  30195. requestID?: number;
  30196. }
  30197. }
  30198. declare module "babylonjs/Materials/Textures/videoTexture" {
  30199. import { Observable } from "babylonjs/Misc/observable";
  30200. import { Nullable } from "babylonjs/types";
  30201. import { Scene } from "babylonjs/scene";
  30202. import { Texture } from "babylonjs/Materials/Textures/texture";
  30203. /**
  30204. * Settings for finer control over video usage
  30205. */
  30206. export interface VideoTextureSettings {
  30207. /**
  30208. * Applies `autoplay` to video, if specified
  30209. */
  30210. autoPlay?: boolean;
  30211. /**
  30212. * Applies `loop` to video, if specified
  30213. */
  30214. loop?: boolean;
  30215. /**
  30216. * Automatically updates internal texture from video at every frame in the render loop
  30217. */
  30218. autoUpdateTexture: boolean;
  30219. /**
  30220. * Image src displayed during the video loading or until the user interacts with the video.
  30221. */
  30222. poster?: string;
  30223. }
  30224. /**
  30225. * If you want to display a video in your scene, this is the special texture for that.
  30226. * This special texture works similar to other textures, with the exception of a few parameters.
  30227. * @see https://doc.babylonjs.com/how_to/video_texture
  30228. */
  30229. export class VideoTexture extends Texture {
  30230. /**
  30231. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30232. */
  30233. readonly autoUpdateTexture: boolean;
  30234. /**
  30235. * The video instance used by the texture internally
  30236. */
  30237. readonly video: HTMLVideoElement;
  30238. private _onUserActionRequestedObservable;
  30239. /**
  30240. * Event triggerd when a dom action is required by the user to play the video.
  30241. * This happens due to recent changes in browser policies preventing video to auto start.
  30242. */
  30243. readonly onUserActionRequestedObservable: Observable<Texture>;
  30244. private _generateMipMaps;
  30245. private _engine;
  30246. private _stillImageCaptured;
  30247. private _displayingPosterTexture;
  30248. private _settings;
  30249. private _createInternalTextureOnEvent;
  30250. /**
  30251. * Creates a video texture.
  30252. * If you want to display a video in your scene, this is the special texture for that.
  30253. * This special texture works similar to other textures, with the exception of a few parameters.
  30254. * @see https://doc.babylonjs.com/how_to/video_texture
  30255. * @param name optional name, will detect from video source, if not defined
  30256. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30257. * @param scene is obviously the current scene.
  30258. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30259. * @param invertY is false by default but can be used to invert video on Y axis
  30260. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30261. * @param settings allows finer control over video usage
  30262. */
  30263. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30264. private _getName;
  30265. private _getVideo;
  30266. private _createInternalTexture;
  30267. private reset;
  30268. /**
  30269. * @hidden Internal method to initiate `update`.
  30270. */
  30271. _rebuild(): void;
  30272. /**
  30273. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30274. */
  30275. update(): void;
  30276. /**
  30277. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30278. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30279. */
  30280. updateTexture(isVisible: boolean): void;
  30281. protected _updateInternalTexture: () => void;
  30282. /**
  30283. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30284. * @param url New url.
  30285. */
  30286. updateURL(url: string): void;
  30287. /**
  30288. * Dispose the texture and release its associated resources.
  30289. */
  30290. dispose(): void;
  30291. /**
  30292. * Creates a video texture straight from a stream.
  30293. * @param scene Define the scene the texture should be created in
  30294. * @param stream Define the stream the texture should be created from
  30295. * @returns The created video texture as a promise
  30296. */
  30297. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30298. /**
  30299. * Creates a video texture straight from your WebCam video feed.
  30300. * @param scene Define the scene the texture should be created in
  30301. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30302. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30303. * @returns The created video texture as a promise
  30304. */
  30305. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30306. minWidth: number;
  30307. maxWidth: number;
  30308. minHeight: number;
  30309. maxHeight: number;
  30310. deviceId: string;
  30311. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30312. /**
  30313. * Creates a video texture straight from your WebCam video feed.
  30314. * @param scene Define the scene the texture should be created in
  30315. * @param onReady Define a callback to triggered once the texture will be ready
  30316. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30317. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30318. */
  30319. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30320. minWidth: number;
  30321. maxWidth: number;
  30322. minHeight: number;
  30323. maxHeight: number;
  30324. deviceId: string;
  30325. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30326. }
  30327. }
  30328. declare module "babylonjs/Engines/engine" {
  30329. import { Observable } from "babylonjs/Misc/observable";
  30330. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30331. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30332. import { Scene } from "babylonjs/scene";
  30333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30334. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30335. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30336. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30339. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30340. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30341. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30342. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30343. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30344. import { WebRequest } from "babylonjs/Misc/webRequest";
  30345. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30346. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30348. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30349. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30350. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30351. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30352. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30353. import { Material } from "babylonjs/Materials/material";
  30354. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30355. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30356. /**
  30357. * Defines the interface used by objects containing a viewport (like a camera)
  30358. */
  30359. interface IViewportOwnerLike {
  30360. /**
  30361. * Gets or sets the viewport
  30362. */
  30363. viewport: IViewportLike;
  30364. }
  30365. /**
  30366. * Interface for attribute information associated with buffer instanciation
  30367. */
  30368. export class InstancingAttributeInfo {
  30369. /**
  30370. * Index/offset of the attribute in the vertex shader
  30371. */
  30372. index: number;
  30373. /**
  30374. * size of the attribute, 1, 2, 3 or 4
  30375. */
  30376. attributeSize: number;
  30377. /**
  30378. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30379. * default is FLOAT
  30380. */
  30381. attribyteType: number;
  30382. /**
  30383. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30384. */
  30385. normalized: boolean;
  30386. /**
  30387. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30388. */
  30389. offset: number;
  30390. /**
  30391. * Name of the GLSL attribute, for debugging purpose only
  30392. */
  30393. attributeName: string;
  30394. }
  30395. /**
  30396. * Define options used to create a depth texture
  30397. */
  30398. export class DepthTextureCreationOptions {
  30399. /** Specifies whether or not a stencil should be allocated in the texture */
  30400. generateStencil?: boolean;
  30401. /** Specifies whether or not bilinear filtering is enable on the texture */
  30402. bilinearFiltering?: boolean;
  30403. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30404. comparisonFunction?: number;
  30405. /** Specifies if the created texture is a cube texture */
  30406. isCube?: boolean;
  30407. }
  30408. /**
  30409. * Class used to describe the capabilities of the engine relatively to the current browser
  30410. */
  30411. export class EngineCapabilities {
  30412. /** Maximum textures units per fragment shader */
  30413. maxTexturesImageUnits: number;
  30414. /** Maximum texture units per vertex shader */
  30415. maxVertexTextureImageUnits: number;
  30416. /** Maximum textures units in the entire pipeline */
  30417. maxCombinedTexturesImageUnits: number;
  30418. /** Maximum texture size */
  30419. maxTextureSize: number;
  30420. /** Maximum cube texture size */
  30421. maxCubemapTextureSize: number;
  30422. /** Maximum render texture size */
  30423. maxRenderTextureSize: number;
  30424. /** Maximum number of vertex attributes */
  30425. maxVertexAttribs: number;
  30426. /** Maximum number of varyings */
  30427. maxVaryingVectors: number;
  30428. /** Maximum number of uniforms per vertex shader */
  30429. maxVertexUniformVectors: number;
  30430. /** Maximum number of uniforms per fragment shader */
  30431. maxFragmentUniformVectors: number;
  30432. /** Defines if standard derivates (dx/dy) are supported */
  30433. standardDerivatives: boolean;
  30434. /** Defines if s3tc texture compression is supported */
  30435. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30436. /** Defines if pvrtc texture compression is supported */
  30437. pvrtc: any;
  30438. /** Defines if etc1 texture compression is supported */
  30439. etc1: any;
  30440. /** Defines if etc2 texture compression is supported */
  30441. etc2: any;
  30442. /** Defines if astc texture compression is supported */
  30443. astc: any;
  30444. /** Defines if float textures are supported */
  30445. textureFloat: boolean;
  30446. /** Defines if vertex array objects are supported */
  30447. vertexArrayObject: boolean;
  30448. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30449. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30450. /** Gets the maximum level of anisotropy supported */
  30451. maxAnisotropy: number;
  30452. /** Defines if instancing is supported */
  30453. instancedArrays: boolean;
  30454. /** Defines if 32 bits indices are supported */
  30455. uintIndices: boolean;
  30456. /** Defines if high precision shaders are supported */
  30457. highPrecisionShaderSupported: boolean;
  30458. /** Defines if depth reading in the fragment shader is supported */
  30459. fragmentDepthSupported: boolean;
  30460. /** Defines if float texture linear filtering is supported*/
  30461. textureFloatLinearFiltering: boolean;
  30462. /** Defines if rendering to float textures is supported */
  30463. textureFloatRender: boolean;
  30464. /** Defines if half float textures are supported*/
  30465. textureHalfFloat: boolean;
  30466. /** Defines if half float texture linear filtering is supported*/
  30467. textureHalfFloatLinearFiltering: boolean;
  30468. /** Defines if rendering to half float textures is supported */
  30469. textureHalfFloatRender: boolean;
  30470. /** Defines if textureLOD shader command is supported */
  30471. textureLOD: boolean;
  30472. /** Defines if draw buffers extension is supported */
  30473. drawBuffersExtension: boolean;
  30474. /** Defines if depth textures are supported */
  30475. depthTextureExtension: boolean;
  30476. /** Defines if float color buffer are supported */
  30477. colorBufferFloat: boolean;
  30478. /** Gets disjoint timer query extension (null if not supported) */
  30479. timerQuery: EXT_disjoint_timer_query;
  30480. /** Defines if timestamp can be used with timer query */
  30481. canUseTimestampForTimerQuery: boolean;
  30482. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30483. multiview: any;
  30484. /** Function used to let the system compiles shaders in background */
  30485. parallelShaderCompile: {
  30486. COMPLETION_STATUS_KHR: number;
  30487. };
  30488. /** Max number of texture samples for MSAA */
  30489. maxMSAASamples: number;
  30490. }
  30491. /** Interface defining initialization parameters for Engine class */
  30492. export interface EngineOptions extends WebGLContextAttributes {
  30493. /**
  30494. * Defines if the engine should no exceed a specified device ratio
  30495. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30496. */
  30497. limitDeviceRatio?: number;
  30498. /**
  30499. * Defines if webvr should be enabled automatically
  30500. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30501. */
  30502. autoEnableWebVR?: boolean;
  30503. /**
  30504. * Defines if webgl2 should be turned off even if supported
  30505. * @see http://doc.babylonjs.com/features/webgl2
  30506. */
  30507. disableWebGL2Support?: boolean;
  30508. /**
  30509. * Defines if webaudio should be initialized as well
  30510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30511. */
  30512. audioEngine?: boolean;
  30513. /**
  30514. * Defines if animations should run using a deterministic lock step
  30515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30516. */
  30517. deterministicLockstep?: boolean;
  30518. /** Defines the maximum steps to use with deterministic lock step mode */
  30519. lockstepMaxSteps?: number;
  30520. /**
  30521. * Defines that engine should ignore context lost events
  30522. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30523. */
  30524. doNotHandleContextLost?: boolean;
  30525. /**
  30526. * Defines that engine should ignore modifying touch action attribute and style
  30527. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30528. */
  30529. doNotHandleTouchAction?: boolean;
  30530. /**
  30531. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30532. */
  30533. useHighPrecisionFloats?: boolean;
  30534. }
  30535. /**
  30536. * Defines the interface used by display changed events
  30537. */
  30538. export interface IDisplayChangedEventArgs {
  30539. /** Gets the vrDisplay object (if any) */
  30540. vrDisplay: Nullable<any>;
  30541. /** Gets a boolean indicating if webVR is supported */
  30542. vrSupported: boolean;
  30543. }
  30544. /**
  30545. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30546. */
  30547. export class Engine {
  30548. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30549. static ExceptionList: ({
  30550. key: string;
  30551. capture: string;
  30552. captureConstraint: number;
  30553. targets: string[];
  30554. } | {
  30555. key: string;
  30556. capture: null;
  30557. captureConstraint: null;
  30558. targets: string[];
  30559. })[];
  30560. /** Gets the list of created engines */
  30561. static readonly Instances: Engine[];
  30562. /**
  30563. * Gets the latest created engine
  30564. */
  30565. static readonly LastCreatedEngine: Nullable<Engine>;
  30566. /**
  30567. * Gets the latest created scene
  30568. */
  30569. static readonly LastCreatedScene: Nullable<Scene>;
  30570. /**
  30571. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30572. * @param flag defines which part of the materials must be marked as dirty
  30573. * @param predicate defines a predicate used to filter which materials should be affected
  30574. */
  30575. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30576. /** @hidden */
  30577. static _TextureLoaders: IInternalTextureLoader[];
  30578. /** Defines that alpha blending is disabled */
  30579. static readonly ALPHA_DISABLE: number;
  30580. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30581. static readonly ALPHA_ADD: number;
  30582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30583. static readonly ALPHA_COMBINE: number;
  30584. /** Defines that alpha blending to DEST - SRC * DEST */
  30585. static readonly ALPHA_SUBTRACT: number;
  30586. /** Defines that alpha blending to SRC * DEST */
  30587. static readonly ALPHA_MULTIPLY: number;
  30588. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30589. static readonly ALPHA_MAXIMIZED: number;
  30590. /** Defines that alpha blending to SRC + DEST */
  30591. static readonly ALPHA_ONEONE: number;
  30592. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30593. static readonly ALPHA_PREMULTIPLIED: number;
  30594. /**
  30595. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30596. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30597. */
  30598. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30599. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30600. static readonly ALPHA_INTERPOLATE: number;
  30601. /**
  30602. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30603. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30604. */
  30605. static readonly ALPHA_SCREENMODE: number;
  30606. /** Defines that the ressource is not delayed*/
  30607. static readonly DELAYLOADSTATE_NONE: number;
  30608. /** Defines that the ressource was successfully delay loaded */
  30609. static readonly DELAYLOADSTATE_LOADED: number;
  30610. /** Defines that the ressource is currently delay loading */
  30611. static readonly DELAYLOADSTATE_LOADING: number;
  30612. /** Defines that the ressource is delayed and has not started loading */
  30613. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30615. static readonly NEVER: number;
  30616. /** 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 */
  30617. static readonly ALWAYS: number;
  30618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30619. static readonly LESS: number;
  30620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30621. static readonly EQUAL: number;
  30622. /** 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 */
  30623. static readonly LEQUAL: number;
  30624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30625. static readonly GREATER: number;
  30626. /** 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 */
  30627. static readonly GEQUAL: number;
  30628. /** 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 */
  30629. static readonly NOTEQUAL: number;
  30630. /** Passed to stencilOperation to specify that stencil value must be kept */
  30631. static readonly KEEP: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30633. static readonly REPLACE: number;
  30634. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30635. static readonly INCR: number;
  30636. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30637. static readonly DECR: number;
  30638. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30639. static readonly INVERT: number;
  30640. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30641. static readonly INCR_WRAP: number;
  30642. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30643. static readonly DECR_WRAP: number;
  30644. /** Texture is not repeating outside of 0..1 UVs */
  30645. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30646. /** Texture is repeating outside of 0..1 UVs */
  30647. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30648. /** Texture is repeating and mirrored */
  30649. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30650. /** ALPHA */
  30651. static readonly TEXTUREFORMAT_ALPHA: number;
  30652. /** LUMINANCE */
  30653. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30654. /** LUMINANCE_ALPHA */
  30655. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30656. /** RGB */
  30657. static readonly TEXTUREFORMAT_RGB: number;
  30658. /** RGBA */
  30659. static readonly TEXTUREFORMAT_RGBA: number;
  30660. /** RED */
  30661. static readonly TEXTUREFORMAT_RED: number;
  30662. /** RED (2nd reference) */
  30663. static readonly TEXTUREFORMAT_R: number;
  30664. /** RG */
  30665. static readonly TEXTUREFORMAT_RG: number;
  30666. /** RED_INTEGER */
  30667. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30668. /** RED_INTEGER (2nd reference) */
  30669. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30670. /** RG_INTEGER */
  30671. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30672. /** RGB_INTEGER */
  30673. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30674. /** RGBA_INTEGER */
  30675. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30676. /** UNSIGNED_BYTE */
  30677. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30678. /** UNSIGNED_BYTE (2nd reference) */
  30679. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30680. /** FLOAT */
  30681. static readonly TEXTURETYPE_FLOAT: number;
  30682. /** HALF_FLOAT */
  30683. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30684. /** BYTE */
  30685. static readonly TEXTURETYPE_BYTE: number;
  30686. /** SHORT */
  30687. static readonly TEXTURETYPE_SHORT: number;
  30688. /** UNSIGNED_SHORT */
  30689. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30690. /** INT */
  30691. static readonly TEXTURETYPE_INT: number;
  30692. /** UNSIGNED_INT */
  30693. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30694. /** UNSIGNED_SHORT_4_4_4_4 */
  30695. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30696. /** UNSIGNED_SHORT_5_5_5_1 */
  30697. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30698. /** UNSIGNED_SHORT_5_6_5 */
  30699. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30700. /** UNSIGNED_INT_2_10_10_10_REV */
  30701. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30702. /** UNSIGNED_INT_24_8 */
  30703. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30704. /** UNSIGNED_INT_10F_11F_11F_REV */
  30705. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30706. /** UNSIGNED_INT_5_9_9_9_REV */
  30707. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30708. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30709. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30710. /** nearest is mag = nearest and min = nearest and mip = linear */
  30711. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30713. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30714. /** Trilinear is mag = linear and min = linear and mip = linear */
  30715. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30716. /** nearest is mag = nearest and min = nearest and mip = linear */
  30717. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30719. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30720. /** Trilinear is mag = linear and min = linear and mip = linear */
  30721. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30722. /** mag = nearest and min = nearest and mip = nearest */
  30723. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30724. /** mag = nearest and min = linear and mip = nearest */
  30725. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30726. /** mag = nearest and min = linear and mip = linear */
  30727. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30728. /** mag = nearest and min = linear and mip = none */
  30729. static readonly TEXTURE_NEAREST_LINEAR: number;
  30730. /** mag = nearest and min = nearest and mip = none */
  30731. static readonly TEXTURE_NEAREST_NEAREST: number;
  30732. /** mag = linear and min = nearest and mip = nearest */
  30733. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30734. /** mag = linear and min = nearest and mip = linear */
  30735. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30736. /** mag = linear and min = linear and mip = none */
  30737. static readonly TEXTURE_LINEAR_LINEAR: number;
  30738. /** mag = linear and min = nearest and mip = none */
  30739. static readonly TEXTURE_LINEAR_NEAREST: number;
  30740. /** Explicit coordinates mode */
  30741. static readonly TEXTURE_EXPLICIT_MODE: number;
  30742. /** Spherical coordinates mode */
  30743. static readonly TEXTURE_SPHERICAL_MODE: number;
  30744. /** Planar coordinates mode */
  30745. static readonly TEXTURE_PLANAR_MODE: number;
  30746. /** Cubic coordinates mode */
  30747. static readonly TEXTURE_CUBIC_MODE: number;
  30748. /** Projection coordinates mode */
  30749. static readonly TEXTURE_PROJECTION_MODE: number;
  30750. /** Skybox coordinates mode */
  30751. static readonly TEXTURE_SKYBOX_MODE: number;
  30752. /** Inverse Cubic coordinates mode */
  30753. static readonly TEXTURE_INVCUBIC_MODE: number;
  30754. /** Equirectangular coordinates mode */
  30755. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30756. /** Equirectangular Fixed coordinates mode */
  30757. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30758. /** Equirectangular Fixed Mirrored coordinates mode */
  30759. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30760. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30761. static readonly SCALEMODE_FLOOR: number;
  30762. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30763. static readonly SCALEMODE_NEAREST: number;
  30764. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30765. static readonly SCALEMODE_CEILING: number;
  30766. /**
  30767. * Returns the current npm package of the sdk
  30768. */
  30769. static readonly NpmPackage: string;
  30770. /**
  30771. * Returns the current version of the framework
  30772. */
  30773. static readonly Version: string;
  30774. /**
  30775. * Returns a string describing the current engine
  30776. */
  30777. readonly description: string;
  30778. /**
  30779. * Gets or sets the epsilon value used by collision engine
  30780. */
  30781. static CollisionsEpsilon: number;
  30782. /**
  30783. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30784. */
  30785. static ShadersRepository: string;
  30786. /**
  30787. * Method called to create the default loading screen.
  30788. * This can be overriden in your own app.
  30789. * @param canvas The rendering canvas element
  30790. * @returns The loading screen
  30791. */
  30792. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30793. /**
  30794. * Method called to create the default rescale post process on each engine.
  30795. */
  30796. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30797. /** @hidden */
  30798. _shaderProcessor: IShaderProcessor;
  30799. /**
  30800. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30801. */
  30802. forcePOTTextures: boolean;
  30803. /**
  30804. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30805. */
  30806. isFullscreen: boolean;
  30807. /**
  30808. * Gets a boolean indicating if the pointer is currently locked
  30809. */
  30810. isPointerLock: boolean;
  30811. /**
  30812. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30813. */
  30814. cullBackFaces: boolean;
  30815. /**
  30816. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30817. */
  30818. renderEvenInBackground: boolean;
  30819. /**
  30820. * Gets or sets a boolean indicating that cache can be kept between frames
  30821. */
  30822. preventCacheWipeBetweenFrames: boolean;
  30823. /**
  30824. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30825. **/
  30826. enableOfflineSupport: boolean;
  30827. /**
  30828. * 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)
  30829. **/
  30830. disableManifestCheck: boolean;
  30831. /**
  30832. * Gets the list of created scenes
  30833. */
  30834. scenes: Scene[];
  30835. /**
  30836. * Event raised when a new scene is created
  30837. */
  30838. onNewSceneAddedObservable: Observable<Scene>;
  30839. /**
  30840. * Gets the list of created postprocesses
  30841. */
  30842. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30843. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30844. validateShaderPrograms: boolean;
  30845. /**
  30846. * Observable event triggered each time the rendering canvas is resized
  30847. */
  30848. onResizeObservable: Observable<Engine>;
  30849. /**
  30850. * Observable event triggered each time the canvas loses focus
  30851. */
  30852. onCanvasBlurObservable: Observable<Engine>;
  30853. /**
  30854. * Observable event triggered each time the canvas gains focus
  30855. */
  30856. onCanvasFocusObservable: Observable<Engine>;
  30857. /**
  30858. * Observable event triggered each time the canvas receives pointerout event
  30859. */
  30860. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30861. /**
  30862. * Observable event triggered before each texture is initialized
  30863. */
  30864. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30865. /**
  30866. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30867. */
  30868. disableUniformBuffers: boolean;
  30869. /** @hidden */
  30870. _uniformBuffers: UniformBuffer[];
  30871. /**
  30872. * Gets a boolean indicating that the engine supports uniform buffers
  30873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30874. */
  30875. readonly supportsUniformBuffers: boolean;
  30876. /**
  30877. * Observable raised when the engine begins a new frame
  30878. */
  30879. onBeginFrameObservable: Observable<Engine>;
  30880. /**
  30881. * If set, will be used to request the next animation frame for the render loop
  30882. */
  30883. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30884. /**
  30885. * Observable raised when the engine ends the current frame
  30886. */
  30887. onEndFrameObservable: Observable<Engine>;
  30888. /**
  30889. * Observable raised when the engine is about to compile a shader
  30890. */
  30891. onBeforeShaderCompilationObservable: Observable<Engine>;
  30892. /**
  30893. * Observable raised when the engine has jsut compiled a shader
  30894. */
  30895. onAfterShaderCompilationObservable: Observable<Engine>;
  30896. /** @hidden */
  30897. _gl: WebGLRenderingContext;
  30898. private _renderingCanvas;
  30899. private _windowIsBackground;
  30900. private _webGLVersion;
  30901. protected _highPrecisionShadersAllowed: boolean;
  30902. /** @hidden */
  30903. readonly _shouldUseHighPrecisionShader: boolean;
  30904. /**
  30905. * Gets a boolean indicating that only power of 2 textures are supported
  30906. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30907. */
  30908. readonly needPOTTextures: boolean;
  30909. /** @hidden */
  30910. _badOS: boolean;
  30911. /** @hidden */
  30912. _badDesktopOS: boolean;
  30913. /**
  30914. * Gets the audio engine
  30915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30916. * @ignorenaming
  30917. */
  30918. static audioEngine: IAudioEngine;
  30919. /**
  30920. * Default AudioEngine factory responsible of creating the Audio Engine.
  30921. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30922. */
  30923. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30924. /**
  30925. * Default offline support factory responsible of creating a tool used to store data locally.
  30926. * By default, this will create a Database object if the workload has been embedded.
  30927. */
  30928. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30929. private _onFocus;
  30930. private _onBlur;
  30931. private _onCanvasPointerOut;
  30932. private _onCanvasBlur;
  30933. private _onCanvasFocus;
  30934. private _onFullscreenChange;
  30935. private _onPointerLockChange;
  30936. private _hardwareScalingLevel;
  30937. /** @hidden */
  30938. _caps: EngineCapabilities;
  30939. private _pointerLockRequested;
  30940. private _isStencilEnable;
  30941. private _colorWrite;
  30942. private _loadingScreen;
  30943. /** @hidden */
  30944. _drawCalls: PerfCounter;
  30945. private _glVersion;
  30946. private _glRenderer;
  30947. private _glVendor;
  30948. private _videoTextureSupported;
  30949. private _renderingQueueLaunched;
  30950. private _activeRenderLoops;
  30951. private _deterministicLockstep;
  30952. private _lockstepMaxSteps;
  30953. /**
  30954. * Observable signaled when a context lost event is raised
  30955. */
  30956. onContextLostObservable: Observable<Engine>;
  30957. /**
  30958. * Observable signaled when a context restored event is raised
  30959. */
  30960. onContextRestoredObservable: Observable<Engine>;
  30961. private _onContextLost;
  30962. private _onContextRestored;
  30963. private _contextWasLost;
  30964. /** @hidden */
  30965. _doNotHandleContextLost: boolean;
  30966. /**
  30967. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30969. */
  30970. doNotHandleContextLost: boolean;
  30971. private _performanceMonitor;
  30972. private _fps;
  30973. private _deltaTime;
  30974. /**
  30975. * Turn this value on if you want to pause FPS computation when in background
  30976. */
  30977. disablePerformanceMonitorInBackground: boolean;
  30978. /**
  30979. * Gets the performance monitor attached to this engine
  30980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30981. */
  30982. readonly performanceMonitor: PerformanceMonitor;
  30983. /**
  30984. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30985. */
  30986. disableVertexArrayObjects: boolean;
  30987. /** @hidden */
  30988. protected _depthCullingState: _DepthCullingState;
  30989. /** @hidden */
  30990. protected _stencilState: _StencilState;
  30991. /** @hidden */
  30992. protected _alphaState: _AlphaState;
  30993. /** @hidden */
  30994. protected _alphaMode: number;
  30995. /** @hidden */
  30996. _internalTexturesCache: InternalTexture[];
  30997. /** @hidden */
  30998. protected _activeChannel: number;
  30999. private _currentTextureChannel;
  31000. /** @hidden */
  31001. protected _boundTexturesCache: {
  31002. [key: string]: Nullable<InternalTexture>;
  31003. };
  31004. /** @hidden */
  31005. protected _currentEffect: Nullable<Effect>;
  31006. /** @hidden */
  31007. protected _currentProgram: Nullable<WebGLProgram>;
  31008. private _compiledEffects;
  31009. private _vertexAttribArraysEnabled;
  31010. /** @hidden */
  31011. protected _cachedViewport: Nullable<IViewportLike>;
  31012. private _cachedVertexArrayObject;
  31013. /** @hidden */
  31014. protected _cachedVertexBuffers: any;
  31015. /** @hidden */
  31016. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31017. /** @hidden */
  31018. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31019. /** @hidden */
  31020. _currentRenderTarget: Nullable<InternalTexture>;
  31021. private _uintIndicesCurrentlySet;
  31022. private _currentBoundBuffer;
  31023. /** @hidden */
  31024. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31025. private _currentBufferPointers;
  31026. private _currentInstanceLocations;
  31027. private _currentInstanceBuffers;
  31028. private _textureUnits;
  31029. /** @hidden */
  31030. _workingCanvas: Nullable<HTMLCanvasElement>;
  31031. /** @hidden */
  31032. _workingContext: Nullable<CanvasRenderingContext2D>;
  31033. private _rescalePostProcess;
  31034. private _dummyFramebuffer;
  31035. private _externalData;
  31036. /** @hidden */
  31037. _bindedRenderFunction: any;
  31038. private _vaoRecordInProgress;
  31039. private _mustWipeVertexAttributes;
  31040. private _emptyTexture;
  31041. private _emptyCubeTexture;
  31042. private _emptyTexture3D;
  31043. /** @hidden */
  31044. _frameHandler: number;
  31045. private _nextFreeTextureSlots;
  31046. private _maxSimultaneousTextures;
  31047. private _activeRequests;
  31048. private _texturesSupported;
  31049. /** @hidden */
  31050. _textureFormatInUse: Nullable<string>;
  31051. /**
  31052. * Gets the list of texture formats supported
  31053. */
  31054. readonly texturesSupported: Array<string>;
  31055. /**
  31056. * Gets the list of texture formats in use
  31057. */
  31058. readonly textureFormatInUse: Nullable<string>;
  31059. /**
  31060. * Gets the current viewport
  31061. */
  31062. readonly currentViewport: Nullable<IViewportLike>;
  31063. /**
  31064. * Gets the default empty texture
  31065. */
  31066. readonly emptyTexture: InternalTexture;
  31067. /**
  31068. * Gets the default empty 3D texture
  31069. */
  31070. readonly emptyTexture3D: InternalTexture;
  31071. /**
  31072. * Gets the default empty cube texture
  31073. */
  31074. readonly emptyCubeTexture: InternalTexture;
  31075. /**
  31076. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31077. */
  31078. readonly premultipliedAlpha: boolean;
  31079. /**
  31080. * Creates a new engine
  31081. * @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
  31082. * @param antialias defines enable antialiasing (default: false)
  31083. * @param options defines further options to be sent to the getContext() function
  31084. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31085. */
  31086. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31087. /**
  31088. * Initializes a webVR display and starts listening to display change events
  31089. * The onVRDisplayChangedObservable will be notified upon these changes
  31090. * @returns The onVRDisplayChangedObservable
  31091. */
  31092. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31093. /** @hidden */
  31094. _prepareVRComponent(): void;
  31095. /** @hidden */
  31096. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31097. /** @hidden */
  31098. _submitVRFrame(): void;
  31099. /**
  31100. * Call this function to leave webVR mode
  31101. * Will do nothing if webVR is not supported or if there is no webVR device
  31102. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31103. */
  31104. disableVR(): void;
  31105. /**
  31106. * Gets a boolean indicating that the system is in VR mode and is presenting
  31107. * @returns true if VR mode is engaged
  31108. */
  31109. isVRPresenting(): boolean;
  31110. /** @hidden */
  31111. _requestVRFrame(): void;
  31112. private _disableTouchAction;
  31113. private _rebuildInternalTextures;
  31114. private _rebuildEffects;
  31115. /**
  31116. * Gets a boolean indicating if all created effects are ready
  31117. * @returns true if all effects are ready
  31118. */
  31119. areAllEffectsReady(): boolean;
  31120. private _rebuildBuffers;
  31121. private _initGLContext;
  31122. /**
  31123. * Gets version of the current webGL context
  31124. */
  31125. readonly webGLVersion: number;
  31126. /**
  31127. * Gets a string idenfifying the name of the class
  31128. * @returns "Engine" string
  31129. */
  31130. getClassName(): string;
  31131. /**
  31132. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31133. */
  31134. readonly isStencilEnable: boolean;
  31135. /** @hidden */
  31136. _prepareWorkingCanvas(): void;
  31137. /**
  31138. * Reset the texture cache to empty state
  31139. */
  31140. resetTextureCache(): void;
  31141. /**
  31142. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31143. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31144. * @returns true if engine is in deterministic lock step mode
  31145. */
  31146. isDeterministicLockStep(): boolean;
  31147. /**
  31148. * Gets the max steps when engine is running in deterministic lock step
  31149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31150. * @returns the max steps
  31151. */
  31152. getLockstepMaxSteps(): number;
  31153. /**
  31154. * Gets an object containing information about the current webGL context
  31155. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31156. */
  31157. getGlInfo(): {
  31158. vendor: string;
  31159. renderer: string;
  31160. version: string;
  31161. };
  31162. /**
  31163. * Gets current aspect ratio
  31164. * @param viewportOwner defines the camera to use to get the aspect ratio
  31165. * @param useScreen defines if screen size must be used (or the current render target if any)
  31166. * @returns a number defining the aspect ratio
  31167. */
  31168. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31169. /**
  31170. * Gets current screen aspect ratio
  31171. * @returns a number defining the aspect ratio
  31172. */
  31173. getScreenAspectRatio(): number;
  31174. /**
  31175. * Gets the current render width
  31176. * @param useScreen defines if screen size must be used (or the current render target if any)
  31177. * @returns a number defining the current render width
  31178. */
  31179. getRenderWidth(useScreen?: boolean): number;
  31180. /**
  31181. * Gets the current render height
  31182. * @param useScreen defines if screen size must be used (or the current render target if any)
  31183. * @returns a number defining the current render height
  31184. */
  31185. getRenderHeight(useScreen?: boolean): number;
  31186. /**
  31187. * Gets the HTML canvas attached with the current webGL context
  31188. * @returns a HTML canvas
  31189. */
  31190. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31191. /**
  31192. * Gets host window
  31193. * @returns the host window object
  31194. */
  31195. getHostWindow(): Window;
  31196. /**
  31197. * Gets host document
  31198. * @returns the host document object
  31199. */
  31200. getHostDocument(): Document;
  31201. /**
  31202. * Gets the client rect of the HTML canvas attached with the current webGL context
  31203. * @returns a client rectanglee
  31204. */
  31205. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31206. /**
  31207. * Defines the hardware scaling level.
  31208. * By default the hardware scaling level is computed from the window device ratio.
  31209. * 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.
  31210. * @param level defines the level to use
  31211. */
  31212. setHardwareScalingLevel(level: number): void;
  31213. /**
  31214. * Gets the current hardware scaling level.
  31215. * By default the hardware scaling level is computed from the window device ratio.
  31216. * 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.
  31217. * @returns a number indicating the current hardware scaling level
  31218. */
  31219. getHardwareScalingLevel(): number;
  31220. /**
  31221. * Gets the list of loaded textures
  31222. * @returns an array containing all loaded textures
  31223. */
  31224. getLoadedTexturesCache(): InternalTexture[];
  31225. /**
  31226. * Gets the object containing all engine capabilities
  31227. * @returns the EngineCapabilities object
  31228. */
  31229. getCaps(): EngineCapabilities;
  31230. /**
  31231. * Gets the current depth function
  31232. * @returns a number defining the depth function
  31233. */
  31234. getDepthFunction(): Nullable<number>;
  31235. /**
  31236. * Sets the current depth function
  31237. * @param depthFunc defines the function to use
  31238. */
  31239. setDepthFunction(depthFunc: number): void;
  31240. /**
  31241. * Sets the current depth function to GREATER
  31242. */
  31243. setDepthFunctionToGreater(): void;
  31244. /**
  31245. * Sets the current depth function to GEQUAL
  31246. */
  31247. setDepthFunctionToGreaterOrEqual(): void;
  31248. /**
  31249. * Sets the current depth function to LESS
  31250. */
  31251. setDepthFunctionToLess(): void;
  31252. private _cachedStencilBuffer;
  31253. private _cachedStencilFunction;
  31254. private _cachedStencilMask;
  31255. private _cachedStencilOperationPass;
  31256. private _cachedStencilOperationFail;
  31257. private _cachedStencilOperationDepthFail;
  31258. private _cachedStencilReference;
  31259. /**
  31260. * Caches the the state of the stencil buffer
  31261. */
  31262. cacheStencilState(): void;
  31263. /**
  31264. * Restores the state of the stencil buffer
  31265. */
  31266. restoreStencilState(): void;
  31267. /**
  31268. * Sets the current depth function to LEQUAL
  31269. */
  31270. setDepthFunctionToLessOrEqual(): void;
  31271. /**
  31272. * Gets a boolean indicating if stencil buffer is enabled
  31273. * @returns the current stencil buffer state
  31274. */
  31275. getStencilBuffer(): boolean;
  31276. /**
  31277. * Enable or disable the stencil buffer
  31278. * @param enable defines if the stencil buffer must be enabled or disabled
  31279. */
  31280. setStencilBuffer(enable: boolean): void;
  31281. /**
  31282. * Gets the current stencil mask
  31283. * @returns a number defining the new stencil mask to use
  31284. */
  31285. getStencilMask(): number;
  31286. /**
  31287. * Sets the current stencil mask
  31288. * @param mask defines the new stencil mask to use
  31289. */
  31290. setStencilMask(mask: number): void;
  31291. /**
  31292. * Gets the current stencil function
  31293. * @returns a number defining the stencil function to use
  31294. */
  31295. getStencilFunction(): number;
  31296. /**
  31297. * Gets the current stencil reference value
  31298. * @returns a number defining the stencil reference value to use
  31299. */
  31300. getStencilFunctionReference(): number;
  31301. /**
  31302. * Gets the current stencil mask
  31303. * @returns a number defining the stencil mask to use
  31304. */
  31305. getStencilFunctionMask(): number;
  31306. /**
  31307. * Sets the current stencil function
  31308. * @param stencilFunc defines the new stencil function to use
  31309. */
  31310. setStencilFunction(stencilFunc: number): void;
  31311. /**
  31312. * Sets the current stencil reference
  31313. * @param reference defines the new stencil reference to use
  31314. */
  31315. setStencilFunctionReference(reference: number): void;
  31316. /**
  31317. * Sets the current stencil mask
  31318. * @param mask defines the new stencil mask to use
  31319. */
  31320. setStencilFunctionMask(mask: number): void;
  31321. /**
  31322. * Gets the current stencil operation when stencil fails
  31323. * @returns a number defining stencil operation to use when stencil fails
  31324. */
  31325. getStencilOperationFail(): number;
  31326. /**
  31327. * Gets the current stencil operation when depth fails
  31328. * @returns a number defining stencil operation to use when depth fails
  31329. */
  31330. getStencilOperationDepthFail(): number;
  31331. /**
  31332. * Gets the current stencil operation when stencil passes
  31333. * @returns a number defining stencil operation to use when stencil passes
  31334. */
  31335. getStencilOperationPass(): number;
  31336. /**
  31337. * Sets the stencil operation to use when stencil fails
  31338. * @param operation defines the stencil operation to use when stencil fails
  31339. */
  31340. setStencilOperationFail(operation: number): void;
  31341. /**
  31342. * Sets the stencil operation to use when depth fails
  31343. * @param operation defines the stencil operation to use when depth fails
  31344. */
  31345. setStencilOperationDepthFail(operation: number): void;
  31346. /**
  31347. * Sets the stencil operation to use when stencil passes
  31348. * @param operation defines the stencil operation to use when stencil passes
  31349. */
  31350. setStencilOperationPass(operation: number): void;
  31351. /**
  31352. * Sets a boolean indicating if the dithering state is enabled or disabled
  31353. * @param value defines the dithering state
  31354. */
  31355. setDitheringState(value: boolean): void;
  31356. /**
  31357. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31358. * @param value defines the rasterizer state
  31359. */
  31360. setRasterizerState(value: boolean): void;
  31361. /**
  31362. * stop executing a render loop function and remove it from the execution array
  31363. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31364. */
  31365. stopRenderLoop(renderFunction?: () => void): void;
  31366. /** @hidden */
  31367. _renderLoop(): void;
  31368. /**
  31369. * Register and execute a render loop. The engine can have more than one render function
  31370. * @param renderFunction defines the function to continuously execute
  31371. */
  31372. runRenderLoop(renderFunction: () => void): void;
  31373. /**
  31374. * Toggle full screen mode
  31375. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31376. */
  31377. switchFullscreen(requestPointerLock: boolean): void;
  31378. /**
  31379. * Enters full screen mode
  31380. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31381. */
  31382. enterFullscreen(requestPointerLock: boolean): void;
  31383. /**
  31384. * Exits full screen mode
  31385. */
  31386. exitFullscreen(): void;
  31387. /**
  31388. * Enters Pointerlock mode
  31389. */
  31390. enterPointerlock(): void;
  31391. /**
  31392. * Exits Pointerlock mode
  31393. */
  31394. exitPointerlock(): void;
  31395. /**
  31396. * Clear the current render buffer or the current render target (if any is set up)
  31397. * @param color defines the color to use
  31398. * @param backBuffer defines if the back buffer must be cleared
  31399. * @param depth defines if the depth buffer must be cleared
  31400. * @param stencil defines if the stencil buffer must be cleared
  31401. */
  31402. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31403. /**
  31404. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31405. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31406. * @param y defines the y-coordinate of the corner of the clear rectangle
  31407. * @param width defines the width of the clear rectangle
  31408. * @param height defines the height of the clear rectangle
  31409. * @param clearColor defines the clear color
  31410. */
  31411. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31412. /**
  31413. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31414. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31415. * @param y defines the y-coordinate of the corner of the clear rectangle
  31416. * @param width defines the width of the clear rectangle
  31417. * @param height defines the height of the clear rectangle
  31418. */
  31419. enableScissor(x: number, y: number, width: number, height: number): void;
  31420. /**
  31421. * Disable previously set scissor test rectangle
  31422. */
  31423. disableScissor(): void;
  31424. private _viewportCached;
  31425. /** @hidden */
  31426. _viewport(x: number, y: number, width: number, height: number): void;
  31427. /**
  31428. * Set the WebGL's viewport
  31429. * @param viewport defines the viewport element to be used
  31430. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31431. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31432. */
  31433. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31434. /**
  31435. * Directly set the WebGL Viewport
  31436. * @param x defines the x coordinate of the viewport (in screen space)
  31437. * @param y defines the y coordinate of the viewport (in screen space)
  31438. * @param width defines the width of the viewport (in screen space)
  31439. * @param height defines the height of the viewport (in screen space)
  31440. * @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
  31441. */
  31442. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31443. /**
  31444. * Begin a new frame
  31445. */
  31446. beginFrame(): void;
  31447. /**
  31448. * Enf the current frame
  31449. */
  31450. endFrame(): void;
  31451. /**
  31452. * Resize the view according to the canvas' size
  31453. */
  31454. resize(): void;
  31455. /**
  31456. * Force a specific size of the canvas
  31457. * @param width defines the new canvas' width
  31458. * @param height defines the new canvas' height
  31459. */
  31460. setSize(width: number, height: number): void;
  31461. /**
  31462. * Binds the frame buffer to the specified texture.
  31463. * @param texture The texture to render to or null for the default canvas
  31464. * @param faceIndex The face of the texture to render to in case of cube texture
  31465. * @param requiredWidth The width of the target to render to
  31466. * @param requiredHeight The height of the target to render to
  31467. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31468. * @param depthStencilTexture The depth stencil texture to use to render
  31469. * @param lodLevel defines le lod level to bind to the frame buffer
  31470. */
  31471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31472. /** @hidden */
  31473. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31474. /**
  31475. * Unbind the current render target texture from the webGL context
  31476. * @param texture defines the render target texture to unbind
  31477. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31478. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31479. */
  31480. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31481. /**
  31482. * Force the mipmap generation for the given render target texture
  31483. * @param texture defines the render target texture to use
  31484. */
  31485. generateMipMapsForCubemap(texture: InternalTexture): void;
  31486. /**
  31487. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31488. */
  31489. flushFramebuffer(): void;
  31490. /**
  31491. * Unbind the current render target and bind the default framebuffer
  31492. */
  31493. restoreDefaultFramebuffer(): void;
  31494. /**
  31495. * Create an uniform buffer
  31496. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31497. * @param elements defines the content of the uniform buffer
  31498. * @returns the webGL uniform buffer
  31499. */
  31500. createUniformBuffer(elements: FloatArray): DataBuffer;
  31501. /**
  31502. * Create a dynamic uniform buffer
  31503. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31504. * @param elements defines the content of the uniform buffer
  31505. * @returns the webGL uniform buffer
  31506. */
  31507. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31508. /**
  31509. * Update an existing uniform buffer
  31510. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31511. * @param uniformBuffer defines the target uniform buffer
  31512. * @param elements defines the content to update
  31513. * @param offset defines the offset in the uniform buffer where update should start
  31514. * @param count defines the size of the data to update
  31515. */
  31516. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31517. private _resetVertexBufferBinding;
  31518. /**
  31519. * Creates a vertex buffer
  31520. * @param data the data for the vertex buffer
  31521. * @returns the new WebGL static buffer
  31522. */
  31523. createVertexBuffer(data: DataArray): DataBuffer;
  31524. /**
  31525. * Creates a dynamic vertex buffer
  31526. * @param data the data for the dynamic vertex buffer
  31527. * @returns the new WebGL dynamic buffer
  31528. */
  31529. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31530. /**
  31531. * Update a dynamic index buffer
  31532. * @param indexBuffer defines the target index buffer
  31533. * @param indices defines the data to update
  31534. * @param offset defines the offset in the target index buffer where update should start
  31535. */
  31536. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31537. /**
  31538. * Updates a dynamic vertex buffer.
  31539. * @param vertexBuffer the vertex buffer to update
  31540. * @param data the data used to update the vertex buffer
  31541. * @param byteOffset the byte offset of the data
  31542. * @param byteLength the byte length of the data
  31543. */
  31544. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31545. private _resetIndexBufferBinding;
  31546. /**
  31547. * Creates a new index buffer
  31548. * @param indices defines the content of the index buffer
  31549. * @param updatable defines if the index buffer must be updatable
  31550. * @returns a new webGL buffer
  31551. */
  31552. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31553. /**
  31554. * Bind a webGL buffer to the webGL context
  31555. * @param buffer defines the buffer to bind
  31556. */
  31557. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31558. /**
  31559. * Bind an uniform buffer to the current webGL context
  31560. * @param buffer defines the buffer to bind
  31561. */
  31562. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31563. /**
  31564. * Bind a buffer to the current webGL context at a given location
  31565. * @param buffer defines the buffer to bind
  31566. * @param location defines the index where to bind the buffer
  31567. */
  31568. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31569. /**
  31570. * Bind a specific block at a given index in a specific shader program
  31571. * @param pipelineContext defines the pipeline context to use
  31572. * @param blockName defines the block name
  31573. * @param index defines the index where to bind the block
  31574. */
  31575. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31576. private bindIndexBuffer;
  31577. private bindBuffer;
  31578. /**
  31579. * update the bound buffer with the given data
  31580. * @param data defines the data to update
  31581. */
  31582. updateArrayBuffer(data: Float32Array): void;
  31583. private _vertexAttribPointer;
  31584. private _bindIndexBufferWithCache;
  31585. private _bindVertexBuffersAttributes;
  31586. /**
  31587. * Records a vertex array object
  31588. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31589. * @param vertexBuffers defines the list of vertex buffers to store
  31590. * @param indexBuffer defines the index buffer to store
  31591. * @param effect defines the effect to store
  31592. * @returns the new vertex array object
  31593. */
  31594. recordVertexArrayObject(vertexBuffers: {
  31595. [key: string]: VertexBuffer;
  31596. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31597. /**
  31598. * Bind a specific vertex array object
  31599. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31600. * @param vertexArrayObject defines the vertex array object to bind
  31601. * @param indexBuffer defines the index buffer to bind
  31602. */
  31603. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31604. /**
  31605. * Bind webGl buffers directly to the webGL context
  31606. * @param vertexBuffer defines the vertex buffer to bind
  31607. * @param indexBuffer defines the index buffer to bind
  31608. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31609. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31610. * @param effect defines the effect associated with the vertex buffer
  31611. */
  31612. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31613. private _unbindVertexArrayObject;
  31614. /**
  31615. * Bind a list of vertex buffers to the webGL context
  31616. * @param vertexBuffers defines the list of vertex buffers to bind
  31617. * @param indexBuffer defines the index buffer to bind
  31618. * @param effect defines the effect associated with the vertex buffers
  31619. */
  31620. bindBuffers(vertexBuffers: {
  31621. [key: string]: Nullable<VertexBuffer>;
  31622. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31623. /**
  31624. * Unbind all instance attributes
  31625. */
  31626. unbindInstanceAttributes(): void;
  31627. /**
  31628. * Release and free the memory of a vertex array object
  31629. * @param vao defines the vertex array object to delete
  31630. */
  31631. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31632. /** @hidden */
  31633. _releaseBuffer(buffer: DataBuffer): boolean;
  31634. /**
  31635. * Creates a webGL buffer to use with instanciation
  31636. * @param capacity defines the size of the buffer
  31637. * @returns the webGL buffer
  31638. */
  31639. createInstancesBuffer(capacity: number): DataBuffer;
  31640. /**
  31641. * Delete a webGL buffer used with instanciation
  31642. * @param buffer defines the webGL buffer to delete
  31643. */
  31644. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31645. /**
  31646. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31647. * @param instancesBuffer defines the webGL buffer to update and bind
  31648. * @param data defines the data to store in the buffer
  31649. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31650. */
  31651. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31652. /**
  31653. * Apply all cached states (depth, culling, stencil and alpha)
  31654. */
  31655. applyStates(): void;
  31656. /**
  31657. * Send a draw order
  31658. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31659. * @param indexStart defines the starting index
  31660. * @param indexCount defines the number of index to draw
  31661. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31662. */
  31663. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31664. /**
  31665. * Draw a list of points
  31666. * @param verticesStart defines the index of first vertex to draw
  31667. * @param verticesCount defines the count of vertices to draw
  31668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31669. */
  31670. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31671. /**
  31672. * Draw a list of unindexed primitives
  31673. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31674. * @param verticesStart defines the index of first vertex to draw
  31675. * @param verticesCount defines the count of vertices to draw
  31676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31677. */
  31678. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31679. /**
  31680. * Draw a list of indexed primitives
  31681. * @param fillMode defines the primitive to use
  31682. * @param indexStart defines the starting index
  31683. * @param indexCount defines the number of index to draw
  31684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31685. */
  31686. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31687. /**
  31688. * Draw a list of unindexed primitives
  31689. * @param fillMode defines the primitive to use
  31690. * @param verticesStart defines the index of first vertex to draw
  31691. * @param verticesCount defines the count of vertices to draw
  31692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31693. */
  31694. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31695. private _drawMode;
  31696. /** @hidden */
  31697. _releaseEffect(effect: Effect): void;
  31698. /** @hidden */
  31699. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31700. /**
  31701. * Create a new effect (used to store vertex/fragment shaders)
  31702. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31703. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31704. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31705. * @param samplers defines an array of string used to represent textures
  31706. * @param defines defines the string containing the defines to use to compile the shaders
  31707. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31708. * @param onCompiled defines a function to call when the effect creation is successful
  31709. * @param onError defines a function to call when the effect creation has failed
  31710. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31711. * @returns the new Effect
  31712. */
  31713. 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;
  31714. private _compileShader;
  31715. private _compileRawShader;
  31716. /**
  31717. * Directly creates a webGL program
  31718. * @param pipelineContext defines the pipeline context to attach to
  31719. * @param vertexCode defines the vertex shader code to use
  31720. * @param fragmentCode defines the fragment shader code to use
  31721. * @param context defines the webGL context to use (if not set, the current one will be used)
  31722. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31723. * @returns the new webGL program
  31724. */
  31725. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31726. /**
  31727. * Creates a webGL program
  31728. * @param pipelineContext defines the pipeline context to attach to
  31729. * @param vertexCode defines the vertex shader code to use
  31730. * @param fragmentCode defines the fragment shader code to use
  31731. * @param defines defines the string containing the defines to use to compile the shaders
  31732. * @param context defines the webGL context to use (if not set, the current one will be used)
  31733. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31734. * @returns the new webGL program
  31735. */
  31736. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31737. /**
  31738. * Creates a new pipeline context
  31739. * @returns the new pipeline
  31740. */
  31741. createPipelineContext(): WebGLPipelineContext;
  31742. private _createShaderProgram;
  31743. private _finalizePipelineContext;
  31744. /** @hidden */
  31745. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31746. /** @hidden */
  31747. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31748. /** @hidden */
  31749. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31750. /**
  31751. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31752. * @param pipelineContext defines the pipeline context to use
  31753. * @param uniformsNames defines the list of uniform names
  31754. * @returns an array of webGL uniform locations
  31755. */
  31756. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31757. /**
  31758. * Gets the lsit of active attributes for a given webGL program
  31759. * @param pipelineContext defines the pipeline context to use
  31760. * @param attributesNames defines the list of attribute names to get
  31761. * @returns an array of indices indicating the offset of each attribute
  31762. */
  31763. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31764. /**
  31765. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31766. * @param effect defines the effect to activate
  31767. */
  31768. enableEffect(effect: Nullable<Effect>): void;
  31769. /**
  31770. * Set the value of an uniform to an array of int32
  31771. * @param uniform defines the webGL uniform location where to store the value
  31772. * @param array defines the array of int32 to store
  31773. */
  31774. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31775. /**
  31776. * Set the value of an uniform to an array of int32 (stored as vec2)
  31777. * @param uniform defines the webGL uniform location where to store the value
  31778. * @param array defines the array of int32 to store
  31779. */
  31780. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31781. /**
  31782. * Set the value of an uniform to an array of int32 (stored as vec3)
  31783. * @param uniform defines the webGL uniform location where to store the value
  31784. * @param array defines the array of int32 to store
  31785. */
  31786. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31787. /**
  31788. * Set the value of an uniform to an array of int32 (stored as vec4)
  31789. * @param uniform defines the webGL uniform location where to store the value
  31790. * @param array defines the array of int32 to store
  31791. */
  31792. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31793. /**
  31794. * Set the value of an uniform to an array of float32
  31795. * @param uniform defines the webGL uniform location where to store the value
  31796. * @param array defines the array of float32 to store
  31797. */
  31798. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31799. /**
  31800. * Set the value of an uniform to an array of float32 (stored as vec2)
  31801. * @param uniform defines the webGL uniform location where to store the value
  31802. * @param array defines the array of float32 to store
  31803. */
  31804. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31805. /**
  31806. * Set the value of an uniform to an array of float32 (stored as vec3)
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param array defines the array of float32 to store
  31809. */
  31810. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31811. /**
  31812. * Set the value of an uniform to an array of float32 (stored as vec4)
  31813. * @param uniform defines the webGL uniform location where to store the value
  31814. * @param array defines the array of float32 to store
  31815. */
  31816. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31817. /**
  31818. * Set the value of an uniform to an array of number
  31819. * @param uniform defines the webGL uniform location where to store the value
  31820. * @param array defines the array of number to store
  31821. */
  31822. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31823. /**
  31824. * Set the value of an uniform to an array of number (stored as vec2)
  31825. * @param uniform defines the webGL uniform location where to store the value
  31826. * @param array defines the array of number to store
  31827. */
  31828. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31829. /**
  31830. * Set the value of an uniform to an array of number (stored as vec3)
  31831. * @param uniform defines the webGL uniform location where to store the value
  31832. * @param array defines the array of number to store
  31833. */
  31834. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31835. /**
  31836. * Set the value of an uniform to an array of number (stored as vec4)
  31837. * @param uniform defines the webGL uniform location where to store the value
  31838. * @param array defines the array of number to store
  31839. */
  31840. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31841. /**
  31842. * Set the value of an uniform to an array of float32 (stored as matrices)
  31843. * @param uniform defines the webGL uniform location where to store the value
  31844. * @param matrices defines the array of float32 to store
  31845. */
  31846. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31847. /**
  31848. * Set the value of an uniform to a matrix (3x3)
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31851. */
  31852. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31853. /**
  31854. * Set the value of an uniform to a matrix (2x2)
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31857. */
  31858. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31859. /**
  31860. * Set the value of an uniform to a number (int)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param value defines the int number to store
  31863. */
  31864. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31865. /**
  31866. * Set the value of an uniform to a number (float)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param value defines the float number to store
  31869. */
  31870. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31871. /**
  31872. * Set the value of an uniform to a vec2
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param x defines the 1st component of the value
  31875. * @param y defines the 2nd component of the value
  31876. */
  31877. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31878. /**
  31879. * Set the value of an uniform to a vec3
  31880. * @param uniform defines the webGL uniform location where to store the value
  31881. * @param x defines the 1st component of the value
  31882. * @param y defines the 2nd component of the value
  31883. * @param z defines the 3rd component of the value
  31884. */
  31885. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31886. /**
  31887. * Set the value of an uniform to a boolean
  31888. * @param uniform defines the webGL uniform location where to store the value
  31889. * @param bool defines the boolean to store
  31890. */
  31891. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31892. /**
  31893. * Set the value of an uniform to a vec4
  31894. * @param uniform defines the webGL uniform location where to store the value
  31895. * @param x defines the 1st component of the value
  31896. * @param y defines the 2nd component of the value
  31897. * @param z defines the 3rd component of the value
  31898. * @param w defines the 4th component of the value
  31899. */
  31900. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31901. /**
  31902. * Sets a Color4 on a uniform variable
  31903. * @param uniform defines the uniform location
  31904. * @param color4 defines the value to be set
  31905. */
  31906. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31907. /**
  31908. * Set various states to the webGL context
  31909. * @param culling defines backface culling state
  31910. * @param zOffset defines the value to apply to zOffset (0 by default)
  31911. * @param force defines if states must be applied even if cache is up to date
  31912. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31913. */
  31914. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31915. /**
  31916. * Set the z offset to apply to current rendering
  31917. * @param value defines the offset to apply
  31918. */
  31919. setZOffset(value: number): void;
  31920. /**
  31921. * Gets the current value of the zOffset
  31922. * @returns the current zOffset state
  31923. */
  31924. getZOffset(): number;
  31925. /**
  31926. * Enable or disable depth buffering
  31927. * @param enable defines the state to set
  31928. */
  31929. setDepthBuffer(enable: boolean): void;
  31930. /**
  31931. * Gets a boolean indicating if depth writing is enabled
  31932. * @returns the current depth writing state
  31933. */
  31934. getDepthWrite(): boolean;
  31935. /**
  31936. * Enable or disable depth writing
  31937. * @param enable defines the state to set
  31938. */
  31939. setDepthWrite(enable: boolean): void;
  31940. /**
  31941. * Enable or disable color writing
  31942. * @param enable defines the state to set
  31943. */
  31944. setColorWrite(enable: boolean): void;
  31945. /**
  31946. * Gets a boolean indicating if color writing is enabled
  31947. * @returns the current color writing state
  31948. */
  31949. getColorWrite(): boolean;
  31950. /**
  31951. * Sets alpha constants used by some alpha blending modes
  31952. * @param r defines the red component
  31953. * @param g defines the green component
  31954. * @param b defines the blue component
  31955. * @param a defines the alpha component
  31956. */
  31957. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31958. /**
  31959. * Sets the current alpha mode
  31960. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31961. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31963. */
  31964. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31965. /**
  31966. * Gets the current alpha mode
  31967. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31968. * @returns the current alpha mode
  31969. */
  31970. getAlphaMode(): number;
  31971. /**
  31972. * Clears the list of texture accessible through engine.
  31973. * This can help preventing texture load conflict due to name collision.
  31974. */
  31975. clearInternalTexturesCache(): void;
  31976. /**
  31977. * Force the entire cache to be cleared
  31978. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31979. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31980. */
  31981. wipeCaches(bruteForce?: boolean): void;
  31982. /**
  31983. * Set the compressed texture format to use, based on the formats you have, and the formats
  31984. * supported by the hardware / browser.
  31985. *
  31986. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31987. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31988. * to API arguments needed to compressed textures. This puts the burden on the container
  31989. * generator to house the arcane code for determining these for current & future formats.
  31990. *
  31991. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31992. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31993. *
  31994. * Note: The result of this call is not taken into account when a texture is base64.
  31995. *
  31996. * @param formatsAvailable defines the list of those format families you have created
  31997. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31998. *
  31999. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32000. * @returns The extension selected.
  32001. */
  32002. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32003. /** @hidden */
  32004. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32005. min: number;
  32006. mag: number;
  32007. };
  32008. /** @hidden */
  32009. _createTexture(): WebGLTexture;
  32010. /**
  32011. * Usually called from Texture.ts.
  32012. * Passed information to create a WebGLTexture
  32013. * @param urlArg defines a value which contains one of the following:
  32014. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32015. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32016. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32017. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32018. * @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)
  32019. * @param scene needed for loading to the correct scene
  32020. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32021. * @param onLoad optional callback to be called upon successful completion
  32022. * @param onError optional callback to be called upon failure
  32023. * @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
  32024. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32025. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32026. * @param forcedExtension defines the extension to use to pick the right loader
  32027. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32028. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32029. */
  32030. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32031. /**
  32032. * @hidden
  32033. * Rescales a texture
  32034. * @param source input texutre
  32035. * @param destination destination texture
  32036. * @param scene scene to use to render the resize
  32037. * @param internalFormat format to use when resizing
  32038. * @param onComplete callback to be called when resize has completed
  32039. */
  32040. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32041. private _unpackFlipYCached;
  32042. /**
  32043. * In case you are sharing the context with other applications, it might
  32044. * be interested to not cache the unpack flip y state to ensure a consistent
  32045. * value would be set.
  32046. */
  32047. enableUnpackFlipYCached: boolean;
  32048. /** @hidden */
  32049. _unpackFlipY(value: boolean): void;
  32050. /** @hidden */
  32051. _getUnpackAlignement(): number;
  32052. /**
  32053. * Creates a dynamic texture
  32054. * @param width defines the width of the texture
  32055. * @param height defines the height of the texture
  32056. * @param generateMipMaps defines if the engine should generate the mip levels
  32057. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32058. * @returns the dynamic texture inside an InternalTexture
  32059. */
  32060. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32061. /**
  32062. * Update the sampling mode of a given texture
  32063. * @param samplingMode defines the required sampling mode
  32064. * @param texture defines the texture to update
  32065. */
  32066. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32067. /**
  32068. * Update the content of a dynamic texture
  32069. * @param texture defines the texture to update
  32070. * @param canvas defines the canvas containing the source
  32071. * @param invertY defines if data must be stored with Y axis inverted
  32072. * @param premulAlpha defines if alpha is stored as premultiplied
  32073. * @param format defines the format of the data
  32074. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32075. */
  32076. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32077. /**
  32078. * Update a video texture
  32079. * @param texture defines the texture to update
  32080. * @param video defines the video element to use
  32081. * @param invertY defines if data must be stored with Y axis inverted
  32082. */
  32083. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32084. /**
  32085. * Updates a depth texture Comparison Mode and Function.
  32086. * If the comparison Function is equal to 0, the mode will be set to none.
  32087. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32088. * @param texture The texture to set the comparison function for
  32089. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32090. */
  32091. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32092. /** @hidden */
  32093. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32094. width: number;
  32095. height: number;
  32096. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32097. /**
  32098. * Creates a depth stencil texture.
  32099. * This is only available in WebGL 2 or with the depth texture extension available.
  32100. * @param size The size of face edge in the texture.
  32101. * @param options The options defining the texture.
  32102. * @returns The texture
  32103. */
  32104. createDepthStencilTexture(size: number | {
  32105. width: number;
  32106. height: number;
  32107. }, options: DepthTextureCreationOptions): InternalTexture;
  32108. /**
  32109. * Creates a depth stencil texture.
  32110. * This is only available in WebGL 2 or with the depth texture extension available.
  32111. * @param size The size of face edge in the texture.
  32112. * @param options The options defining the texture.
  32113. * @returns The texture
  32114. */
  32115. private _createDepthStencilTexture;
  32116. /**
  32117. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32118. * @param renderTarget The render target to set the frame buffer for
  32119. */
  32120. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32121. /**
  32122. * Creates a new render target texture
  32123. * @param size defines the size of the texture
  32124. * @param options defines the options used to create the texture
  32125. * @returns a new render target texture stored in an InternalTexture
  32126. */
  32127. createRenderTargetTexture(size: number | {
  32128. width: number;
  32129. height: number;
  32130. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32131. /** @hidden */
  32132. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32133. /**
  32134. * Updates the sample count of a render target texture
  32135. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32136. * @param texture defines the texture to update
  32137. * @param samples defines the sample count to set
  32138. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32139. */
  32140. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32141. /** @hidden */
  32142. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32143. /** @hidden */
  32144. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32145. /** @hidden */
  32146. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32147. /** @hidden */
  32148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32149. /**
  32150. * @hidden
  32151. */
  32152. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32153. private _prepareWebGLTextureContinuation;
  32154. private _prepareWebGLTexture;
  32155. /** @hidden */
  32156. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32157. /** @hidden */
  32158. _releaseFramebufferObjects(texture: InternalTexture): void;
  32159. /** @hidden */
  32160. _releaseTexture(texture: InternalTexture): void;
  32161. private setProgram;
  32162. private _boundUniforms;
  32163. /**
  32164. * Binds an effect to the webGL context
  32165. * @param effect defines the effect to bind
  32166. */
  32167. bindSamplers(effect: Effect): void;
  32168. private _activateCurrentTexture;
  32169. /** @hidden */
  32170. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32171. /** @hidden */
  32172. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32173. /**
  32174. * Sets a texture to the webGL context from a postprocess
  32175. * @param channel defines the channel to use
  32176. * @param postProcess defines the source postprocess
  32177. */
  32178. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32179. /**
  32180. * Binds the output of the passed in post process to the texture channel specified
  32181. * @param channel The channel the texture should be bound to
  32182. * @param postProcess The post process which's output should be bound
  32183. */
  32184. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32185. /**
  32186. * Unbind all textures from the webGL context
  32187. */
  32188. unbindAllTextures(): void;
  32189. /**
  32190. * Sets a texture to the according uniform.
  32191. * @param channel The texture channel
  32192. * @param uniform The uniform to set
  32193. * @param texture The texture to apply
  32194. */
  32195. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32196. /**
  32197. * Sets a depth stencil texture from a render target to the according uniform.
  32198. * @param channel The texture channel
  32199. * @param uniform The uniform to set
  32200. * @param texture The render target texture containing the depth stencil texture to apply
  32201. */
  32202. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32203. private _bindSamplerUniformToChannel;
  32204. private _getTextureWrapMode;
  32205. private _setTexture;
  32206. /**
  32207. * Sets an array of texture to the webGL context
  32208. * @param channel defines the channel where the texture array must be set
  32209. * @param uniform defines the associated uniform location
  32210. * @param textures defines the array of textures to bind
  32211. */
  32212. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32213. /** @hidden */
  32214. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32215. private _setTextureParameterFloat;
  32216. private _setTextureParameterInteger;
  32217. /**
  32218. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32219. * @param x defines the x coordinate of the rectangle where pixels must be read
  32220. * @param y defines the y coordinate of the rectangle where pixels must be read
  32221. * @param width defines the width of the rectangle where pixels must be read
  32222. * @param height defines the height of the rectangle where pixels must be read
  32223. * @returns a Uint8Array containing RGBA colors
  32224. */
  32225. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32226. /**
  32227. * Add an externaly attached data from its key.
  32228. * This method call will fail and return false, if such key already exists.
  32229. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32230. * @param key the unique key that identifies the data
  32231. * @param data the data object to associate to the key for this Engine instance
  32232. * @return true if no such key were already present and the data was added successfully, false otherwise
  32233. */
  32234. addExternalData<T>(key: string, data: T): boolean;
  32235. /**
  32236. * Get an externaly attached data from its key
  32237. * @param key the unique key that identifies the data
  32238. * @return the associated data, if present (can be null), or undefined if not present
  32239. */
  32240. getExternalData<T>(key: string): T;
  32241. /**
  32242. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32243. * @param key the unique key that identifies the data
  32244. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32245. * @return the associated data, can be null if the factory returned null.
  32246. */
  32247. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32248. /**
  32249. * Remove an externaly attached data from the Engine instance
  32250. * @param key the unique key that identifies the data
  32251. * @return true if the data was successfully removed, false if it doesn't exist
  32252. */
  32253. removeExternalData(key: string): boolean;
  32254. /**
  32255. * Unbind all vertex attributes from the webGL context
  32256. */
  32257. unbindAllAttributes(): void;
  32258. /**
  32259. * 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
  32260. */
  32261. releaseEffects(): void;
  32262. /**
  32263. * Dispose and release all associated resources
  32264. */
  32265. dispose(): void;
  32266. /**
  32267. * Display the loading screen
  32268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32269. */
  32270. displayLoadingUI(): void;
  32271. /**
  32272. * Hide the loading screen
  32273. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32274. */
  32275. hideLoadingUI(): void;
  32276. /**
  32277. * Gets the current loading screen object
  32278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32279. */
  32280. /**
  32281. * Sets the current loading screen object
  32282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32283. */
  32284. loadingScreen: ILoadingScreen;
  32285. /**
  32286. * Sets the current loading screen text
  32287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32288. */
  32289. loadingUIText: string;
  32290. /**
  32291. * Sets the current loading screen background color
  32292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32293. */
  32294. loadingUIBackgroundColor: string;
  32295. /**
  32296. * Attach a new callback raised when context lost event is fired
  32297. * @param callback defines the callback to call
  32298. */
  32299. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32300. /**
  32301. * Attach a new callback raised when context restored event is fired
  32302. * @param callback defines the callback to call
  32303. */
  32304. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32305. /**
  32306. * Gets the source code of the vertex shader associated with a specific webGL program
  32307. * @param program defines the program to use
  32308. * @returns a string containing the source code of the vertex shader associated with the program
  32309. */
  32310. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32311. /**
  32312. * Gets the source code of the fragment shader associated with a specific webGL program
  32313. * @param program defines the program to use
  32314. * @returns a string containing the source code of the fragment shader associated with the program
  32315. */
  32316. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32317. /**
  32318. * Get the current error code of the webGL context
  32319. * @returns the error code
  32320. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32321. */
  32322. getError(): number;
  32323. /**
  32324. * Gets the current framerate
  32325. * @returns a number representing the framerate
  32326. */
  32327. getFps(): number;
  32328. /**
  32329. * Gets the time spent between current and previous frame
  32330. * @returns a number representing the delta time in ms
  32331. */
  32332. getDeltaTime(): number;
  32333. private _measureFps;
  32334. /** @hidden */
  32335. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32336. private _canRenderToFloatFramebuffer;
  32337. private _canRenderToHalfFloatFramebuffer;
  32338. private _canRenderToFramebuffer;
  32339. /** @hidden */
  32340. _getWebGLTextureType(type: number): number;
  32341. /** @hidden */
  32342. _getInternalFormat(format: number): number;
  32343. /** @hidden */
  32344. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32345. /** @hidden */
  32346. _getRGBAMultiSampleBufferFormat(type: number): number;
  32347. /** @hidden */
  32348. _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;
  32349. /** @hidden */
  32350. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32351. /**
  32352. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32353. * @returns true if the engine can be created
  32354. * @ignorenaming
  32355. */
  32356. static isSupported(): boolean;
  32357. /**
  32358. * Find the next highest power of two.
  32359. * @param x Number to start search from.
  32360. * @return Next highest power of two.
  32361. */
  32362. static CeilingPOT(x: number): number;
  32363. /**
  32364. * Find the next lowest power of two.
  32365. * @param x Number to start search from.
  32366. * @return Next lowest power of two.
  32367. */
  32368. static FloorPOT(x: number): number;
  32369. /**
  32370. * Find the nearest power of two.
  32371. * @param x Number to start search from.
  32372. * @return Next nearest power of two.
  32373. */
  32374. static NearestPOT(x: number): number;
  32375. /**
  32376. * Get the closest exponent of two
  32377. * @param value defines the value to approximate
  32378. * @param max defines the maximum value to return
  32379. * @param mode defines how to define the closest value
  32380. * @returns closest exponent of two of the given value
  32381. */
  32382. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32383. /**
  32384. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32385. * @param func - the function to be called
  32386. * @param requester - the object that will request the next frame. Falls back to window.
  32387. * @returns frame number
  32388. */
  32389. static QueueNewFrame(func: () => void, requester?: any): number;
  32390. /**
  32391. * Ask the browser to promote the current element to pointerlock mode
  32392. * @param element defines the DOM element to promote
  32393. */
  32394. static _RequestPointerlock(element: HTMLElement): void;
  32395. /**
  32396. * Asks the browser to exit pointerlock mode
  32397. */
  32398. static _ExitPointerlock(): void;
  32399. /**
  32400. * Ask the browser to promote the current element to fullscreen rendering mode
  32401. * @param element defines the DOM element to promote
  32402. */
  32403. static _RequestFullscreen(element: HTMLElement): void;
  32404. /**
  32405. * Asks the browser to exit fullscreen mode
  32406. */
  32407. static _ExitFullscreen(): void;
  32408. }
  32409. }
  32410. declare module "babylonjs/Engines/engineStore" {
  32411. import { Nullable } from "babylonjs/types";
  32412. import { Engine } from "babylonjs/Engines/engine";
  32413. import { Scene } from "babylonjs/scene";
  32414. /**
  32415. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32416. * during the life time of the application.
  32417. */
  32418. export class EngineStore {
  32419. /** Gets the list of created engines */
  32420. static Instances: import("babylonjs/Engines/engine").Engine[];
  32421. /** @hidden */
  32422. static _LastCreatedScene: Nullable<Scene>;
  32423. /**
  32424. * Gets the latest created engine
  32425. */
  32426. static readonly LastCreatedEngine: Nullable<Engine>;
  32427. /**
  32428. * Gets the latest created scene
  32429. */
  32430. static readonly LastCreatedScene: Nullable<Scene>;
  32431. /**
  32432. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32433. * @ignorenaming
  32434. */
  32435. static UseFallbackTexture: boolean;
  32436. /**
  32437. * Texture content used if a texture cannot loaded
  32438. * @ignorenaming
  32439. */
  32440. static FallbackTexture: string;
  32441. }
  32442. }
  32443. declare module "babylonjs/Misc/promise" {
  32444. /**
  32445. * Helper class that provides a small promise polyfill
  32446. */
  32447. export class PromisePolyfill {
  32448. /**
  32449. * Static function used to check if the polyfill is required
  32450. * If this is the case then the function will inject the polyfill to window.Promise
  32451. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32452. */
  32453. static Apply(force?: boolean): void;
  32454. }
  32455. }
  32456. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32457. /**
  32458. * Interface for screenshot methods with describe argument called `size` as object with options
  32459. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32460. */
  32461. export interface IScreenshotSize {
  32462. /**
  32463. * number in pixels for canvas height
  32464. */
  32465. height?: number;
  32466. /**
  32467. * multiplier allowing render at a higher or lower resolution
  32468. * If value is defined then height and width will be ignored and taken from camera
  32469. */
  32470. precision?: number;
  32471. /**
  32472. * number in pixels for canvas width
  32473. */
  32474. width?: number;
  32475. }
  32476. }
  32477. declare module "babylonjs/Misc/tools" {
  32478. import { Nullable, float } from "babylonjs/types";
  32479. import { DomManagement } from "babylonjs/Misc/domManagement";
  32480. import { WebRequest } from "babylonjs/Misc/webRequest";
  32481. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32482. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32483. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32484. import { Camera } from "babylonjs/Cameras/camera";
  32485. import { Engine } from "babylonjs/Engines/engine";
  32486. interface IColor4Like {
  32487. r: float;
  32488. g: float;
  32489. b: float;
  32490. a: float;
  32491. }
  32492. /**
  32493. * Class containing a set of static utilities functions
  32494. */
  32495. export class Tools {
  32496. /**
  32497. * Gets or sets the base URL to use to load assets
  32498. */
  32499. static BaseUrl: string;
  32500. /**
  32501. * Enable/Disable Custom HTTP Request Headers globally.
  32502. * default = false
  32503. * @see CustomRequestHeaders
  32504. */
  32505. static UseCustomRequestHeaders: boolean;
  32506. /**
  32507. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32508. * i.e. when loading files, where the server/service expects an Authorization header
  32509. */
  32510. static CustomRequestHeaders: {
  32511. [key: string]: string;
  32512. };
  32513. /**
  32514. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32515. */
  32516. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32517. /**
  32518. * Default behaviour for cors in the application.
  32519. * It can be a string if the expected behavior is identical in the entire app.
  32520. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32521. */
  32522. static CorsBehavior: string | ((url: string | string[]) => string);
  32523. /**
  32524. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32525. * @ignorenaming
  32526. */
  32527. static UseFallbackTexture: boolean;
  32528. /**
  32529. * Use this object to register external classes like custom textures or material
  32530. * to allow the laoders to instantiate them
  32531. */
  32532. static RegisteredExternalClasses: {
  32533. [key: string]: Object;
  32534. };
  32535. /**
  32536. * Texture content used if a texture cannot loaded
  32537. * @ignorenaming
  32538. */
  32539. static fallbackTexture: string;
  32540. /**
  32541. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32542. * @param u defines the coordinate on X axis
  32543. * @param v defines the coordinate on Y axis
  32544. * @param width defines the width of the source data
  32545. * @param height defines the height of the source data
  32546. * @param pixels defines the source byte array
  32547. * @param color defines the output color
  32548. */
  32549. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32550. /**
  32551. * Interpolates between a and b via alpha
  32552. * @param a The lower value (returned when alpha = 0)
  32553. * @param b The upper value (returned when alpha = 1)
  32554. * @param alpha The interpolation-factor
  32555. * @return The mixed value
  32556. */
  32557. static Mix(a: number, b: number, alpha: number): number;
  32558. /**
  32559. * Tries to instantiate a new object from a given class name
  32560. * @param className defines the class name to instantiate
  32561. * @returns the new object or null if the system was not able to do the instantiation
  32562. */
  32563. static Instantiate(className: string): any;
  32564. /**
  32565. * Provides a slice function that will work even on IE
  32566. * @param data defines the array to slice
  32567. * @param start defines the start of the data (optional)
  32568. * @param end defines the end of the data (optional)
  32569. * @returns the new sliced array
  32570. */
  32571. static Slice<T>(data: T, start?: number, end?: number): T;
  32572. /**
  32573. * Polyfill for setImmediate
  32574. * @param action defines the action to execute after the current execution block
  32575. */
  32576. static SetImmediate(action: () => void): void;
  32577. /**
  32578. * Function indicating if a number is an exponent of 2
  32579. * @param value defines the value to test
  32580. * @returns true if the value is an exponent of 2
  32581. */
  32582. static IsExponentOfTwo(value: number): boolean;
  32583. private static _tmpFloatArray;
  32584. /**
  32585. * Returns the nearest 32-bit single precision float representation of a Number
  32586. * @param value A Number. If the parameter is of a different type, it will get converted
  32587. * to a number or to NaN if it cannot be converted
  32588. * @returns number
  32589. */
  32590. static FloatRound(value: number): number;
  32591. /**
  32592. * Extracts the filename from a path
  32593. * @param path defines the path to use
  32594. * @returns the filename
  32595. */
  32596. static GetFilename(path: string): string;
  32597. /**
  32598. * Extracts the "folder" part of a path (everything before the filename).
  32599. * @param uri The URI to extract the info from
  32600. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32601. * @returns The "folder" part of the path
  32602. */
  32603. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32604. /**
  32605. * Extracts text content from a DOM element hierarchy
  32606. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32607. */
  32608. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32609. /**
  32610. * Convert an angle in radians to degrees
  32611. * @param angle defines the angle to convert
  32612. * @returns the angle in degrees
  32613. */
  32614. static ToDegrees(angle: number): number;
  32615. /**
  32616. * Convert an angle in degrees to radians
  32617. * @param angle defines the angle to convert
  32618. * @returns the angle in radians
  32619. */
  32620. static ToRadians(angle: number): number;
  32621. /**
  32622. * Encode a buffer to a base64 string
  32623. * @param buffer defines the buffer to encode
  32624. * @returns the encoded string
  32625. */
  32626. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32627. /**
  32628. * Returns an array if obj is not an array
  32629. * @param obj defines the object to evaluate as an array
  32630. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32631. * @returns either obj directly if obj is an array or a new array containing obj
  32632. */
  32633. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32634. /**
  32635. * Gets the pointer prefix to use
  32636. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32637. */
  32638. static GetPointerPrefix(): string;
  32639. /**
  32640. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32641. * @param url define the url we are trying
  32642. * @param element define the dom element where to configure the cors policy
  32643. */
  32644. static SetCorsBehavior(url: string | string[], element: {
  32645. crossOrigin: string | null;
  32646. }): void;
  32647. /**
  32648. * Removes unwanted characters from an url
  32649. * @param url defines the url to clean
  32650. * @returns the cleaned url
  32651. */
  32652. static CleanUrl(url: string): string;
  32653. /**
  32654. * Gets or sets a function used to pre-process url before using them to load assets
  32655. */
  32656. static PreprocessUrl: (url: string) => string;
  32657. /**
  32658. * Loads an image as an HTMLImageElement.
  32659. * @param input url string, ArrayBuffer, or Blob to load
  32660. * @param onLoad callback called when the image successfully loads
  32661. * @param onError callback called when the image fails to load
  32662. * @param offlineProvider offline provider for caching
  32663. * @returns the HTMLImageElement of the loaded image
  32664. */
  32665. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32666. /**
  32667. * Loads a file
  32668. * @param url url string, ArrayBuffer, or Blob to load
  32669. * @param onSuccess callback called when the file successfully loads
  32670. * @param onProgress callback called while file is loading (if the server supports this mode)
  32671. * @param offlineProvider defines the offline provider for caching
  32672. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32673. * @param onError callback called when the file fails to load
  32674. * @returns a file request object
  32675. */
  32676. 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;
  32677. /**
  32678. * Loads a file from a url
  32679. * @param url the file url to load
  32680. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32681. */
  32682. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32683. /**
  32684. * Load a script (identified by an url). When the url returns, the
  32685. * content of this file is added into a new script element, attached to the DOM (body element)
  32686. * @param scriptUrl defines the url of the script to laod
  32687. * @param onSuccess defines the callback called when the script is loaded
  32688. * @param onError defines the callback to call if an error occurs
  32689. * @param scriptId defines the id of the script element
  32690. */
  32691. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32692. /**
  32693. * Load an asynchronous script (identified by an url). When the url returns, the
  32694. * content of this file is added into a new script element, attached to the DOM (body element)
  32695. * @param scriptUrl defines the url of the script to laod
  32696. * @param scriptId defines the id of the script element
  32697. * @returns a promise request object
  32698. */
  32699. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32700. /**
  32701. * Loads a file from a blob
  32702. * @param fileToLoad defines the blob to use
  32703. * @param callback defines the callback to call when data is loaded
  32704. * @param progressCallback defines the callback to call during loading process
  32705. * @returns a file request object
  32706. */
  32707. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32708. /**
  32709. * Loads a file
  32710. * @param fileToLoad defines the file to load
  32711. * @param callback defines the callback to call when data is loaded
  32712. * @param progressCallBack defines the callback to call during loading process
  32713. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32714. * @returns a file request object
  32715. */
  32716. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32717. /**
  32718. * Creates a data url from a given string content
  32719. * @param content defines the content to convert
  32720. * @returns the new data url link
  32721. */
  32722. static FileAsURL(content: string): string;
  32723. /**
  32724. * Format the given number to a specific decimal format
  32725. * @param value defines the number to format
  32726. * @param decimals defines the number of decimals to use
  32727. * @returns the formatted string
  32728. */
  32729. static Format(value: number, decimals?: number): string;
  32730. /**
  32731. * Tries to copy an object by duplicating every property
  32732. * @param source defines the source object
  32733. * @param destination defines the target object
  32734. * @param doNotCopyList defines a list of properties to avoid
  32735. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32736. */
  32737. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32738. /**
  32739. * Gets a boolean indicating if the given object has no own property
  32740. * @param obj defines the object to test
  32741. * @returns true if object has no own property
  32742. */
  32743. static IsEmpty(obj: any): boolean;
  32744. /**
  32745. * Function used to register events at window level
  32746. * @param windowElement defines the Window object to use
  32747. * @param events defines the events to register
  32748. */
  32749. static RegisterTopRootEvents(windowElement: Window, events: {
  32750. name: string;
  32751. handler: Nullable<(e: FocusEvent) => any>;
  32752. }[]): void;
  32753. /**
  32754. * Function used to unregister events from window level
  32755. * @param windowElement defines the Window object to use
  32756. * @param events defines the events to unregister
  32757. */
  32758. static UnregisterTopRootEvents(windowElement: Window, events: {
  32759. name: string;
  32760. handler: Nullable<(e: FocusEvent) => any>;
  32761. }[]): void;
  32762. /**
  32763. * @ignore
  32764. */
  32765. static _ScreenshotCanvas: HTMLCanvasElement;
  32766. /**
  32767. * Dumps the current bound framebuffer
  32768. * @param width defines the rendering width
  32769. * @param height defines the rendering height
  32770. * @param engine defines the hosting engine
  32771. * @param successCallback defines the callback triggered once the data are available
  32772. * @param mimeType defines the mime type of the result
  32773. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32774. */
  32775. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32776. /**
  32777. * Converts the canvas data to blob.
  32778. * This acts as a polyfill for browsers not supporting the to blob function.
  32779. * @param canvas Defines the canvas to extract the data from
  32780. * @param successCallback Defines the callback triggered once the data are available
  32781. * @param mimeType Defines the mime type of the result
  32782. */
  32783. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32784. /**
  32785. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32786. * @param successCallback defines the callback triggered once the data are available
  32787. * @param mimeType defines the mime type of the result
  32788. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32789. */
  32790. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32791. /**
  32792. * Downloads a blob in the browser
  32793. * @param blob defines the blob to download
  32794. * @param fileName defines the name of the downloaded file
  32795. */
  32796. static Download(blob: Blob, fileName: string): void;
  32797. /**
  32798. * Captures a screenshot of the current rendering
  32799. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32800. * @param engine defines the rendering engine
  32801. * @param camera defines the source camera
  32802. * @param size This parameter can be set to a single number or to an object with the
  32803. * following (optional) properties: precision, width, height. If a single number is passed,
  32804. * it will be used for both width and height. If an object is passed, the screenshot size
  32805. * will be derived from the parameters. The precision property is a multiplier allowing
  32806. * rendering at a higher or lower resolution
  32807. * @param successCallback defines the callback receives a single parameter which contains the
  32808. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32809. * src parameter of an <img> to display it
  32810. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32811. * Check your browser for supported MIME types
  32812. */
  32813. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32814. /**
  32815. * Captures a screenshot of the current rendering
  32816. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32817. * @param engine defines the rendering engine
  32818. * @param camera defines the source camera
  32819. * @param size This parameter can be set to a single number or to an object with the
  32820. * following (optional) properties: precision, width, height. If a single number is passed,
  32821. * it will be used for both width and height. If an object is passed, the screenshot size
  32822. * will be derived from the parameters. The precision property is a multiplier allowing
  32823. * rendering at a higher or lower resolution
  32824. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32825. * Check your browser for supported MIME types
  32826. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32827. * to the src parameter of an <img> to display it
  32828. */
  32829. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32830. /**
  32831. * Generates an image screenshot from the specified camera.
  32832. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32833. * @param engine The engine to use for rendering
  32834. * @param camera The camera to use for rendering
  32835. * @param size This parameter can be set to a single number or to an object with the
  32836. * following (optional) properties: precision, width, height. If a single number is passed,
  32837. * it will be used for both width and height. If an object is passed, the screenshot size
  32838. * will be derived from the parameters. The precision property is a multiplier allowing
  32839. * rendering at a higher or lower resolution
  32840. * @param successCallback The callback receives a single parameter which contains the
  32841. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32842. * src parameter of an <img> to display it
  32843. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32844. * Check your browser for supported MIME types
  32845. * @param samples Texture samples (default: 1)
  32846. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32847. * @param fileName A name for for the downloaded file.
  32848. */
  32849. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32850. /**
  32851. * Generates an image screenshot from the specified camera.
  32852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32853. * @param engine The engine to use for rendering
  32854. * @param camera The camera to use for rendering
  32855. * @param size This parameter can be set to a single number or to an object with the
  32856. * following (optional) properties: precision, width, height. If a single number is passed,
  32857. * it will be used for both width and height. If an object is passed, the screenshot size
  32858. * will be derived from the parameters. The precision property is a multiplier allowing
  32859. * rendering at a higher or lower resolution
  32860. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32861. * Check your browser for supported MIME types
  32862. * @param samples Texture samples (default: 1)
  32863. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32864. * @param fileName A name for for the downloaded file.
  32865. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32866. * to the src parameter of an <img> to display it
  32867. */
  32868. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32869. /**
  32870. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32871. * Be aware Math.random() could cause collisions, but:
  32872. * "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"
  32873. * @returns a pseudo random id
  32874. */
  32875. static RandomId(): string;
  32876. /**
  32877. * Test if the given uri is a base64 string
  32878. * @param uri The uri to test
  32879. * @return True if the uri is a base64 string or false otherwise
  32880. */
  32881. static IsBase64(uri: string): boolean;
  32882. /**
  32883. * Decode the given base64 uri.
  32884. * @param uri The uri to decode
  32885. * @return The decoded base64 data.
  32886. */
  32887. static DecodeBase64(uri: string): ArrayBuffer;
  32888. /**
  32889. * Gets the absolute url.
  32890. * @param url the input url
  32891. * @return the absolute url
  32892. */
  32893. static GetAbsoluteUrl(url: string): string;
  32894. /**
  32895. * No log
  32896. */
  32897. static readonly NoneLogLevel: number;
  32898. /**
  32899. * Only message logs
  32900. */
  32901. static readonly MessageLogLevel: number;
  32902. /**
  32903. * Only warning logs
  32904. */
  32905. static readonly WarningLogLevel: number;
  32906. /**
  32907. * Only error logs
  32908. */
  32909. static readonly ErrorLogLevel: number;
  32910. /**
  32911. * All logs
  32912. */
  32913. static readonly AllLogLevel: number;
  32914. /**
  32915. * Gets a value indicating the number of loading errors
  32916. * @ignorenaming
  32917. */
  32918. static readonly errorsCount: number;
  32919. /**
  32920. * Callback called when a new log is added
  32921. */
  32922. static OnNewCacheEntry: (entry: string) => void;
  32923. /**
  32924. * Log a message to the console
  32925. * @param message defines the message to log
  32926. */
  32927. static Log(message: string): void;
  32928. /**
  32929. * Write a warning message to the console
  32930. * @param message defines the message to log
  32931. */
  32932. static Warn(message: string): void;
  32933. /**
  32934. * Write an error message to the console
  32935. * @param message defines the message to log
  32936. */
  32937. static Error(message: string): void;
  32938. /**
  32939. * Gets current log cache (list of logs)
  32940. */
  32941. static readonly LogCache: string;
  32942. /**
  32943. * Clears the log cache
  32944. */
  32945. static ClearLogCache(): void;
  32946. /**
  32947. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32948. */
  32949. static LogLevels: number;
  32950. /**
  32951. * Checks if the window object exists
  32952. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32953. */
  32954. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32955. /**
  32956. * No performance log
  32957. */
  32958. static readonly PerformanceNoneLogLevel: number;
  32959. /**
  32960. * Use user marks to log performance
  32961. */
  32962. static readonly PerformanceUserMarkLogLevel: number;
  32963. /**
  32964. * Log performance to the console
  32965. */
  32966. static readonly PerformanceConsoleLogLevel: number;
  32967. private static _performance;
  32968. /**
  32969. * Sets the current performance log level
  32970. */
  32971. static PerformanceLogLevel: number;
  32972. private static _StartPerformanceCounterDisabled;
  32973. private static _EndPerformanceCounterDisabled;
  32974. private static _StartUserMark;
  32975. private static _EndUserMark;
  32976. private static _StartPerformanceConsole;
  32977. private static _EndPerformanceConsole;
  32978. /**
  32979. * Starts a performance counter
  32980. */
  32981. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32982. /**
  32983. * Ends a specific performance coutner
  32984. */
  32985. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32986. /**
  32987. * Gets either window.performance.now() if supported or Date.now() else
  32988. */
  32989. static readonly Now: number;
  32990. /**
  32991. * This method will return the name of the class used to create the instance of the given object.
  32992. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32993. * @param object the object to get the class name from
  32994. * @param isType defines if the object is actually a type
  32995. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32996. */
  32997. static GetClassName(object: any, isType?: boolean): string;
  32998. /**
  32999. * Gets the first element of an array satisfying a given predicate
  33000. * @param array defines the array to browse
  33001. * @param predicate defines the predicate to use
  33002. * @returns null if not found or the element
  33003. */
  33004. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33005. /**
  33006. * This method will return the name of the full name of the class, including its owning module (if any).
  33007. * 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).
  33008. * @param object the object to get the class name from
  33009. * @param isType defines if the object is actually a type
  33010. * @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.
  33011. * @ignorenaming
  33012. */
  33013. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33014. /**
  33015. * Returns a promise that resolves after the given amount of time.
  33016. * @param delay Number of milliseconds to delay
  33017. * @returns Promise that resolves after the given amount of time
  33018. */
  33019. static DelayAsync(delay: number): Promise<void>;
  33020. }
  33021. /**
  33022. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33023. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33024. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33025. * @param name The name of the class, case should be preserved
  33026. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33027. */
  33028. export function className(name: string, module?: string): (target: Object) => void;
  33029. /**
  33030. * An implementation of a loop for asynchronous functions.
  33031. */
  33032. export class AsyncLoop {
  33033. /**
  33034. * Defines the number of iterations for the loop
  33035. */
  33036. iterations: number;
  33037. /**
  33038. * Defines the current index of the loop.
  33039. */
  33040. index: number;
  33041. private _done;
  33042. private _fn;
  33043. private _successCallback;
  33044. /**
  33045. * Constructor.
  33046. * @param iterations the number of iterations.
  33047. * @param func the function to run each iteration
  33048. * @param successCallback the callback that will be called upon succesful execution
  33049. * @param offset starting offset.
  33050. */
  33051. constructor(
  33052. /**
  33053. * Defines the number of iterations for the loop
  33054. */
  33055. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33056. /**
  33057. * Execute the next iteration. Must be called after the last iteration was finished.
  33058. */
  33059. executeNext(): void;
  33060. /**
  33061. * Break the loop and run the success callback.
  33062. */
  33063. breakLoop(): void;
  33064. /**
  33065. * Create and run an async loop.
  33066. * @param iterations the number of iterations.
  33067. * @param fn the function to run each iteration
  33068. * @param successCallback the callback that will be called upon succesful execution
  33069. * @param offset starting offset.
  33070. * @returns the created async loop object
  33071. */
  33072. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33073. /**
  33074. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33075. * @param iterations total number of iterations
  33076. * @param syncedIterations number of synchronous iterations in each async iteration.
  33077. * @param fn the function to call each iteration.
  33078. * @param callback a success call back that will be called when iterating stops.
  33079. * @param breakFunction a break condition (optional)
  33080. * @param timeout timeout settings for the setTimeout function. default - 0.
  33081. * @returns the created async loop object
  33082. */
  33083. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33084. }
  33085. }
  33086. declare module "babylonjs/Collisions/collisionCoordinator" {
  33087. import { Nullable } from "babylonjs/types";
  33088. import { Scene } from "babylonjs/scene";
  33089. import { Vector3 } from "babylonjs/Maths/math.vector";
  33090. import { Collider } from "babylonjs/Collisions/collider";
  33091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33092. /** @hidden */
  33093. export interface ICollisionCoordinator {
  33094. createCollider(): Collider;
  33095. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33096. init(scene: Scene): void;
  33097. }
  33098. /** @hidden */
  33099. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33100. private _scene;
  33101. private _scaledPosition;
  33102. private _scaledVelocity;
  33103. private _finalPosition;
  33104. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33105. createCollider(): Collider;
  33106. init(scene: Scene): void;
  33107. private _collideWithWorld;
  33108. }
  33109. }
  33110. declare module "babylonjs/Inputs/scene.inputManager" {
  33111. import { Nullable } from "babylonjs/types";
  33112. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33113. import { Vector2 } from "babylonjs/Maths/math.vector";
  33114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33115. import { Scene } from "babylonjs/scene";
  33116. /**
  33117. * Class used to manage all inputs for the scene.
  33118. */
  33119. export class InputManager {
  33120. /** The distance in pixel that you have to move to prevent some events */
  33121. static DragMovementThreshold: number;
  33122. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33123. static LongPressDelay: number;
  33124. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33125. static DoubleClickDelay: number;
  33126. /** If you need to check double click without raising a single click at first click, enable this flag */
  33127. static ExclusiveDoubleClickMode: boolean;
  33128. private _wheelEventName;
  33129. private _onPointerMove;
  33130. private _onPointerDown;
  33131. private _onPointerUp;
  33132. private _initClickEvent;
  33133. private _initActionManager;
  33134. private _delayedSimpleClick;
  33135. private _delayedSimpleClickTimeout;
  33136. private _previousDelayedSimpleClickTimeout;
  33137. private _meshPickProceed;
  33138. private _previousButtonPressed;
  33139. private _currentPickResult;
  33140. private _previousPickResult;
  33141. private _totalPointersPressed;
  33142. private _doubleClickOccured;
  33143. private _pointerOverMesh;
  33144. private _pickedDownMesh;
  33145. private _pickedUpMesh;
  33146. private _pointerX;
  33147. private _pointerY;
  33148. private _unTranslatedPointerX;
  33149. private _unTranslatedPointerY;
  33150. private _startingPointerPosition;
  33151. private _previousStartingPointerPosition;
  33152. private _startingPointerTime;
  33153. private _previousStartingPointerTime;
  33154. private _pointerCaptures;
  33155. private _onKeyDown;
  33156. private _onKeyUp;
  33157. private _onCanvasFocusObserver;
  33158. private _onCanvasBlurObserver;
  33159. private _scene;
  33160. /**
  33161. * Creates a new InputManager
  33162. * @param scene defines the hosting scene
  33163. */
  33164. constructor(scene: Scene);
  33165. /**
  33166. * Gets the mesh that is currently under the pointer
  33167. */
  33168. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33169. /**
  33170. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33171. */
  33172. readonly unTranslatedPointer: Vector2;
  33173. /**
  33174. * Gets or sets the current on-screen X position of the pointer
  33175. */
  33176. pointerX: number;
  33177. /**
  33178. * Gets or sets the current on-screen Y position of the pointer
  33179. */
  33180. pointerY: number;
  33181. private _updatePointerPosition;
  33182. private _processPointerMove;
  33183. private _setRayOnPointerInfo;
  33184. private _checkPrePointerObservable;
  33185. /**
  33186. * Use this method to simulate a pointer move on a mesh
  33187. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33188. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33189. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33190. */
  33191. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33192. /**
  33193. * Use this method to simulate a pointer down on a mesh
  33194. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33195. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33196. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33197. */
  33198. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33199. private _processPointerDown;
  33200. /** @hidden */
  33201. _isPointerSwiping(): boolean;
  33202. /**
  33203. * Use this method to simulate a pointer up on a mesh
  33204. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33205. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33206. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33207. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33208. */
  33209. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33210. private _processPointerUp;
  33211. /**
  33212. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33213. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33214. * @returns true if the pointer was captured
  33215. */
  33216. isPointerCaptured(pointerId?: number): boolean;
  33217. /**
  33218. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33219. * @param attachUp defines if you want to attach events to pointerup
  33220. * @param attachDown defines if you want to attach events to pointerdown
  33221. * @param attachMove defines if you want to attach events to pointermove
  33222. */
  33223. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33224. /**
  33225. * Detaches all event handlers
  33226. */
  33227. detachControl(): void;
  33228. /**
  33229. * Force the value of meshUnderPointer
  33230. * @param mesh defines the mesh to use
  33231. */
  33232. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33233. /**
  33234. * Gets the mesh under the pointer
  33235. * @returns a Mesh or null if no mesh is under the pointer
  33236. */
  33237. getPointerOverMesh(): Nullable<AbstractMesh>;
  33238. }
  33239. }
  33240. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33241. /**
  33242. * Helper class used to generate session unique ID
  33243. */
  33244. export class UniqueIdGenerator {
  33245. private static _UniqueIdCounter;
  33246. /**
  33247. * Gets an unique (relatively to the current scene) Id
  33248. */
  33249. static readonly UniqueId: number;
  33250. }
  33251. }
  33252. declare module "babylonjs/Animations/animationGroup" {
  33253. import { Animatable } from "babylonjs/Animations/animatable";
  33254. import { Animation } from "babylonjs/Animations/animation";
  33255. import { Scene, IDisposable } from "babylonjs/scene";
  33256. import { Observable } from "babylonjs/Misc/observable";
  33257. import { Nullable } from "babylonjs/types";
  33258. import "babylonjs/Animations/animatable";
  33259. /**
  33260. * This class defines the direct association between an animation and a target
  33261. */
  33262. export class TargetedAnimation {
  33263. /**
  33264. * Animation to perform
  33265. */
  33266. animation: Animation;
  33267. /**
  33268. * Target to animate
  33269. */
  33270. target: any;
  33271. /**
  33272. * Serialize the object
  33273. * @returns the JSON object representing the current entity
  33274. */
  33275. serialize(): any;
  33276. }
  33277. /**
  33278. * Use this class to create coordinated animations on multiple targets
  33279. */
  33280. export class AnimationGroup implements IDisposable {
  33281. /** The name of the animation group */
  33282. name: string;
  33283. private _scene;
  33284. private _targetedAnimations;
  33285. private _animatables;
  33286. private _from;
  33287. private _to;
  33288. private _isStarted;
  33289. private _isPaused;
  33290. private _speedRatio;
  33291. private _loopAnimation;
  33292. /**
  33293. * Gets or sets the unique id of the node
  33294. */
  33295. uniqueId: number;
  33296. /**
  33297. * This observable will notify when one animation have ended
  33298. */
  33299. onAnimationEndObservable: Observable<TargetedAnimation>;
  33300. /**
  33301. * Observer raised when one animation loops
  33302. */
  33303. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33304. /**
  33305. * This observable will notify when all animations have ended.
  33306. */
  33307. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33308. /**
  33309. * This observable will notify when all animations have paused.
  33310. */
  33311. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33312. /**
  33313. * This observable will notify when all animations are playing.
  33314. */
  33315. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33316. /**
  33317. * Gets the first frame
  33318. */
  33319. readonly from: number;
  33320. /**
  33321. * Gets the last frame
  33322. */
  33323. readonly to: number;
  33324. /**
  33325. * Define if the animations are started
  33326. */
  33327. readonly isStarted: boolean;
  33328. /**
  33329. * Gets a value indicating that the current group is playing
  33330. */
  33331. readonly isPlaying: boolean;
  33332. /**
  33333. * Gets or sets the speed ratio to use for all animations
  33334. */
  33335. /**
  33336. * Gets or sets the speed ratio to use for all animations
  33337. */
  33338. speedRatio: number;
  33339. /**
  33340. * Gets or sets if all animations should loop or not
  33341. */
  33342. loopAnimation: boolean;
  33343. /**
  33344. * Gets the targeted animations for this animation group
  33345. */
  33346. readonly targetedAnimations: Array<TargetedAnimation>;
  33347. /**
  33348. * returning the list of animatables controlled by this animation group.
  33349. */
  33350. readonly animatables: Array<Animatable>;
  33351. /**
  33352. * Instantiates a new Animation Group.
  33353. * This helps managing several animations at once.
  33354. * @see http://doc.babylonjs.com/how_to/group
  33355. * @param name Defines the name of the group
  33356. * @param scene Defines the scene the group belongs to
  33357. */
  33358. constructor(
  33359. /** The name of the animation group */
  33360. name: string, scene?: Nullable<Scene>);
  33361. /**
  33362. * Add an animation (with its target) in the group
  33363. * @param animation defines the animation we want to add
  33364. * @param target defines the target of the animation
  33365. * @returns the TargetedAnimation object
  33366. */
  33367. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33368. /**
  33369. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33370. * It can add constant keys at begin or end
  33371. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33372. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33373. * @returns the animation group
  33374. */
  33375. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33376. /**
  33377. * Start all animations on given targets
  33378. * @param loop defines if animations must loop
  33379. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33380. * @param from defines the from key (optional)
  33381. * @param to defines the to key (optional)
  33382. * @returns the current animation group
  33383. */
  33384. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33385. /**
  33386. * Pause all animations
  33387. * @returns the animation group
  33388. */
  33389. pause(): AnimationGroup;
  33390. /**
  33391. * Play all animations to initial state
  33392. * This function will start() the animations if they were not started or will restart() them if they were paused
  33393. * @param loop defines if animations must loop
  33394. * @returns the animation group
  33395. */
  33396. play(loop?: boolean): AnimationGroup;
  33397. /**
  33398. * Reset all animations to initial state
  33399. * @returns the animation group
  33400. */
  33401. reset(): AnimationGroup;
  33402. /**
  33403. * Restart animations from key 0
  33404. * @returns the animation group
  33405. */
  33406. restart(): AnimationGroup;
  33407. /**
  33408. * Stop all animations
  33409. * @returns the animation group
  33410. */
  33411. stop(): AnimationGroup;
  33412. /**
  33413. * Set animation weight for all animatables
  33414. * @param weight defines the weight to use
  33415. * @return the animationGroup
  33416. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33417. */
  33418. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33419. /**
  33420. * Synchronize and normalize all animatables with a source animatable
  33421. * @param root defines the root animatable to synchronize with
  33422. * @return the animationGroup
  33423. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33424. */
  33425. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33426. /**
  33427. * Goes to a specific frame in this animation group
  33428. * @param frame the frame number to go to
  33429. * @return the animationGroup
  33430. */
  33431. goToFrame(frame: number): AnimationGroup;
  33432. /**
  33433. * Dispose all associated resources
  33434. */
  33435. dispose(): void;
  33436. private _checkAnimationGroupEnded;
  33437. /**
  33438. * Clone the current animation group and returns a copy
  33439. * @param newName defines the name of the new group
  33440. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33441. * @returns the new aniamtion group
  33442. */
  33443. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33444. /**
  33445. * Serializes the animationGroup to an object
  33446. * @returns Serialized object
  33447. */
  33448. serialize(): any;
  33449. /**
  33450. * Returns a new AnimationGroup object parsed from the source provided.
  33451. * @param parsedAnimationGroup defines the source
  33452. * @param scene defines the scene that will receive the animationGroup
  33453. * @returns a new AnimationGroup
  33454. */
  33455. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33456. /**
  33457. * Returns the string "AnimationGroup"
  33458. * @returns "AnimationGroup"
  33459. */
  33460. getClassName(): string;
  33461. /**
  33462. * Creates a detailled string about the object
  33463. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33464. * @returns a string representing the object
  33465. */
  33466. toString(fullDetails?: boolean): string;
  33467. }
  33468. }
  33469. declare module "babylonjs/scene" {
  33470. import { Nullable } from "babylonjs/types";
  33471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33472. import { Observable } from "babylonjs/Misc/observable";
  33473. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33474. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33475. import { Geometry } from "babylonjs/Meshes/geometry";
  33476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33479. import { Mesh } from "babylonjs/Meshes/mesh";
  33480. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33481. import { Bone } from "babylonjs/Bones/bone";
  33482. import { Skeleton } from "babylonjs/Bones/skeleton";
  33483. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33484. import { Camera } from "babylonjs/Cameras/camera";
  33485. import { AbstractScene } from "babylonjs/abstractScene";
  33486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33488. import { Material } from "babylonjs/Materials/material";
  33489. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33490. import { Effect } from "babylonjs/Materials/effect";
  33491. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33492. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33493. import { Light } from "babylonjs/Lights/light";
  33494. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33495. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33496. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33497. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33498. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33499. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33500. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33501. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33502. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33503. import { Engine } from "babylonjs/Engines/engine";
  33504. import { Node } from "babylonjs/node";
  33505. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33506. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33507. import { WebRequest } from "babylonjs/Misc/webRequest";
  33508. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33509. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33510. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33511. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33512. import { Plane } from "babylonjs/Maths/math.plane";
  33513. import { Ray } from "babylonjs/Culling/ray";
  33514. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33515. import { Animation } from "babylonjs/Animations/animation";
  33516. import { Animatable } from "babylonjs/Animations/animatable";
  33517. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33519. import { Collider } from "babylonjs/Collisions/collider";
  33520. /**
  33521. * Define an interface for all classes that will hold resources
  33522. */
  33523. export interface IDisposable {
  33524. /**
  33525. * Releases all held resources
  33526. */
  33527. dispose(): void;
  33528. }
  33529. /** Interface defining initialization parameters for Scene class */
  33530. export interface SceneOptions {
  33531. /**
  33532. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33533. * It will improve performance when the number of geometries becomes important.
  33534. */
  33535. useGeometryUniqueIdsMap?: boolean;
  33536. /**
  33537. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33538. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33539. */
  33540. useMaterialMeshMap?: boolean;
  33541. /**
  33542. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33543. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33544. */
  33545. useClonedMeshhMap?: boolean;
  33546. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33547. virtual?: boolean;
  33548. }
  33549. /**
  33550. * Represents a scene to be rendered by the engine.
  33551. * @see http://doc.babylonjs.com/features/scene
  33552. */
  33553. export class Scene extends AbstractScene implements IAnimatable {
  33554. /** The fog is deactivated */
  33555. static readonly FOGMODE_NONE: number;
  33556. /** The fog density is following an exponential function */
  33557. static readonly FOGMODE_EXP: number;
  33558. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33559. static readonly FOGMODE_EXP2: number;
  33560. /** The fog density is following a linear function. */
  33561. static readonly FOGMODE_LINEAR: number;
  33562. /**
  33563. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33564. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33565. */
  33566. static MinDeltaTime: number;
  33567. /**
  33568. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33569. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33570. */
  33571. static MaxDeltaTime: number;
  33572. /**
  33573. * Factory used to create the default material.
  33574. * @param name The name of the material to create
  33575. * @param scene The scene to create the material for
  33576. * @returns The default material
  33577. */
  33578. static DefaultMaterialFactory(scene: Scene): Material;
  33579. /**
  33580. * Factory used to create the a collision coordinator.
  33581. * @returns The collision coordinator
  33582. */
  33583. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33584. /** @hidden */
  33585. _inputManager: InputManager;
  33586. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33587. cameraToUseForPointers: Nullable<Camera>;
  33588. /** @hidden */
  33589. readonly _isScene: boolean;
  33590. /**
  33591. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33592. */
  33593. autoClear: boolean;
  33594. /**
  33595. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33596. */
  33597. autoClearDepthAndStencil: boolean;
  33598. /**
  33599. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33600. */
  33601. clearColor: Color4;
  33602. /**
  33603. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33604. */
  33605. ambientColor: Color3;
  33606. /**
  33607. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33608. * It should only be one of the following (if not the default embedded one):
  33609. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33610. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33611. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33612. * The material properties need to be setup according to the type of texture in use.
  33613. */
  33614. environmentBRDFTexture: BaseTexture;
  33615. /** @hidden */
  33616. protected _environmentTexture: Nullable<BaseTexture>;
  33617. /**
  33618. * Texture used in all pbr material as the reflection texture.
  33619. * As in the majority of the scene they are the same (exception for multi room and so on),
  33620. * this is easier to reference from here than from all the materials.
  33621. */
  33622. /**
  33623. * Texture used in all pbr material as the reflection texture.
  33624. * As in the majority of the scene they are the same (exception for multi room and so on),
  33625. * this is easier to set here than in all the materials.
  33626. */
  33627. environmentTexture: Nullable<BaseTexture>;
  33628. /** @hidden */
  33629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33630. /**
  33631. * Default image processing configuration used either in the rendering
  33632. * Forward main pass or through the imageProcessingPostProcess if present.
  33633. * As in the majority of the scene they are the same (exception for multi camera),
  33634. * this is easier to reference from here than from all the materials and post process.
  33635. *
  33636. * No setter as we it is a shared configuration, you can set the values instead.
  33637. */
  33638. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33639. private _forceWireframe;
  33640. /**
  33641. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33642. */
  33643. forceWireframe: boolean;
  33644. private _forcePointsCloud;
  33645. /**
  33646. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33647. */
  33648. forcePointsCloud: boolean;
  33649. /**
  33650. * Gets or sets the active clipplane 1
  33651. */
  33652. clipPlane: Nullable<Plane>;
  33653. /**
  33654. * Gets or sets the active clipplane 2
  33655. */
  33656. clipPlane2: Nullable<Plane>;
  33657. /**
  33658. * Gets or sets the active clipplane 3
  33659. */
  33660. clipPlane3: Nullable<Plane>;
  33661. /**
  33662. * Gets or sets the active clipplane 4
  33663. */
  33664. clipPlane4: Nullable<Plane>;
  33665. /**
  33666. * Gets or sets a boolean indicating if animations are enabled
  33667. */
  33668. animationsEnabled: boolean;
  33669. private _animationPropertiesOverride;
  33670. /**
  33671. * Gets or sets the animation properties override
  33672. */
  33673. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33674. /**
  33675. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33676. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33677. */
  33678. useConstantAnimationDeltaTime: boolean;
  33679. /**
  33680. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33681. * Please note that it requires to run a ray cast through the scene on every frame
  33682. */
  33683. constantlyUpdateMeshUnderPointer: boolean;
  33684. /**
  33685. * Defines the HTML cursor to use when hovering over interactive elements
  33686. */
  33687. hoverCursor: string;
  33688. /**
  33689. * Defines the HTML default cursor to use (empty by default)
  33690. */
  33691. defaultCursor: string;
  33692. /**
  33693. * This is used to call preventDefault() on pointer down
  33694. * in order to block unwanted artifacts like system double clicks
  33695. */
  33696. preventDefaultOnPointerDown: boolean;
  33697. /**
  33698. * This is used to call preventDefault() on pointer up
  33699. * in order to block unwanted artifacts like system double clicks
  33700. */
  33701. preventDefaultOnPointerUp: boolean;
  33702. /**
  33703. * Gets or sets user defined metadata
  33704. */
  33705. metadata: any;
  33706. /**
  33707. * For internal use only. Please do not use.
  33708. */
  33709. reservedDataStore: any;
  33710. /**
  33711. * Gets the name of the plugin used to load this scene (null by default)
  33712. */
  33713. loadingPluginName: string;
  33714. /**
  33715. * Use this array to add regular expressions used to disable offline support for specific urls
  33716. */
  33717. disableOfflineSupportExceptionRules: RegExp[];
  33718. /**
  33719. * An event triggered when the scene is disposed.
  33720. */
  33721. onDisposeObservable: Observable<Scene>;
  33722. private _onDisposeObserver;
  33723. /** Sets a function to be executed when this scene is disposed. */
  33724. onDispose: () => void;
  33725. /**
  33726. * An event triggered before rendering the scene (right after animations and physics)
  33727. */
  33728. onBeforeRenderObservable: Observable<Scene>;
  33729. private _onBeforeRenderObserver;
  33730. /** Sets a function to be executed before rendering this scene */
  33731. beforeRender: Nullable<() => void>;
  33732. /**
  33733. * An event triggered after rendering the scene
  33734. */
  33735. onAfterRenderObservable: Observable<Scene>;
  33736. /**
  33737. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33738. */
  33739. onAfterRenderCameraObservable: Observable<Camera>;
  33740. private _onAfterRenderObserver;
  33741. /** Sets a function to be executed after rendering this scene */
  33742. afterRender: Nullable<() => void>;
  33743. /**
  33744. * An event triggered before animating the scene
  33745. */
  33746. onBeforeAnimationsObservable: Observable<Scene>;
  33747. /**
  33748. * An event triggered after animations processing
  33749. */
  33750. onAfterAnimationsObservable: Observable<Scene>;
  33751. /**
  33752. * An event triggered before draw calls are ready to be sent
  33753. */
  33754. onBeforeDrawPhaseObservable: Observable<Scene>;
  33755. /**
  33756. * An event triggered after draw calls have been sent
  33757. */
  33758. onAfterDrawPhaseObservable: Observable<Scene>;
  33759. /**
  33760. * An event triggered when the scene is ready
  33761. */
  33762. onReadyObservable: Observable<Scene>;
  33763. /**
  33764. * An event triggered before rendering a camera
  33765. */
  33766. onBeforeCameraRenderObservable: Observable<Camera>;
  33767. private _onBeforeCameraRenderObserver;
  33768. /** Sets a function to be executed before rendering a camera*/
  33769. beforeCameraRender: () => void;
  33770. /**
  33771. * An event triggered after rendering a camera
  33772. */
  33773. onAfterCameraRenderObservable: Observable<Camera>;
  33774. private _onAfterCameraRenderObserver;
  33775. /** Sets a function to be executed after rendering a camera*/
  33776. afterCameraRender: () => void;
  33777. /**
  33778. * An event triggered when active meshes evaluation is about to start
  33779. */
  33780. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33781. /**
  33782. * An event triggered when active meshes evaluation is done
  33783. */
  33784. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33785. /**
  33786. * An event triggered when particles rendering is about to start
  33787. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33788. */
  33789. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33790. /**
  33791. * An event triggered when particles rendering is done
  33792. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33793. */
  33794. onAfterParticlesRenderingObservable: Observable<Scene>;
  33795. /**
  33796. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33797. */
  33798. onDataLoadedObservable: Observable<Scene>;
  33799. /**
  33800. * An event triggered when a camera is created
  33801. */
  33802. onNewCameraAddedObservable: Observable<Camera>;
  33803. /**
  33804. * An event triggered when a camera is removed
  33805. */
  33806. onCameraRemovedObservable: Observable<Camera>;
  33807. /**
  33808. * An event triggered when a light is created
  33809. */
  33810. onNewLightAddedObservable: Observable<Light>;
  33811. /**
  33812. * An event triggered when a light is removed
  33813. */
  33814. onLightRemovedObservable: Observable<Light>;
  33815. /**
  33816. * An event triggered when a geometry is created
  33817. */
  33818. onNewGeometryAddedObservable: Observable<Geometry>;
  33819. /**
  33820. * An event triggered when a geometry is removed
  33821. */
  33822. onGeometryRemovedObservable: Observable<Geometry>;
  33823. /**
  33824. * An event triggered when a transform node is created
  33825. */
  33826. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33827. /**
  33828. * An event triggered when a transform node is removed
  33829. */
  33830. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33831. /**
  33832. * An event triggered when a mesh is created
  33833. */
  33834. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33835. /**
  33836. * An event triggered when a mesh is removed
  33837. */
  33838. onMeshRemovedObservable: Observable<AbstractMesh>;
  33839. /**
  33840. * An event triggered when a skeleton is created
  33841. */
  33842. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33843. /**
  33844. * An event triggered when a skeleton is removed
  33845. */
  33846. onSkeletonRemovedObservable: Observable<Skeleton>;
  33847. /**
  33848. * An event triggered when a material is created
  33849. */
  33850. onNewMaterialAddedObservable: Observable<Material>;
  33851. /**
  33852. * An event triggered when a material is removed
  33853. */
  33854. onMaterialRemovedObservable: Observable<Material>;
  33855. /**
  33856. * An event triggered when a texture is created
  33857. */
  33858. onNewTextureAddedObservable: Observable<BaseTexture>;
  33859. /**
  33860. * An event triggered when a texture is removed
  33861. */
  33862. onTextureRemovedObservable: Observable<BaseTexture>;
  33863. /**
  33864. * An event triggered when render targets are about to be rendered
  33865. * Can happen multiple times per frame.
  33866. */
  33867. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33868. /**
  33869. * An event triggered when render targets were rendered.
  33870. * Can happen multiple times per frame.
  33871. */
  33872. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33873. /**
  33874. * An event triggered before calculating deterministic simulation step
  33875. */
  33876. onBeforeStepObservable: Observable<Scene>;
  33877. /**
  33878. * An event triggered after calculating deterministic simulation step
  33879. */
  33880. onAfterStepObservable: Observable<Scene>;
  33881. /**
  33882. * An event triggered when the activeCamera property is updated
  33883. */
  33884. onActiveCameraChanged: Observable<Scene>;
  33885. /**
  33886. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33887. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33888. * 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)
  33889. */
  33890. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33891. /**
  33892. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33893. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33894. * 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)
  33895. */
  33896. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33897. /**
  33898. * This Observable will when a mesh has been imported into the scene.
  33899. */
  33900. onMeshImportedObservable: Observable<AbstractMesh>;
  33901. /**
  33902. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33903. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33904. */
  33905. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33906. /** @hidden */
  33907. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33908. /**
  33909. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33910. */
  33911. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33912. /**
  33913. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33914. */
  33915. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33916. /**
  33917. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33918. */
  33919. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33920. /** Callback called when a pointer move is detected */
  33921. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33922. /** Callback called when a pointer down is detected */
  33923. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33924. /** Callback called when a pointer up is detected */
  33925. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33926. /** Callback called when a pointer pick is detected */
  33927. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33928. /**
  33929. * 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).
  33930. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33931. */
  33932. onPrePointerObservable: Observable<PointerInfoPre>;
  33933. /**
  33934. * Observable event triggered each time an input event is received from the rendering canvas
  33935. */
  33936. onPointerObservable: Observable<PointerInfo>;
  33937. /**
  33938. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33939. */
  33940. readonly unTranslatedPointer: Vector2;
  33941. /**
  33942. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33943. */
  33944. static DragMovementThreshold: number;
  33945. /**
  33946. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33947. */
  33948. static LongPressDelay: number;
  33949. /**
  33950. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33951. */
  33952. static DoubleClickDelay: number;
  33953. /** If you need to check double click without raising a single click at first click, enable this flag */
  33954. static ExclusiveDoubleClickMode: boolean;
  33955. /** @hidden */
  33956. _mirroredCameraPosition: Nullable<Vector3>;
  33957. /**
  33958. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33959. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33960. */
  33961. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33962. /**
  33963. * Observable event triggered each time an keyboard event is received from the hosting window
  33964. */
  33965. onKeyboardObservable: Observable<KeyboardInfo>;
  33966. private _useRightHandedSystem;
  33967. /**
  33968. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33969. */
  33970. useRightHandedSystem: boolean;
  33971. private _timeAccumulator;
  33972. private _currentStepId;
  33973. private _currentInternalStep;
  33974. /**
  33975. * Sets the step Id used by deterministic lock step
  33976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33977. * @param newStepId defines the step Id
  33978. */
  33979. setStepId(newStepId: number): void;
  33980. /**
  33981. * Gets the step Id used by deterministic lock step
  33982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33983. * @returns the step Id
  33984. */
  33985. getStepId(): number;
  33986. /**
  33987. * Gets the internal step used by deterministic lock step
  33988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33989. * @returns the internal step
  33990. */
  33991. getInternalStep(): number;
  33992. private _fogEnabled;
  33993. /**
  33994. * Gets or sets a boolean indicating if fog is enabled on this scene
  33995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33996. * (Default is true)
  33997. */
  33998. fogEnabled: boolean;
  33999. private _fogMode;
  34000. /**
  34001. * Gets or sets the fog mode to use
  34002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34003. * | mode | value |
  34004. * | --- | --- |
  34005. * | FOGMODE_NONE | 0 |
  34006. * | FOGMODE_EXP | 1 |
  34007. * | FOGMODE_EXP2 | 2 |
  34008. * | FOGMODE_LINEAR | 3 |
  34009. */
  34010. fogMode: number;
  34011. /**
  34012. * Gets or sets the fog color to use
  34013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34014. * (Default is Color3(0.2, 0.2, 0.3))
  34015. */
  34016. fogColor: Color3;
  34017. /**
  34018. * Gets or sets the fog density to use
  34019. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34020. * (Default is 0.1)
  34021. */
  34022. fogDensity: number;
  34023. /**
  34024. * Gets or sets the fog start distance to use
  34025. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34026. * (Default is 0)
  34027. */
  34028. fogStart: number;
  34029. /**
  34030. * Gets or sets the fog end distance to use
  34031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34032. * (Default is 1000)
  34033. */
  34034. fogEnd: number;
  34035. private _shadowsEnabled;
  34036. /**
  34037. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34038. */
  34039. shadowsEnabled: boolean;
  34040. private _lightsEnabled;
  34041. /**
  34042. * Gets or sets a boolean indicating if lights are enabled on this scene
  34043. */
  34044. lightsEnabled: boolean;
  34045. /** All of the active cameras added to this scene. */
  34046. activeCameras: Camera[];
  34047. /** @hidden */
  34048. _activeCamera: Nullable<Camera>;
  34049. /** Gets or sets the current active camera */
  34050. activeCamera: Nullable<Camera>;
  34051. private _defaultMaterial;
  34052. /** The default material used on meshes when no material is affected */
  34053. /** The default material used on meshes when no material is affected */
  34054. defaultMaterial: Material;
  34055. private _texturesEnabled;
  34056. /**
  34057. * Gets or sets a boolean indicating if textures are enabled on this scene
  34058. */
  34059. texturesEnabled: boolean;
  34060. /**
  34061. * Gets or sets a boolean indicating if particles are enabled on this scene
  34062. */
  34063. particlesEnabled: boolean;
  34064. /**
  34065. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34066. */
  34067. spritesEnabled: boolean;
  34068. private _skeletonsEnabled;
  34069. /**
  34070. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34071. */
  34072. skeletonsEnabled: boolean;
  34073. /**
  34074. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34075. */
  34076. lensFlaresEnabled: boolean;
  34077. /**
  34078. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34079. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34080. */
  34081. collisionsEnabled: boolean;
  34082. private _collisionCoordinator;
  34083. /** @hidden */
  34084. readonly collisionCoordinator: ICollisionCoordinator;
  34085. /**
  34086. * Defines the gravity applied to this scene (used only for collisions)
  34087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34088. */
  34089. gravity: Vector3;
  34090. /**
  34091. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34092. */
  34093. postProcessesEnabled: boolean;
  34094. /**
  34095. * The list of postprocesses added to the scene
  34096. */
  34097. postProcesses: PostProcess[];
  34098. /**
  34099. * Gets the current postprocess manager
  34100. */
  34101. postProcessManager: PostProcessManager;
  34102. /**
  34103. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34104. */
  34105. renderTargetsEnabled: boolean;
  34106. /**
  34107. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34108. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34109. */
  34110. dumpNextRenderTargets: boolean;
  34111. /**
  34112. * The list of user defined render targets added to the scene
  34113. */
  34114. customRenderTargets: RenderTargetTexture[];
  34115. /**
  34116. * Defines if texture loading must be delayed
  34117. * If true, textures will only be loaded when they need to be rendered
  34118. */
  34119. useDelayedTextureLoading: boolean;
  34120. /**
  34121. * Gets the list of meshes imported to the scene through SceneLoader
  34122. */
  34123. importedMeshesFiles: String[];
  34124. /**
  34125. * Gets or sets a boolean indicating if probes are enabled on this scene
  34126. */
  34127. probesEnabled: boolean;
  34128. /**
  34129. * Gets or sets the current offline provider to use to store scene data
  34130. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34131. */
  34132. offlineProvider: IOfflineProvider;
  34133. /**
  34134. * Gets or sets the action manager associated with the scene
  34135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34136. */
  34137. actionManager: AbstractActionManager;
  34138. private _meshesForIntersections;
  34139. /**
  34140. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34141. */
  34142. proceduralTexturesEnabled: boolean;
  34143. private _engine;
  34144. private _totalVertices;
  34145. /** @hidden */
  34146. _activeIndices: PerfCounter;
  34147. /** @hidden */
  34148. _activeParticles: PerfCounter;
  34149. /** @hidden */
  34150. _activeBones: PerfCounter;
  34151. private _animationRatio;
  34152. /** @hidden */
  34153. _animationTimeLast: number;
  34154. /** @hidden */
  34155. _animationTime: number;
  34156. /**
  34157. * Gets or sets a general scale for animation speed
  34158. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34159. */
  34160. animationTimeScale: number;
  34161. /** @hidden */
  34162. _cachedMaterial: Nullable<Material>;
  34163. /** @hidden */
  34164. _cachedEffect: Nullable<Effect>;
  34165. /** @hidden */
  34166. _cachedVisibility: Nullable<number>;
  34167. private _renderId;
  34168. private _frameId;
  34169. private _executeWhenReadyTimeoutId;
  34170. private _intermediateRendering;
  34171. private _viewUpdateFlag;
  34172. private _projectionUpdateFlag;
  34173. /** @hidden */
  34174. _toBeDisposed: Nullable<IDisposable>[];
  34175. private _activeRequests;
  34176. /** @hidden */
  34177. _pendingData: any[];
  34178. private _isDisposed;
  34179. /**
  34180. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34181. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34182. */
  34183. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34184. private _activeMeshes;
  34185. private _processedMaterials;
  34186. private _renderTargets;
  34187. /** @hidden */
  34188. _activeParticleSystems: SmartArray<IParticleSystem>;
  34189. private _activeSkeletons;
  34190. private _softwareSkinnedMeshes;
  34191. private _renderingManager;
  34192. /** @hidden */
  34193. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34194. private _transformMatrix;
  34195. private _sceneUbo;
  34196. /** @hidden */
  34197. _viewMatrix: Matrix;
  34198. private _projectionMatrix;
  34199. /** @hidden */
  34200. _forcedViewPosition: Nullable<Vector3>;
  34201. /** @hidden */
  34202. _frustumPlanes: Plane[];
  34203. /**
  34204. * Gets the list of frustum planes (built from the active camera)
  34205. */
  34206. readonly frustumPlanes: Plane[];
  34207. /**
  34208. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34209. * This is useful if there are more lights that the maximum simulteanous authorized
  34210. */
  34211. requireLightSorting: boolean;
  34212. /** @hidden */
  34213. readonly useMaterialMeshMap: boolean;
  34214. /** @hidden */
  34215. readonly useClonedMeshhMap: boolean;
  34216. private _externalData;
  34217. private _uid;
  34218. /**
  34219. * @hidden
  34220. * Backing store of defined scene components.
  34221. */
  34222. _components: ISceneComponent[];
  34223. /**
  34224. * @hidden
  34225. * Backing store of defined scene components.
  34226. */
  34227. _serializableComponents: ISceneSerializableComponent[];
  34228. /**
  34229. * List of components to register on the next registration step.
  34230. */
  34231. private _transientComponents;
  34232. /**
  34233. * Registers the transient components if needed.
  34234. */
  34235. private _registerTransientComponents;
  34236. /**
  34237. * @hidden
  34238. * Add a component to the scene.
  34239. * Note that the ccomponent could be registered on th next frame if this is called after
  34240. * the register component stage.
  34241. * @param component Defines the component to add to the scene
  34242. */
  34243. _addComponent(component: ISceneComponent): void;
  34244. /**
  34245. * @hidden
  34246. * Gets a component from the scene.
  34247. * @param name defines the name of the component to retrieve
  34248. * @returns the component or null if not present
  34249. */
  34250. _getComponent(name: string): Nullable<ISceneComponent>;
  34251. /**
  34252. * @hidden
  34253. * Defines the actions happening before camera updates.
  34254. */
  34255. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34256. /**
  34257. * @hidden
  34258. * Defines the actions happening before clear the canvas.
  34259. */
  34260. _beforeClearStage: Stage<SimpleStageAction>;
  34261. /**
  34262. * @hidden
  34263. * Defines the actions when collecting render targets for the frame.
  34264. */
  34265. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34266. /**
  34267. * @hidden
  34268. * Defines the actions happening for one camera in the frame.
  34269. */
  34270. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34271. /**
  34272. * @hidden
  34273. * Defines the actions happening during the per mesh ready checks.
  34274. */
  34275. _isReadyForMeshStage: Stage<MeshStageAction>;
  34276. /**
  34277. * @hidden
  34278. * Defines the actions happening before evaluate active mesh checks.
  34279. */
  34280. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34281. /**
  34282. * @hidden
  34283. * Defines the actions happening during the evaluate sub mesh checks.
  34284. */
  34285. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34286. /**
  34287. * @hidden
  34288. * Defines the actions happening during the active mesh stage.
  34289. */
  34290. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34291. /**
  34292. * @hidden
  34293. * Defines the actions happening during the per camera render target step.
  34294. */
  34295. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34296. /**
  34297. * @hidden
  34298. * Defines the actions happening just before the active camera is drawing.
  34299. */
  34300. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34301. /**
  34302. * @hidden
  34303. * Defines the actions happening just before a render target is drawing.
  34304. */
  34305. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34306. /**
  34307. * @hidden
  34308. * Defines the actions happening just before a rendering group is drawing.
  34309. */
  34310. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34311. /**
  34312. * @hidden
  34313. * Defines the actions happening just before a mesh is drawing.
  34314. */
  34315. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34316. /**
  34317. * @hidden
  34318. * Defines the actions happening just after a mesh has been drawn.
  34319. */
  34320. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34321. /**
  34322. * @hidden
  34323. * Defines the actions happening just after a rendering group has been drawn.
  34324. */
  34325. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34326. /**
  34327. * @hidden
  34328. * Defines the actions happening just after the active camera has been drawn.
  34329. */
  34330. _afterCameraDrawStage: Stage<CameraStageAction>;
  34331. /**
  34332. * @hidden
  34333. * Defines the actions happening just after a render target has been drawn.
  34334. */
  34335. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34336. /**
  34337. * @hidden
  34338. * Defines the actions happening just after rendering all cameras and computing intersections.
  34339. */
  34340. _afterRenderStage: Stage<SimpleStageAction>;
  34341. /**
  34342. * @hidden
  34343. * Defines the actions happening when a pointer move event happens.
  34344. */
  34345. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34346. /**
  34347. * @hidden
  34348. * Defines the actions happening when a pointer down event happens.
  34349. */
  34350. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34351. /**
  34352. * @hidden
  34353. * Defines the actions happening when a pointer up event happens.
  34354. */
  34355. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34356. /**
  34357. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34358. */
  34359. private geometriesByUniqueId;
  34360. /**
  34361. * Creates a new Scene
  34362. * @param engine defines the engine to use to render this scene
  34363. * @param options defines the scene options
  34364. */
  34365. constructor(engine: Engine, options?: SceneOptions);
  34366. /**
  34367. * Gets a string idenfifying the name of the class
  34368. * @returns "Scene" string
  34369. */
  34370. getClassName(): string;
  34371. private _defaultMeshCandidates;
  34372. /**
  34373. * @hidden
  34374. */
  34375. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34376. private _defaultSubMeshCandidates;
  34377. /**
  34378. * @hidden
  34379. */
  34380. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34381. /**
  34382. * Sets the default candidate providers for the scene.
  34383. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34384. * and getCollidingSubMeshCandidates to their default function
  34385. */
  34386. setDefaultCandidateProviders(): void;
  34387. /**
  34388. * Gets the mesh that is currently under the pointer
  34389. */
  34390. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34391. /**
  34392. * Gets or sets the current on-screen X position of the pointer
  34393. */
  34394. pointerX: number;
  34395. /**
  34396. * Gets or sets the current on-screen Y position of the pointer
  34397. */
  34398. pointerY: number;
  34399. /**
  34400. * Gets the cached material (ie. the latest rendered one)
  34401. * @returns the cached material
  34402. */
  34403. getCachedMaterial(): Nullable<Material>;
  34404. /**
  34405. * Gets the cached effect (ie. the latest rendered one)
  34406. * @returns the cached effect
  34407. */
  34408. getCachedEffect(): Nullable<Effect>;
  34409. /**
  34410. * Gets the cached visibility state (ie. the latest rendered one)
  34411. * @returns the cached visibility state
  34412. */
  34413. getCachedVisibility(): Nullable<number>;
  34414. /**
  34415. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34416. * @param material defines the current material
  34417. * @param effect defines the current effect
  34418. * @param visibility defines the current visibility state
  34419. * @returns true if one parameter is not cached
  34420. */
  34421. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34422. /**
  34423. * Gets the engine associated with the scene
  34424. * @returns an Engine
  34425. */
  34426. getEngine(): Engine;
  34427. /**
  34428. * Gets the total number of vertices rendered per frame
  34429. * @returns the total number of vertices rendered per frame
  34430. */
  34431. getTotalVertices(): number;
  34432. /**
  34433. * Gets the performance counter for total vertices
  34434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34435. */
  34436. readonly totalVerticesPerfCounter: PerfCounter;
  34437. /**
  34438. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34439. * @returns the total number of active indices rendered per frame
  34440. */
  34441. getActiveIndices(): number;
  34442. /**
  34443. * Gets the performance counter for active indices
  34444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34445. */
  34446. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34447. /**
  34448. * Gets the total number of active particles rendered per frame
  34449. * @returns the total number of active particles rendered per frame
  34450. */
  34451. getActiveParticles(): number;
  34452. /**
  34453. * Gets the performance counter for active particles
  34454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34455. */
  34456. readonly activeParticlesPerfCounter: PerfCounter;
  34457. /**
  34458. * Gets the total number of active bones rendered per frame
  34459. * @returns the total number of active bones rendered per frame
  34460. */
  34461. getActiveBones(): number;
  34462. /**
  34463. * Gets the performance counter for active bones
  34464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34465. */
  34466. readonly activeBonesPerfCounter: PerfCounter;
  34467. /**
  34468. * Gets the array of active meshes
  34469. * @returns an array of AbstractMesh
  34470. */
  34471. getActiveMeshes(): SmartArray<AbstractMesh>;
  34472. /**
  34473. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34474. * @returns a number
  34475. */
  34476. getAnimationRatio(): number;
  34477. /**
  34478. * Gets an unique Id for the current render phase
  34479. * @returns a number
  34480. */
  34481. getRenderId(): number;
  34482. /**
  34483. * Gets an unique Id for the current frame
  34484. * @returns a number
  34485. */
  34486. getFrameId(): number;
  34487. /** Call this function if you want to manually increment the render Id*/
  34488. incrementRenderId(): void;
  34489. private _createUbo;
  34490. /**
  34491. * Use this method to simulate a pointer move on a mesh
  34492. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34493. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34494. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34495. * @returns the current scene
  34496. */
  34497. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34498. /**
  34499. * Use this method to simulate a pointer down on a mesh
  34500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34503. * @returns the current scene
  34504. */
  34505. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34506. /**
  34507. * Use this method to simulate a pointer up on a mesh
  34508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34511. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34512. * @returns the current scene
  34513. */
  34514. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34515. /**
  34516. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34517. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34518. * @returns true if the pointer was captured
  34519. */
  34520. isPointerCaptured(pointerId?: number): boolean;
  34521. /**
  34522. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34523. * @param attachUp defines if you want to attach events to pointerup
  34524. * @param attachDown defines if you want to attach events to pointerdown
  34525. * @param attachMove defines if you want to attach events to pointermove
  34526. */
  34527. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34528. /** Detaches all event handlers*/
  34529. detachControl(): void;
  34530. /**
  34531. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34532. * Delay loaded resources are not taking in account
  34533. * @return true if all required resources are ready
  34534. */
  34535. isReady(): boolean;
  34536. /** Resets all cached information relative to material (including effect and visibility) */
  34537. resetCachedMaterial(): void;
  34538. /**
  34539. * Registers a function to be called before every frame render
  34540. * @param func defines the function to register
  34541. */
  34542. registerBeforeRender(func: () => void): void;
  34543. /**
  34544. * Unregisters a function called before every frame render
  34545. * @param func defines the function to unregister
  34546. */
  34547. unregisterBeforeRender(func: () => void): void;
  34548. /**
  34549. * Registers a function to be called after every frame render
  34550. * @param func defines the function to register
  34551. */
  34552. registerAfterRender(func: () => void): void;
  34553. /**
  34554. * Unregisters a function called after every frame render
  34555. * @param func defines the function to unregister
  34556. */
  34557. unregisterAfterRender(func: () => void): void;
  34558. private _executeOnceBeforeRender;
  34559. /**
  34560. * The provided function will run before render once and will be disposed afterwards.
  34561. * A timeout delay can be provided so that the function will be executed in N ms.
  34562. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34563. * @param func The function to be executed.
  34564. * @param timeout optional delay in ms
  34565. */
  34566. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34567. /** @hidden */
  34568. _addPendingData(data: any): void;
  34569. /** @hidden */
  34570. _removePendingData(data: any): void;
  34571. /**
  34572. * Returns the number of items waiting to be loaded
  34573. * @returns the number of items waiting to be loaded
  34574. */
  34575. getWaitingItemsCount(): number;
  34576. /**
  34577. * Returns a boolean indicating if the scene is still loading data
  34578. */
  34579. readonly isLoading: boolean;
  34580. /**
  34581. * Registers a function to be executed when the scene is ready
  34582. * @param {Function} func - the function to be executed
  34583. */
  34584. executeWhenReady(func: () => void): void;
  34585. /**
  34586. * Returns a promise that resolves when the scene is ready
  34587. * @returns A promise that resolves when the scene is ready
  34588. */
  34589. whenReadyAsync(): Promise<void>;
  34590. /** @hidden */
  34591. _checkIsReady(): void;
  34592. /**
  34593. * Gets all animatable attached to the scene
  34594. */
  34595. readonly animatables: Animatable[];
  34596. /**
  34597. * Resets the last animation time frame.
  34598. * Useful to override when animations start running when loading a scene for the first time.
  34599. */
  34600. resetLastAnimationTimeFrame(): void;
  34601. /**
  34602. * Gets the current view matrix
  34603. * @returns a Matrix
  34604. */
  34605. getViewMatrix(): Matrix;
  34606. /**
  34607. * Gets the current projection matrix
  34608. * @returns a Matrix
  34609. */
  34610. getProjectionMatrix(): Matrix;
  34611. /**
  34612. * Gets the current transform matrix
  34613. * @returns a Matrix made of View * Projection
  34614. */
  34615. getTransformMatrix(): Matrix;
  34616. /**
  34617. * Sets the current transform matrix
  34618. * @param viewL defines the View matrix to use
  34619. * @param projectionL defines the Projection matrix to use
  34620. * @param viewR defines the right View matrix to use (if provided)
  34621. * @param projectionR defines the right Projection matrix to use (if provided)
  34622. */
  34623. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34624. /**
  34625. * Gets the uniform buffer used to store scene data
  34626. * @returns a UniformBuffer
  34627. */
  34628. getSceneUniformBuffer(): UniformBuffer;
  34629. /**
  34630. * Gets an unique (relatively to the current scene) Id
  34631. * @returns an unique number for the scene
  34632. */
  34633. getUniqueId(): number;
  34634. /**
  34635. * Add a mesh to the list of scene's meshes
  34636. * @param newMesh defines the mesh to add
  34637. * @param recursive if all child meshes should also be added to the scene
  34638. */
  34639. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34640. /**
  34641. * Remove a mesh for the list of scene's meshes
  34642. * @param toRemove defines the mesh to remove
  34643. * @param recursive if all child meshes should also be removed from the scene
  34644. * @returns the index where the mesh was in the mesh list
  34645. */
  34646. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34647. /**
  34648. * Add a transform node to the list of scene's transform nodes
  34649. * @param newTransformNode defines the transform node to add
  34650. */
  34651. addTransformNode(newTransformNode: TransformNode): void;
  34652. /**
  34653. * Remove a transform node for the list of scene's transform nodes
  34654. * @param toRemove defines the transform node to remove
  34655. * @returns the index where the transform node was in the transform node list
  34656. */
  34657. removeTransformNode(toRemove: TransformNode): number;
  34658. /**
  34659. * Remove a skeleton for the list of scene's skeletons
  34660. * @param toRemove defines the skeleton to remove
  34661. * @returns the index where the skeleton was in the skeleton list
  34662. */
  34663. removeSkeleton(toRemove: Skeleton): number;
  34664. /**
  34665. * Remove a morph target for the list of scene's morph targets
  34666. * @param toRemove defines the morph target to remove
  34667. * @returns the index where the morph target was in the morph target list
  34668. */
  34669. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34670. /**
  34671. * Remove a light for the list of scene's lights
  34672. * @param toRemove defines the light to remove
  34673. * @returns the index where the light was in the light list
  34674. */
  34675. removeLight(toRemove: Light): number;
  34676. /**
  34677. * Remove a camera for the list of scene's cameras
  34678. * @param toRemove defines the camera to remove
  34679. * @returns the index where the camera was in the camera list
  34680. */
  34681. removeCamera(toRemove: Camera): number;
  34682. /**
  34683. * Remove a particle system for the list of scene's particle systems
  34684. * @param toRemove defines the particle system to remove
  34685. * @returns the index where the particle system was in the particle system list
  34686. */
  34687. removeParticleSystem(toRemove: IParticleSystem): number;
  34688. /**
  34689. * Remove a animation for the list of scene's animations
  34690. * @param toRemove defines the animation to remove
  34691. * @returns the index where the animation was in the animation list
  34692. */
  34693. removeAnimation(toRemove: Animation): number;
  34694. /**
  34695. * Will stop the animation of the given target
  34696. * @param target - the target
  34697. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34698. * @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)
  34699. */
  34700. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34701. /**
  34702. * Removes the given animation group from this scene.
  34703. * @param toRemove The animation group to remove
  34704. * @returns The index of the removed animation group
  34705. */
  34706. removeAnimationGroup(toRemove: AnimationGroup): number;
  34707. /**
  34708. * Removes the given multi-material from this scene.
  34709. * @param toRemove The multi-material to remove
  34710. * @returns The index of the removed multi-material
  34711. */
  34712. removeMultiMaterial(toRemove: MultiMaterial): number;
  34713. /**
  34714. * Removes the given material from this scene.
  34715. * @param toRemove The material to remove
  34716. * @returns The index of the removed material
  34717. */
  34718. removeMaterial(toRemove: Material): number;
  34719. /**
  34720. * Removes the given action manager from this scene.
  34721. * @param toRemove The action manager to remove
  34722. * @returns The index of the removed action manager
  34723. */
  34724. removeActionManager(toRemove: AbstractActionManager): number;
  34725. /**
  34726. * Removes the given texture from this scene.
  34727. * @param toRemove The texture to remove
  34728. * @returns The index of the removed texture
  34729. */
  34730. removeTexture(toRemove: BaseTexture): number;
  34731. /**
  34732. * Adds the given light to this scene
  34733. * @param newLight The light to add
  34734. */
  34735. addLight(newLight: Light): void;
  34736. /**
  34737. * Sorts the list list based on light priorities
  34738. */
  34739. sortLightsByPriority(): void;
  34740. /**
  34741. * Adds the given camera to this scene
  34742. * @param newCamera The camera to add
  34743. */
  34744. addCamera(newCamera: Camera): void;
  34745. /**
  34746. * Adds the given skeleton to this scene
  34747. * @param newSkeleton The skeleton to add
  34748. */
  34749. addSkeleton(newSkeleton: Skeleton): void;
  34750. /**
  34751. * Adds the given particle system to this scene
  34752. * @param newParticleSystem The particle system to add
  34753. */
  34754. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34755. /**
  34756. * Adds the given animation to this scene
  34757. * @param newAnimation The animation to add
  34758. */
  34759. addAnimation(newAnimation: Animation): void;
  34760. /**
  34761. * Adds the given animation group to this scene.
  34762. * @param newAnimationGroup The animation group to add
  34763. */
  34764. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34765. /**
  34766. * Adds the given multi-material to this scene
  34767. * @param newMultiMaterial The multi-material to add
  34768. */
  34769. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34770. /**
  34771. * Adds the given material to this scene
  34772. * @param newMaterial The material to add
  34773. */
  34774. addMaterial(newMaterial: Material): void;
  34775. /**
  34776. * Adds the given morph target to this scene
  34777. * @param newMorphTargetManager The morph target to add
  34778. */
  34779. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34780. /**
  34781. * Adds the given geometry to this scene
  34782. * @param newGeometry The geometry to add
  34783. */
  34784. addGeometry(newGeometry: Geometry): void;
  34785. /**
  34786. * Adds the given action manager to this scene
  34787. * @param newActionManager The action manager to add
  34788. */
  34789. addActionManager(newActionManager: AbstractActionManager): void;
  34790. /**
  34791. * Adds the given texture to this scene.
  34792. * @param newTexture The texture to add
  34793. */
  34794. addTexture(newTexture: BaseTexture): void;
  34795. /**
  34796. * Switch active camera
  34797. * @param newCamera defines the new active camera
  34798. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34799. */
  34800. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34801. /**
  34802. * sets the active camera of the scene using its ID
  34803. * @param id defines the camera's ID
  34804. * @return the new active camera or null if none found.
  34805. */
  34806. setActiveCameraByID(id: string): Nullable<Camera>;
  34807. /**
  34808. * sets the active camera of the scene using its name
  34809. * @param name defines the camera's name
  34810. * @returns the new active camera or null if none found.
  34811. */
  34812. setActiveCameraByName(name: string): Nullable<Camera>;
  34813. /**
  34814. * get an animation group using its name
  34815. * @param name defines the material's name
  34816. * @return the animation group or null if none found.
  34817. */
  34818. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34819. /**
  34820. * Get a material using its unique id
  34821. * @param uniqueId defines the material's unique id
  34822. * @return the material or null if none found.
  34823. */
  34824. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34825. /**
  34826. * get a material using its id
  34827. * @param id defines the material's ID
  34828. * @return the material or null if none found.
  34829. */
  34830. getMaterialByID(id: string): Nullable<Material>;
  34831. /**
  34832. * Gets a the last added material using a given id
  34833. * @param id defines the material's ID
  34834. * @return the last material with the given id or null if none found.
  34835. */
  34836. getLastMaterialByID(id: string): Nullable<Material>;
  34837. /**
  34838. * Gets a material using its name
  34839. * @param name defines the material's name
  34840. * @return the material or null if none found.
  34841. */
  34842. getMaterialByName(name: string): Nullable<Material>;
  34843. /**
  34844. * Get a texture using its unique id
  34845. * @param uniqueId defines the texture's unique id
  34846. * @return the texture or null if none found.
  34847. */
  34848. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34849. /**
  34850. * Gets a camera using its id
  34851. * @param id defines the id to look for
  34852. * @returns the camera or null if not found
  34853. */
  34854. getCameraByID(id: string): Nullable<Camera>;
  34855. /**
  34856. * Gets a camera using its unique id
  34857. * @param uniqueId defines the unique id to look for
  34858. * @returns the camera or null if not found
  34859. */
  34860. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34861. /**
  34862. * Gets a camera using its name
  34863. * @param name defines the camera's name
  34864. * @return the camera or null if none found.
  34865. */
  34866. getCameraByName(name: string): Nullable<Camera>;
  34867. /**
  34868. * Gets a bone using its id
  34869. * @param id defines the bone's id
  34870. * @return the bone or null if not found
  34871. */
  34872. getBoneByID(id: string): Nullable<Bone>;
  34873. /**
  34874. * Gets a bone using its id
  34875. * @param name defines the bone's name
  34876. * @return the bone or null if not found
  34877. */
  34878. getBoneByName(name: string): Nullable<Bone>;
  34879. /**
  34880. * Gets a light node using its name
  34881. * @param name defines the the light's name
  34882. * @return the light or null if none found.
  34883. */
  34884. getLightByName(name: string): Nullable<Light>;
  34885. /**
  34886. * Gets a light node using its id
  34887. * @param id defines the light's id
  34888. * @return the light or null if none found.
  34889. */
  34890. getLightByID(id: string): Nullable<Light>;
  34891. /**
  34892. * Gets a light node using its scene-generated unique ID
  34893. * @param uniqueId defines the light's unique id
  34894. * @return the light or null if none found.
  34895. */
  34896. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34897. /**
  34898. * Gets a particle system by id
  34899. * @param id defines the particle system id
  34900. * @return the corresponding system or null if none found
  34901. */
  34902. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34903. /**
  34904. * Gets a geometry using its ID
  34905. * @param id defines the geometry's id
  34906. * @return the geometry or null if none found.
  34907. */
  34908. getGeometryByID(id: string): Nullable<Geometry>;
  34909. private _getGeometryByUniqueID;
  34910. /**
  34911. * Add a new geometry to this scene
  34912. * @param geometry defines the geometry to be added to the scene.
  34913. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34914. * @return a boolean defining if the geometry was added or not
  34915. */
  34916. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34917. /**
  34918. * Removes an existing geometry
  34919. * @param geometry defines the geometry to be removed from the scene
  34920. * @return a boolean defining if the geometry was removed or not
  34921. */
  34922. removeGeometry(geometry: Geometry): boolean;
  34923. /**
  34924. * Gets the list of geometries attached to the scene
  34925. * @returns an array of Geometry
  34926. */
  34927. getGeometries(): Geometry[];
  34928. /**
  34929. * Gets the first added mesh found of a given ID
  34930. * @param id defines the id to search for
  34931. * @return the mesh found or null if not found at all
  34932. */
  34933. getMeshByID(id: string): Nullable<AbstractMesh>;
  34934. /**
  34935. * Gets a list of meshes using their id
  34936. * @param id defines the id to search for
  34937. * @returns a list of meshes
  34938. */
  34939. getMeshesByID(id: string): Array<AbstractMesh>;
  34940. /**
  34941. * Gets the first added transform node found of a given ID
  34942. * @param id defines the id to search for
  34943. * @return the found transform node or null if not found at all.
  34944. */
  34945. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34946. /**
  34947. * Gets a transform node with its auto-generated unique id
  34948. * @param uniqueId efines the unique id to search for
  34949. * @return the found transform node or null if not found at all.
  34950. */
  34951. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34952. /**
  34953. * Gets a list of transform nodes using their id
  34954. * @param id defines the id to search for
  34955. * @returns a list of transform nodes
  34956. */
  34957. getTransformNodesByID(id: string): Array<TransformNode>;
  34958. /**
  34959. * Gets a mesh with its auto-generated unique id
  34960. * @param uniqueId defines the unique id to search for
  34961. * @return the found mesh or null if not found at all.
  34962. */
  34963. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34964. /**
  34965. * Gets a the last added mesh using a given id
  34966. * @param id defines the id to search for
  34967. * @return the found mesh or null if not found at all.
  34968. */
  34969. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34970. /**
  34971. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34972. * @param id defines the id to search for
  34973. * @return the found node or null if not found at all
  34974. */
  34975. getLastEntryByID(id: string): Nullable<Node>;
  34976. /**
  34977. * Gets a node (Mesh, Camera, Light) using a given id
  34978. * @param id defines the id to search for
  34979. * @return the found node or null if not found at all
  34980. */
  34981. getNodeByID(id: string): Nullable<Node>;
  34982. /**
  34983. * Gets a node (Mesh, Camera, Light) using a given name
  34984. * @param name defines the name to search for
  34985. * @return the found node or null if not found at all.
  34986. */
  34987. getNodeByName(name: string): Nullable<Node>;
  34988. /**
  34989. * Gets a mesh using a given name
  34990. * @param name defines the name to search for
  34991. * @return the found mesh or null if not found at all.
  34992. */
  34993. getMeshByName(name: string): Nullable<AbstractMesh>;
  34994. /**
  34995. * Gets a transform node using a given name
  34996. * @param name defines the name to search for
  34997. * @return the found transform node or null if not found at all.
  34998. */
  34999. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35000. /**
  35001. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35002. * @param id defines the id to search for
  35003. * @return the found skeleton or null if not found at all.
  35004. */
  35005. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35006. /**
  35007. * Gets a skeleton using a given auto generated unique id
  35008. * @param uniqueId defines the unique id to search for
  35009. * @return the found skeleton or null if not found at all.
  35010. */
  35011. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35012. /**
  35013. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35014. * @param id defines the id to search for
  35015. * @return the found skeleton or null if not found at all.
  35016. */
  35017. getSkeletonById(id: string): Nullable<Skeleton>;
  35018. /**
  35019. * Gets a skeleton using a given name
  35020. * @param name defines the name to search for
  35021. * @return the found skeleton or null if not found at all.
  35022. */
  35023. getSkeletonByName(name: string): Nullable<Skeleton>;
  35024. /**
  35025. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35026. * @param id defines the id to search for
  35027. * @return the found morph target manager or null if not found at all.
  35028. */
  35029. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35030. /**
  35031. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35032. * @param id defines the id to search for
  35033. * @return the found morph target or null if not found at all.
  35034. */
  35035. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35036. /**
  35037. * Gets a boolean indicating if the given mesh is active
  35038. * @param mesh defines the mesh to look for
  35039. * @returns true if the mesh is in the active list
  35040. */
  35041. isActiveMesh(mesh: AbstractMesh): boolean;
  35042. /**
  35043. * Return a unique id as a string which can serve as an identifier for the scene
  35044. */
  35045. readonly uid: string;
  35046. /**
  35047. * Add an externaly attached data from its key.
  35048. * This method call will fail and return false, if such key already exists.
  35049. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35050. * @param key the unique key that identifies the data
  35051. * @param data the data object to associate to the key for this Engine instance
  35052. * @return true if no such key were already present and the data was added successfully, false otherwise
  35053. */
  35054. addExternalData<T>(key: string, data: T): boolean;
  35055. /**
  35056. * Get an externaly attached data from its key
  35057. * @param key the unique key that identifies the data
  35058. * @return the associated data, if present (can be null), or undefined if not present
  35059. */
  35060. getExternalData<T>(key: string): Nullable<T>;
  35061. /**
  35062. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35063. * @param key the unique key that identifies the data
  35064. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35065. * @return the associated data, can be null if the factory returned null.
  35066. */
  35067. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35068. /**
  35069. * Remove an externaly attached data from the Engine instance
  35070. * @param key the unique key that identifies the data
  35071. * @return true if the data was successfully removed, false if it doesn't exist
  35072. */
  35073. removeExternalData(key: string): boolean;
  35074. private _evaluateSubMesh;
  35075. /**
  35076. * Clear the processed materials smart array preventing retention point in material dispose.
  35077. */
  35078. freeProcessedMaterials(): void;
  35079. private _preventFreeActiveMeshesAndRenderingGroups;
  35080. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35081. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35082. * when disposing several meshes in a row or a hierarchy of meshes.
  35083. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35084. */
  35085. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35086. /**
  35087. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35088. */
  35089. freeActiveMeshes(): void;
  35090. /**
  35091. * Clear the info related to rendering groups preventing retention points during dispose.
  35092. */
  35093. freeRenderingGroups(): void;
  35094. /** @hidden */
  35095. _isInIntermediateRendering(): boolean;
  35096. /**
  35097. * Lambda returning the list of potentially active meshes.
  35098. */
  35099. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35100. /**
  35101. * Lambda returning the list of potentially active sub meshes.
  35102. */
  35103. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35104. /**
  35105. * Lambda returning the list of potentially intersecting sub meshes.
  35106. */
  35107. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35108. /**
  35109. * Lambda returning the list of potentially colliding sub meshes.
  35110. */
  35111. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35112. private _activeMeshesFrozen;
  35113. /**
  35114. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35115. * @returns the current scene
  35116. */
  35117. freezeActiveMeshes(): Scene;
  35118. /**
  35119. * Use this function to restart evaluating active meshes on every frame
  35120. * @returns the current scene
  35121. */
  35122. unfreezeActiveMeshes(): Scene;
  35123. private _evaluateActiveMeshes;
  35124. private _activeMesh;
  35125. /**
  35126. * Update the transform matrix to update from the current active camera
  35127. * @param force defines a boolean used to force the update even if cache is up to date
  35128. */
  35129. updateTransformMatrix(force?: boolean): void;
  35130. private _bindFrameBuffer;
  35131. /** @hidden */
  35132. _allowPostProcessClearColor: boolean;
  35133. /** @hidden */
  35134. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35135. private _processSubCameras;
  35136. private _checkIntersections;
  35137. /** @hidden */
  35138. _advancePhysicsEngineStep(step: number): void;
  35139. /**
  35140. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35141. */
  35142. getDeterministicFrameTime: () => number;
  35143. /** @hidden */
  35144. _animate(): void;
  35145. /** Execute all animations (for a frame) */
  35146. animate(): void;
  35147. /**
  35148. * Render the scene
  35149. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35150. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35151. */
  35152. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35153. /**
  35154. * Freeze all materials
  35155. * A frozen material will not be updatable but should be faster to render
  35156. */
  35157. freezeMaterials(): void;
  35158. /**
  35159. * Unfreeze all materials
  35160. * A frozen material will not be updatable but should be faster to render
  35161. */
  35162. unfreezeMaterials(): void;
  35163. /**
  35164. * Releases all held ressources
  35165. */
  35166. dispose(): void;
  35167. /**
  35168. * Gets if the scene is already disposed
  35169. */
  35170. readonly isDisposed: boolean;
  35171. /**
  35172. * Call this function to reduce memory footprint of the scene.
  35173. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35174. */
  35175. clearCachedVertexData(): void;
  35176. /**
  35177. * This function will remove the local cached buffer data from texture.
  35178. * It will save memory but will prevent the texture from being rebuilt
  35179. */
  35180. cleanCachedTextureBuffer(): void;
  35181. /**
  35182. * Get the world extend vectors with an optional filter
  35183. *
  35184. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35185. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35186. */
  35187. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35188. min: Vector3;
  35189. max: Vector3;
  35190. };
  35191. /**
  35192. * Creates a ray that can be used to pick in the scene
  35193. * @param x defines the x coordinate of the origin (on-screen)
  35194. * @param y defines the y coordinate of the origin (on-screen)
  35195. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35196. * @param camera defines the camera to use for the picking
  35197. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35198. * @returns a Ray
  35199. */
  35200. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35201. /**
  35202. * Creates a ray that can be used to pick in the scene
  35203. * @param x defines the x coordinate of the origin (on-screen)
  35204. * @param y defines the y coordinate of the origin (on-screen)
  35205. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35206. * @param result defines the ray where to store the picking ray
  35207. * @param camera defines the camera to use for the picking
  35208. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35209. * @returns the current scene
  35210. */
  35211. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35212. /**
  35213. * Creates a ray that can be used to pick in the scene
  35214. * @param x defines the x coordinate of the origin (on-screen)
  35215. * @param y defines the y coordinate of the origin (on-screen)
  35216. * @param camera defines the camera to use for the picking
  35217. * @returns a Ray
  35218. */
  35219. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35220. /**
  35221. * Creates a ray that can be used to pick in the scene
  35222. * @param x defines the x coordinate of the origin (on-screen)
  35223. * @param y defines the y coordinate of the origin (on-screen)
  35224. * @param result defines the ray where to store the picking ray
  35225. * @param camera defines the camera to use for the picking
  35226. * @returns the current scene
  35227. */
  35228. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35229. /** Launch a ray to try to pick a mesh in the scene
  35230. * @param x position on screen
  35231. * @param y position on screen
  35232. * @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
  35233. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35234. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35236. * @returns a PickingInfo
  35237. */
  35238. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35239. /** Use the given ray to pick a mesh in the scene
  35240. * @param ray The ray to use to pick meshes
  35241. * @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
  35242. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35244. * @returns a PickingInfo
  35245. */
  35246. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35247. /**
  35248. * Launch a ray to try to pick a mesh in the scene
  35249. * @param x X position on screen
  35250. * @param y Y position on screen
  35251. * @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
  35252. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35254. * @returns an array of PickingInfo
  35255. */
  35256. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35257. /**
  35258. * Launch a ray to try to pick a mesh in the scene
  35259. * @param ray Ray to use
  35260. * @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
  35261. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35262. * @returns an array of PickingInfo
  35263. */
  35264. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35265. /**
  35266. * Force the value of meshUnderPointer
  35267. * @param mesh defines the mesh to use
  35268. */
  35269. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35270. /**
  35271. * Gets the mesh under the pointer
  35272. * @returns a Mesh or null if no mesh is under the pointer
  35273. */
  35274. getPointerOverMesh(): Nullable<AbstractMesh>;
  35275. /** @hidden */
  35276. _rebuildGeometries(): void;
  35277. /** @hidden */
  35278. _rebuildTextures(): void;
  35279. private _getByTags;
  35280. /**
  35281. * Get a list of meshes by tags
  35282. * @param tagsQuery defines the tags query to use
  35283. * @param forEach defines a predicate used to filter results
  35284. * @returns an array of Mesh
  35285. */
  35286. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35287. /**
  35288. * Get a list of cameras by tags
  35289. * @param tagsQuery defines the tags query to use
  35290. * @param forEach defines a predicate used to filter results
  35291. * @returns an array of Camera
  35292. */
  35293. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35294. /**
  35295. * Get a list of lights by tags
  35296. * @param tagsQuery defines the tags query to use
  35297. * @param forEach defines a predicate used to filter results
  35298. * @returns an array of Light
  35299. */
  35300. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35301. /**
  35302. * Get a list of materials by tags
  35303. * @param tagsQuery defines the tags query to use
  35304. * @param forEach defines a predicate used to filter results
  35305. * @returns an array of Material
  35306. */
  35307. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35308. /**
  35309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35310. * This allowed control for front to back rendering or reversly depending of the special needs.
  35311. *
  35312. * @param renderingGroupId The rendering group id corresponding to its index
  35313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35316. */
  35317. 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;
  35318. /**
  35319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35320. *
  35321. * @param renderingGroupId The rendering group id corresponding to its index
  35322. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35323. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35324. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35325. */
  35326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35327. /**
  35328. * Gets the current auto clear configuration for one rendering group of the rendering
  35329. * manager.
  35330. * @param index the rendering group index to get the information for
  35331. * @returns The auto clear setup for the requested rendering group
  35332. */
  35333. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35334. private _blockMaterialDirtyMechanism;
  35335. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35336. blockMaterialDirtyMechanism: boolean;
  35337. /**
  35338. * Will flag all materials as dirty to trigger new shader compilation
  35339. * @param flag defines the flag used to specify which material part must be marked as dirty
  35340. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35341. */
  35342. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35343. /** @hidden */
  35344. _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;
  35345. /** @hidden */
  35346. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35347. }
  35348. }
  35349. declare module "babylonjs/assetContainer" {
  35350. import { AbstractScene } from "babylonjs/abstractScene";
  35351. import { Scene } from "babylonjs/scene";
  35352. import { Mesh } from "babylonjs/Meshes/mesh";
  35353. /**
  35354. * Set of assets to keep when moving a scene into an asset container.
  35355. */
  35356. export class KeepAssets extends AbstractScene {
  35357. }
  35358. /**
  35359. * Container with a set of assets that can be added or removed from a scene.
  35360. */
  35361. export class AssetContainer extends AbstractScene {
  35362. /**
  35363. * The scene the AssetContainer belongs to.
  35364. */
  35365. scene: Scene;
  35366. /**
  35367. * Instantiates an AssetContainer.
  35368. * @param scene The scene the AssetContainer belongs to.
  35369. */
  35370. constructor(scene: Scene);
  35371. /**
  35372. * Adds all the assets from the container to the scene.
  35373. */
  35374. addAllToScene(): void;
  35375. /**
  35376. * Removes all the assets in the container from the scene
  35377. */
  35378. removeAllFromScene(): void;
  35379. /**
  35380. * Disposes all the assets in the container
  35381. */
  35382. dispose(): void;
  35383. private _moveAssets;
  35384. /**
  35385. * Removes all the assets contained in the scene and adds them to the container.
  35386. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35387. */
  35388. moveAllFromScene(keepAssets?: KeepAssets): void;
  35389. /**
  35390. * 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.
  35391. * @returns the root mesh
  35392. */
  35393. createRootMesh(): Mesh;
  35394. }
  35395. }
  35396. declare module "babylonjs/abstractScene" {
  35397. import { Scene } from "babylonjs/scene";
  35398. import { Nullable } from "babylonjs/types";
  35399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35400. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35401. import { Geometry } from "babylonjs/Meshes/geometry";
  35402. import { Skeleton } from "babylonjs/Bones/skeleton";
  35403. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35404. import { AssetContainer } from "babylonjs/assetContainer";
  35405. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35406. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35408. import { Material } from "babylonjs/Materials/material";
  35409. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35410. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35411. import { Camera } from "babylonjs/Cameras/camera";
  35412. import { Light } from "babylonjs/Lights/light";
  35413. import { Node } from "babylonjs/node";
  35414. import { Animation } from "babylonjs/Animations/animation";
  35415. /**
  35416. * Defines how the parser contract is defined.
  35417. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35418. */
  35419. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35420. /**
  35421. * Defines how the individual parser contract is defined.
  35422. * These parser can parse an individual asset
  35423. */
  35424. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35425. /**
  35426. * Base class of the scene acting as a container for the different elements composing a scene.
  35427. * This class is dynamically extended by the different components of the scene increasing
  35428. * flexibility and reducing coupling
  35429. */
  35430. export abstract class AbstractScene {
  35431. /**
  35432. * Stores the list of available parsers in the application.
  35433. */
  35434. private static _BabylonFileParsers;
  35435. /**
  35436. * Stores the list of available individual parsers in the application.
  35437. */
  35438. private static _IndividualBabylonFileParsers;
  35439. /**
  35440. * Adds a parser in the list of available ones
  35441. * @param name Defines the name of the parser
  35442. * @param parser Defines the parser to add
  35443. */
  35444. static AddParser(name: string, parser: BabylonFileParser): void;
  35445. /**
  35446. * Gets a general parser from the list of avaialble ones
  35447. * @param name Defines the name of the parser
  35448. * @returns the requested parser or null
  35449. */
  35450. static GetParser(name: string): Nullable<BabylonFileParser>;
  35451. /**
  35452. * Adds n individual parser in the list of available ones
  35453. * @param name Defines the name of the parser
  35454. * @param parser Defines the parser to add
  35455. */
  35456. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35457. /**
  35458. * Gets an individual parser from the list of avaialble ones
  35459. * @param name Defines the name of the parser
  35460. * @returns the requested parser or null
  35461. */
  35462. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35463. /**
  35464. * Parser json data and populate both a scene and its associated container object
  35465. * @param jsonData Defines the data to parse
  35466. * @param scene Defines the scene to parse the data for
  35467. * @param container Defines the container attached to the parsing sequence
  35468. * @param rootUrl Defines the root url of the data
  35469. */
  35470. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35471. /**
  35472. * Gets the list of root nodes (ie. nodes with no parent)
  35473. */
  35474. rootNodes: Node[];
  35475. /** All of the cameras added to this scene
  35476. * @see http://doc.babylonjs.com/babylon101/cameras
  35477. */
  35478. cameras: Camera[];
  35479. /**
  35480. * All of the lights added to this scene
  35481. * @see http://doc.babylonjs.com/babylon101/lights
  35482. */
  35483. lights: Light[];
  35484. /**
  35485. * All of the (abstract) meshes added to this scene
  35486. */
  35487. meshes: AbstractMesh[];
  35488. /**
  35489. * The list of skeletons added to the scene
  35490. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35491. */
  35492. skeletons: Skeleton[];
  35493. /**
  35494. * All of the particle systems added to this scene
  35495. * @see http://doc.babylonjs.com/babylon101/particles
  35496. */
  35497. particleSystems: IParticleSystem[];
  35498. /**
  35499. * Gets a list of Animations associated with the scene
  35500. */
  35501. animations: Animation[];
  35502. /**
  35503. * All of the animation groups added to this scene
  35504. * @see http://doc.babylonjs.com/how_to/group
  35505. */
  35506. animationGroups: AnimationGroup[];
  35507. /**
  35508. * All of the multi-materials added to this scene
  35509. * @see http://doc.babylonjs.com/how_to/multi_materials
  35510. */
  35511. multiMaterials: MultiMaterial[];
  35512. /**
  35513. * All of the materials added to this scene
  35514. * In the context of a Scene, it is not supposed to be modified manually.
  35515. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35516. * Note also that the order of the Material wihin the array is not significant and might change.
  35517. * @see http://doc.babylonjs.com/babylon101/materials
  35518. */
  35519. materials: Material[];
  35520. /**
  35521. * The list of morph target managers added to the scene
  35522. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35523. */
  35524. morphTargetManagers: MorphTargetManager[];
  35525. /**
  35526. * The list of geometries used in the scene.
  35527. */
  35528. geometries: Geometry[];
  35529. /**
  35530. * All of the tranform nodes added to this scene
  35531. * In the context of a Scene, it is not supposed to be modified manually.
  35532. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35533. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35534. * @see http://doc.babylonjs.com/how_to/transformnode
  35535. */
  35536. transformNodes: TransformNode[];
  35537. /**
  35538. * ActionManagers available on the scene.
  35539. */
  35540. actionManagers: AbstractActionManager[];
  35541. /**
  35542. * Textures to keep.
  35543. */
  35544. textures: BaseTexture[];
  35545. /**
  35546. * Environment texture for the scene
  35547. */
  35548. environmentTexture: Nullable<BaseTexture>;
  35549. }
  35550. }
  35551. declare module "babylonjs/Audio/sound" {
  35552. import { Observable } from "babylonjs/Misc/observable";
  35553. import { Vector3 } from "babylonjs/Maths/math.vector";
  35554. import { Nullable } from "babylonjs/types";
  35555. import { Scene } from "babylonjs/scene";
  35556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35557. /**
  35558. * Interface used to define options for Sound class
  35559. */
  35560. export interface ISoundOptions {
  35561. /**
  35562. * Does the sound autoplay once loaded.
  35563. */
  35564. autoplay?: boolean;
  35565. /**
  35566. * Does the sound loop after it finishes playing once.
  35567. */
  35568. loop?: boolean;
  35569. /**
  35570. * Sound's volume
  35571. */
  35572. volume?: number;
  35573. /**
  35574. * Is it a spatial sound?
  35575. */
  35576. spatialSound?: boolean;
  35577. /**
  35578. * Maximum distance to hear that sound
  35579. */
  35580. maxDistance?: number;
  35581. /**
  35582. * Uses user defined attenuation function
  35583. */
  35584. useCustomAttenuation?: boolean;
  35585. /**
  35586. * Define the roll off factor of spatial sounds.
  35587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35588. */
  35589. rolloffFactor?: number;
  35590. /**
  35591. * Define the reference distance the sound should be heard perfectly.
  35592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35593. */
  35594. refDistance?: number;
  35595. /**
  35596. * Define the distance attenuation model the sound will follow.
  35597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35598. */
  35599. distanceModel?: string;
  35600. /**
  35601. * Defines the playback speed (1 by default)
  35602. */
  35603. playbackRate?: number;
  35604. /**
  35605. * Defines if the sound is from a streaming source
  35606. */
  35607. streaming?: boolean;
  35608. /**
  35609. * Defines an optional length (in seconds) inside the sound file
  35610. */
  35611. length?: number;
  35612. /**
  35613. * Defines an optional offset (in seconds) inside the sound file
  35614. */
  35615. offset?: number;
  35616. /**
  35617. * If true, URLs will not be required to state the audio file codec to use.
  35618. */
  35619. skipCodecCheck?: boolean;
  35620. }
  35621. /**
  35622. * Defines a sound that can be played in the application.
  35623. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35625. */
  35626. export class Sound {
  35627. /**
  35628. * The name of the sound in the scene.
  35629. */
  35630. name: string;
  35631. /**
  35632. * Does the sound autoplay once loaded.
  35633. */
  35634. autoplay: boolean;
  35635. /**
  35636. * Does the sound loop after it finishes playing once.
  35637. */
  35638. loop: boolean;
  35639. /**
  35640. * Does the sound use a custom attenuation curve to simulate the falloff
  35641. * happening when the source gets further away from the camera.
  35642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35643. */
  35644. useCustomAttenuation: boolean;
  35645. /**
  35646. * The sound track id this sound belongs to.
  35647. */
  35648. soundTrackId: number;
  35649. /**
  35650. * Is this sound currently played.
  35651. */
  35652. isPlaying: boolean;
  35653. /**
  35654. * Is this sound currently paused.
  35655. */
  35656. isPaused: boolean;
  35657. /**
  35658. * Does this sound enables spatial sound.
  35659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35660. */
  35661. spatialSound: boolean;
  35662. /**
  35663. * Define the reference distance the sound should be heard perfectly.
  35664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35665. */
  35666. refDistance: number;
  35667. /**
  35668. * Define the roll off factor of spatial sounds.
  35669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35670. */
  35671. rolloffFactor: number;
  35672. /**
  35673. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35675. */
  35676. maxDistance: number;
  35677. /**
  35678. * Define the distance attenuation model the sound will follow.
  35679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35680. */
  35681. distanceModel: string;
  35682. /**
  35683. * @hidden
  35684. * Back Compat
  35685. **/
  35686. onended: () => any;
  35687. /**
  35688. * Observable event when the current playing sound finishes.
  35689. */
  35690. onEndedObservable: Observable<Sound>;
  35691. private _panningModel;
  35692. private _playbackRate;
  35693. private _streaming;
  35694. private _startTime;
  35695. private _startOffset;
  35696. private _position;
  35697. /** @hidden */
  35698. _positionInEmitterSpace: boolean;
  35699. private _localDirection;
  35700. private _volume;
  35701. private _isReadyToPlay;
  35702. private _isDirectional;
  35703. private _readyToPlayCallback;
  35704. private _audioBuffer;
  35705. private _soundSource;
  35706. private _streamingSource;
  35707. private _soundPanner;
  35708. private _soundGain;
  35709. private _inputAudioNode;
  35710. private _outputAudioNode;
  35711. private _coneInnerAngle;
  35712. private _coneOuterAngle;
  35713. private _coneOuterGain;
  35714. private _scene;
  35715. private _connectedTransformNode;
  35716. private _customAttenuationFunction;
  35717. private _registerFunc;
  35718. private _isOutputConnected;
  35719. private _htmlAudioElement;
  35720. private _urlType;
  35721. private _length?;
  35722. private _offset?;
  35723. /** @hidden */
  35724. static _SceneComponentInitialization: (scene: Scene) => void;
  35725. /**
  35726. * Create a sound and attach it to a scene
  35727. * @param name Name of your sound
  35728. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35729. * @param scene defines the scene the sound belongs to
  35730. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35731. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35732. */
  35733. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35734. /**
  35735. * Release the sound and its associated resources
  35736. */
  35737. dispose(): void;
  35738. /**
  35739. * Gets if the sounds is ready to be played or not.
  35740. * @returns true if ready, otherwise false
  35741. */
  35742. isReady(): boolean;
  35743. private _soundLoaded;
  35744. /**
  35745. * Sets the data of the sound from an audiobuffer
  35746. * @param audioBuffer The audioBuffer containing the data
  35747. */
  35748. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35749. /**
  35750. * Updates the current sounds options such as maxdistance, loop...
  35751. * @param options A JSON object containing values named as the object properties
  35752. */
  35753. updateOptions(options: ISoundOptions): void;
  35754. private _createSpatialParameters;
  35755. private _updateSpatialParameters;
  35756. /**
  35757. * Switch the panning model to HRTF:
  35758. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35760. */
  35761. switchPanningModelToHRTF(): void;
  35762. /**
  35763. * Switch the panning model to Equal Power:
  35764. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35766. */
  35767. switchPanningModelToEqualPower(): void;
  35768. private _switchPanningModel;
  35769. /**
  35770. * Connect this sound to a sound track audio node like gain...
  35771. * @param soundTrackAudioNode the sound track audio node to connect to
  35772. */
  35773. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35774. /**
  35775. * Transform this sound into a directional source
  35776. * @param coneInnerAngle Size of the inner cone in degree
  35777. * @param coneOuterAngle Size of the outer cone in degree
  35778. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35779. */
  35780. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35781. /**
  35782. * Gets or sets the inner angle for the directional cone.
  35783. */
  35784. /**
  35785. * Gets or sets the inner angle for the directional cone.
  35786. */
  35787. directionalConeInnerAngle: number;
  35788. /**
  35789. * Gets or sets the outer angle for the directional cone.
  35790. */
  35791. /**
  35792. * Gets or sets the outer angle for the directional cone.
  35793. */
  35794. directionalConeOuterAngle: number;
  35795. /**
  35796. * Sets the position of the emitter if spatial sound is enabled
  35797. * @param newPosition Defines the new posisiton
  35798. */
  35799. setPosition(newPosition: Vector3): void;
  35800. /**
  35801. * Sets the local direction of the emitter if spatial sound is enabled
  35802. * @param newLocalDirection Defines the new local direction
  35803. */
  35804. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35805. private _updateDirection;
  35806. /** @hidden */
  35807. updateDistanceFromListener(): void;
  35808. /**
  35809. * Sets a new custom attenuation function for the sound.
  35810. * @param callback Defines the function used for the attenuation
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35812. */
  35813. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35814. /**
  35815. * Play the sound
  35816. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35817. * @param offset (optional) Start the sound at a specific time in seconds
  35818. * @param length (optional) Sound duration (in seconds)
  35819. */
  35820. play(time?: number, offset?: number, length?: number): void;
  35821. private _onended;
  35822. /**
  35823. * Stop the sound
  35824. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35825. */
  35826. stop(time?: number): void;
  35827. /**
  35828. * Put the sound in pause
  35829. */
  35830. pause(): void;
  35831. /**
  35832. * Sets a dedicated volume for this sounds
  35833. * @param newVolume Define the new volume of the sound
  35834. * @param time Define time for gradual change to new volume
  35835. */
  35836. setVolume(newVolume: number, time?: number): void;
  35837. /**
  35838. * Set the sound play back rate
  35839. * @param newPlaybackRate Define the playback rate the sound should be played at
  35840. */
  35841. setPlaybackRate(newPlaybackRate: number): void;
  35842. /**
  35843. * Gets the volume of the sound.
  35844. * @returns the volume of the sound
  35845. */
  35846. getVolume(): number;
  35847. /**
  35848. * Attach the sound to a dedicated mesh
  35849. * @param transformNode The transform node to connect the sound with
  35850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35851. */
  35852. attachToMesh(transformNode: TransformNode): void;
  35853. /**
  35854. * Detach the sound from the previously attached mesh
  35855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35856. */
  35857. detachFromMesh(): void;
  35858. private _onRegisterAfterWorldMatrixUpdate;
  35859. /**
  35860. * Clone the current sound in the scene.
  35861. * @returns the new sound clone
  35862. */
  35863. clone(): Nullable<Sound>;
  35864. /**
  35865. * Gets the current underlying audio buffer containing the data
  35866. * @returns the audio buffer
  35867. */
  35868. getAudioBuffer(): Nullable<AudioBuffer>;
  35869. /**
  35870. * Serializes the Sound in a JSON representation
  35871. * @returns the JSON representation of the sound
  35872. */
  35873. serialize(): any;
  35874. /**
  35875. * Parse a JSON representation of a sound to innstantiate in a given scene
  35876. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35877. * @param scene Define the scene the new parsed sound should be created in
  35878. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35879. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35880. * @returns the newly parsed sound
  35881. */
  35882. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35883. }
  35884. }
  35885. declare module "babylonjs/Actions/directAudioActions" {
  35886. import { Action } from "babylonjs/Actions/action";
  35887. import { Condition } from "babylonjs/Actions/condition";
  35888. import { Sound } from "babylonjs/Audio/sound";
  35889. /**
  35890. * This defines an action helpful to play a defined sound on a triggered action.
  35891. */
  35892. export class PlaySoundAction extends Action {
  35893. private _sound;
  35894. /**
  35895. * Instantiate the action
  35896. * @param triggerOptions defines the trigger options
  35897. * @param sound defines the sound to play
  35898. * @param condition defines the trigger related conditions
  35899. */
  35900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35901. /** @hidden */
  35902. _prepare(): void;
  35903. /**
  35904. * Execute the action and play the sound.
  35905. */
  35906. execute(): void;
  35907. /**
  35908. * Serializes the actions and its related information.
  35909. * @param parent defines the object to serialize in
  35910. * @returns the serialized object
  35911. */
  35912. serialize(parent: any): any;
  35913. }
  35914. /**
  35915. * This defines an action helpful to stop a defined sound on a triggered action.
  35916. */
  35917. export class StopSoundAction extends Action {
  35918. private _sound;
  35919. /**
  35920. * Instantiate the action
  35921. * @param triggerOptions defines the trigger options
  35922. * @param sound defines the sound to stop
  35923. * @param condition defines the trigger related conditions
  35924. */
  35925. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35926. /** @hidden */
  35927. _prepare(): void;
  35928. /**
  35929. * Execute the action and stop the sound.
  35930. */
  35931. execute(): void;
  35932. /**
  35933. * Serializes the actions and its related information.
  35934. * @param parent defines the object to serialize in
  35935. * @returns the serialized object
  35936. */
  35937. serialize(parent: any): any;
  35938. }
  35939. }
  35940. declare module "babylonjs/Actions/interpolateValueAction" {
  35941. import { Action } from "babylonjs/Actions/action";
  35942. import { Condition } from "babylonjs/Actions/condition";
  35943. import { Observable } from "babylonjs/Misc/observable";
  35944. /**
  35945. * This defines an action responsible to change the value of a property
  35946. * by interpolating between its current value and the newly set one once triggered.
  35947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35948. */
  35949. export class InterpolateValueAction extends Action {
  35950. /**
  35951. * Defines the path of the property where the value should be interpolated
  35952. */
  35953. propertyPath: string;
  35954. /**
  35955. * Defines the target value at the end of the interpolation.
  35956. */
  35957. value: any;
  35958. /**
  35959. * Defines the time it will take for the property to interpolate to the value.
  35960. */
  35961. duration: number;
  35962. /**
  35963. * Defines if the other scene animations should be stopped when the action has been triggered
  35964. */
  35965. stopOtherAnimations?: boolean;
  35966. /**
  35967. * Defines a callback raised once the interpolation animation has been done.
  35968. */
  35969. onInterpolationDone?: () => void;
  35970. /**
  35971. * Observable triggered once the interpolation animation has been done.
  35972. */
  35973. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35974. private _target;
  35975. private _effectiveTarget;
  35976. private _property;
  35977. /**
  35978. * Instantiate the action
  35979. * @param triggerOptions defines the trigger options
  35980. * @param target defines the object containing the value to interpolate
  35981. * @param propertyPath defines the path to the property in the target object
  35982. * @param value defines the target value at the end of the interpolation
  35983. * @param duration deines the time it will take for the property to interpolate to the value.
  35984. * @param condition defines the trigger related conditions
  35985. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35986. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35987. */
  35988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35989. /** @hidden */
  35990. _prepare(): void;
  35991. /**
  35992. * Execute the action starts the value interpolation.
  35993. */
  35994. execute(): void;
  35995. /**
  35996. * Serializes the actions and its related information.
  35997. * @param parent defines the object to serialize in
  35998. * @returns the serialized object
  35999. */
  36000. serialize(parent: any): any;
  36001. }
  36002. }
  36003. declare module "babylonjs/Actions/index" {
  36004. export * from "babylonjs/Actions/action";
  36005. export * from "babylonjs/Actions/actionEvent";
  36006. export * from "babylonjs/Actions/actionManager";
  36007. export * from "babylonjs/Actions/condition";
  36008. export * from "babylonjs/Actions/directActions";
  36009. export * from "babylonjs/Actions/directAudioActions";
  36010. export * from "babylonjs/Actions/interpolateValueAction";
  36011. }
  36012. declare module "babylonjs/Animations/index" {
  36013. export * from "babylonjs/Animations/animatable";
  36014. export * from "babylonjs/Animations/animation";
  36015. export * from "babylonjs/Animations/animationGroup";
  36016. export * from "babylonjs/Animations/animationPropertiesOverride";
  36017. export * from "babylonjs/Animations/easing";
  36018. export * from "babylonjs/Animations/runtimeAnimation";
  36019. export * from "babylonjs/Animations/animationEvent";
  36020. export * from "babylonjs/Animations/animationGroup";
  36021. export * from "babylonjs/Animations/animationKey";
  36022. export * from "babylonjs/Animations/animationRange";
  36023. export * from "babylonjs/Animations/animatable.interface";
  36024. }
  36025. declare module "babylonjs/Audio/soundTrack" {
  36026. import { Sound } from "babylonjs/Audio/sound";
  36027. import { Analyser } from "babylonjs/Audio/analyser";
  36028. import { Scene } from "babylonjs/scene";
  36029. /**
  36030. * Options allowed during the creation of a sound track.
  36031. */
  36032. export interface ISoundTrackOptions {
  36033. /**
  36034. * The volume the sound track should take during creation
  36035. */
  36036. volume?: number;
  36037. /**
  36038. * Define if the sound track is the main sound track of the scene
  36039. */
  36040. mainTrack?: boolean;
  36041. }
  36042. /**
  36043. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36044. * It will be also used in a future release to apply effects on a specific track.
  36045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36046. */
  36047. export class SoundTrack {
  36048. /**
  36049. * The unique identifier of the sound track in the scene.
  36050. */
  36051. id: number;
  36052. /**
  36053. * The list of sounds included in the sound track.
  36054. */
  36055. soundCollection: Array<Sound>;
  36056. private _outputAudioNode;
  36057. private _scene;
  36058. private _isMainTrack;
  36059. private _connectedAnalyser;
  36060. private _options;
  36061. private _isInitialized;
  36062. /**
  36063. * Creates a new sound track.
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36065. * @param scene Define the scene the sound track belongs to
  36066. * @param options
  36067. */
  36068. constructor(scene: Scene, options?: ISoundTrackOptions);
  36069. private _initializeSoundTrackAudioGraph;
  36070. /**
  36071. * Release the sound track and its associated resources
  36072. */
  36073. dispose(): void;
  36074. /**
  36075. * Adds a sound to this sound track
  36076. * @param sound define the cound to add
  36077. * @ignoreNaming
  36078. */
  36079. AddSound(sound: Sound): void;
  36080. /**
  36081. * Removes a sound to this sound track
  36082. * @param sound define the cound to remove
  36083. * @ignoreNaming
  36084. */
  36085. RemoveSound(sound: Sound): void;
  36086. /**
  36087. * Set a global volume for the full sound track.
  36088. * @param newVolume Define the new volume of the sound track
  36089. */
  36090. setVolume(newVolume: number): void;
  36091. /**
  36092. * Switch the panning model to HRTF:
  36093. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36095. */
  36096. switchPanningModelToHRTF(): void;
  36097. /**
  36098. * Switch the panning model to Equal Power:
  36099. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36101. */
  36102. switchPanningModelToEqualPower(): void;
  36103. /**
  36104. * Connect the sound track to an audio analyser allowing some amazing
  36105. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36107. * @param analyser The analyser to connect to the engine
  36108. */
  36109. connectToAnalyser(analyser: Analyser): void;
  36110. }
  36111. }
  36112. declare module "babylonjs/Audio/audioSceneComponent" {
  36113. import { Sound } from "babylonjs/Audio/sound";
  36114. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36115. import { Nullable } from "babylonjs/types";
  36116. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36117. import { Scene } from "babylonjs/scene";
  36118. import { AbstractScene } from "babylonjs/abstractScene";
  36119. import "babylonjs/Audio/audioEngine";
  36120. module "babylonjs/abstractScene" {
  36121. interface AbstractScene {
  36122. /**
  36123. * The list of sounds used in the scene.
  36124. */
  36125. sounds: Nullable<Array<Sound>>;
  36126. }
  36127. }
  36128. module "babylonjs/scene" {
  36129. interface Scene {
  36130. /**
  36131. * @hidden
  36132. * Backing field
  36133. */
  36134. _mainSoundTrack: SoundTrack;
  36135. /**
  36136. * The main sound track played by the scene.
  36137. * It cotains your primary collection of sounds.
  36138. */
  36139. mainSoundTrack: SoundTrack;
  36140. /**
  36141. * The list of sound tracks added to the scene
  36142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36143. */
  36144. soundTracks: Nullable<Array<SoundTrack>>;
  36145. /**
  36146. * Gets a sound using a given name
  36147. * @param name defines the name to search for
  36148. * @return the found sound or null if not found at all.
  36149. */
  36150. getSoundByName(name: string): Nullable<Sound>;
  36151. /**
  36152. * Gets or sets if audio support is enabled
  36153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36154. */
  36155. audioEnabled: boolean;
  36156. /**
  36157. * Gets or sets if audio will be output to headphones
  36158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36159. */
  36160. headphone: boolean;
  36161. }
  36162. }
  36163. /**
  36164. * Defines the sound scene component responsible to manage any sounds
  36165. * in a given scene.
  36166. */
  36167. export class AudioSceneComponent implements ISceneSerializableComponent {
  36168. /**
  36169. * The component name helpfull to identify the component in the list of scene components.
  36170. */
  36171. readonly name: string;
  36172. /**
  36173. * The scene the component belongs to.
  36174. */
  36175. scene: Scene;
  36176. private _audioEnabled;
  36177. /**
  36178. * Gets whether audio is enabled or not.
  36179. * Please use related enable/disable method to switch state.
  36180. */
  36181. readonly audioEnabled: boolean;
  36182. private _headphone;
  36183. /**
  36184. * Gets whether audio is outputing to headphone or not.
  36185. * Please use the according Switch methods to change output.
  36186. */
  36187. readonly headphone: boolean;
  36188. /**
  36189. * Creates a new instance of the component for the given scene
  36190. * @param scene Defines the scene to register the component in
  36191. */
  36192. constructor(scene: Scene);
  36193. /**
  36194. * Registers the component in a given scene
  36195. */
  36196. register(): void;
  36197. /**
  36198. * Rebuilds the elements related to this component in case of
  36199. * context lost for instance.
  36200. */
  36201. rebuild(): void;
  36202. /**
  36203. * Serializes the component data to the specified json object
  36204. * @param serializationObject The object to serialize to
  36205. */
  36206. serialize(serializationObject: any): void;
  36207. /**
  36208. * Adds all the elements from the container to the scene
  36209. * @param container the container holding the elements
  36210. */
  36211. addFromContainer(container: AbstractScene): void;
  36212. /**
  36213. * Removes all the elements in the container from the scene
  36214. * @param container contains the elements to remove
  36215. * @param dispose if the removed element should be disposed (default: false)
  36216. */
  36217. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36218. /**
  36219. * Disposes the component and the associated ressources.
  36220. */
  36221. dispose(): void;
  36222. /**
  36223. * Disables audio in the associated scene.
  36224. */
  36225. disableAudio(): void;
  36226. /**
  36227. * Enables audio in the associated scene.
  36228. */
  36229. enableAudio(): void;
  36230. /**
  36231. * Switch audio to headphone output.
  36232. */
  36233. switchAudioModeForHeadphones(): void;
  36234. /**
  36235. * Switch audio to normal speakers.
  36236. */
  36237. switchAudioModeForNormalSpeakers(): void;
  36238. private _afterRender;
  36239. }
  36240. }
  36241. declare module "babylonjs/Audio/weightedsound" {
  36242. import { Sound } from "babylonjs/Audio/sound";
  36243. /**
  36244. * Wraps one or more Sound objects and selects one with random weight for playback.
  36245. */
  36246. export class WeightedSound {
  36247. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36248. loop: boolean;
  36249. private _coneInnerAngle;
  36250. private _coneOuterAngle;
  36251. private _volume;
  36252. /** A Sound is currently playing. */
  36253. isPlaying: boolean;
  36254. /** A Sound is currently paused. */
  36255. isPaused: boolean;
  36256. private _sounds;
  36257. private _weights;
  36258. private _currentIndex?;
  36259. /**
  36260. * Creates a new WeightedSound from the list of sounds given.
  36261. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36262. * @param sounds Array of Sounds that will be selected from.
  36263. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36264. */
  36265. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36266. /**
  36267. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36268. */
  36269. /**
  36270. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36271. */
  36272. directionalConeInnerAngle: number;
  36273. /**
  36274. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36275. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36276. */
  36277. /**
  36278. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36279. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36280. */
  36281. directionalConeOuterAngle: number;
  36282. /**
  36283. * Playback volume.
  36284. */
  36285. /**
  36286. * Playback volume.
  36287. */
  36288. volume: number;
  36289. private _onended;
  36290. /**
  36291. * Suspend playback
  36292. */
  36293. pause(): void;
  36294. /**
  36295. * Stop playback
  36296. */
  36297. stop(): void;
  36298. /**
  36299. * Start playback.
  36300. * @param startOffset Position the clip head at a specific time in seconds.
  36301. */
  36302. play(startOffset?: number): void;
  36303. }
  36304. }
  36305. declare module "babylonjs/Audio/index" {
  36306. export * from "babylonjs/Audio/analyser";
  36307. export * from "babylonjs/Audio/audioEngine";
  36308. export * from "babylonjs/Audio/audioSceneComponent";
  36309. export * from "babylonjs/Audio/sound";
  36310. export * from "babylonjs/Audio/soundTrack";
  36311. export * from "babylonjs/Audio/weightedsound";
  36312. }
  36313. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36314. import { Behavior } from "babylonjs/Behaviors/behavior";
  36315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36316. import { BackEase } from "babylonjs/Animations/easing";
  36317. /**
  36318. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36320. */
  36321. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36322. /**
  36323. * Gets the name of the behavior.
  36324. */
  36325. readonly name: string;
  36326. /**
  36327. * The easing function used by animations
  36328. */
  36329. static EasingFunction: BackEase;
  36330. /**
  36331. * The easing mode used by animations
  36332. */
  36333. static EasingMode: number;
  36334. /**
  36335. * The duration of the animation, in milliseconds
  36336. */
  36337. transitionDuration: number;
  36338. /**
  36339. * Length of the distance animated by the transition when lower radius is reached
  36340. */
  36341. lowerRadiusTransitionRange: number;
  36342. /**
  36343. * Length of the distance animated by the transition when upper radius is reached
  36344. */
  36345. upperRadiusTransitionRange: number;
  36346. private _autoTransitionRange;
  36347. /**
  36348. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36349. */
  36350. /**
  36351. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36352. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36353. */
  36354. autoTransitionRange: boolean;
  36355. private _attachedCamera;
  36356. private _onAfterCheckInputsObserver;
  36357. private _onMeshTargetChangedObserver;
  36358. /**
  36359. * Initializes the behavior.
  36360. */
  36361. init(): void;
  36362. /**
  36363. * Attaches the behavior to its arc rotate camera.
  36364. * @param camera Defines the camera to attach the behavior to
  36365. */
  36366. attach(camera: ArcRotateCamera): void;
  36367. /**
  36368. * Detaches the behavior from its current arc rotate camera.
  36369. */
  36370. detach(): void;
  36371. private _radiusIsAnimating;
  36372. private _radiusBounceTransition;
  36373. private _animatables;
  36374. private _cachedWheelPrecision;
  36375. /**
  36376. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36377. * @param radiusLimit The limit to check against.
  36378. * @return Bool to indicate if at limit.
  36379. */
  36380. private _isRadiusAtLimit;
  36381. /**
  36382. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36383. * @param radiusDelta The delta by which to animate to. Can be negative.
  36384. */
  36385. private _applyBoundRadiusAnimation;
  36386. /**
  36387. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36388. */
  36389. protected _clearAnimationLocks(): void;
  36390. /**
  36391. * Stops and removes all animations that have been applied to the camera
  36392. */
  36393. stopAllAnimations(): void;
  36394. }
  36395. }
  36396. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36397. import { Behavior } from "babylonjs/Behaviors/behavior";
  36398. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36399. import { ExponentialEase } from "babylonjs/Animations/easing";
  36400. import { Nullable } from "babylonjs/types";
  36401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36402. import { Vector3 } from "babylonjs/Maths/math.vector";
  36403. /**
  36404. * 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.
  36405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36406. */
  36407. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36408. /**
  36409. * Gets the name of the behavior.
  36410. */
  36411. readonly name: string;
  36412. private _mode;
  36413. private _radiusScale;
  36414. private _positionScale;
  36415. private _defaultElevation;
  36416. private _elevationReturnTime;
  36417. private _elevationReturnWaitTime;
  36418. private _zoomStopsAnimation;
  36419. private _framingTime;
  36420. /**
  36421. * The easing function used by animations
  36422. */
  36423. static EasingFunction: ExponentialEase;
  36424. /**
  36425. * The easing mode used by animations
  36426. */
  36427. static EasingMode: number;
  36428. /**
  36429. * Sets the current mode used by the behavior
  36430. */
  36431. /**
  36432. * Gets current mode used by the behavior.
  36433. */
  36434. mode: number;
  36435. /**
  36436. * Sets the scale applied to the radius (1 by default)
  36437. */
  36438. /**
  36439. * Gets the scale applied to the radius
  36440. */
  36441. radiusScale: number;
  36442. /**
  36443. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36444. */
  36445. /**
  36446. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36447. */
  36448. positionScale: number;
  36449. /**
  36450. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36451. * behaviour is triggered, in radians.
  36452. */
  36453. /**
  36454. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36455. * behaviour is triggered, in radians.
  36456. */
  36457. defaultElevation: number;
  36458. /**
  36459. * Sets the time (in milliseconds) taken to return to the default beta position.
  36460. * Negative value indicates camera should not return to default.
  36461. */
  36462. /**
  36463. * Gets the time (in milliseconds) taken to return to the default beta position.
  36464. * Negative value indicates camera should not return to default.
  36465. */
  36466. elevationReturnTime: number;
  36467. /**
  36468. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36469. */
  36470. /**
  36471. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36472. */
  36473. elevationReturnWaitTime: number;
  36474. /**
  36475. * Sets the flag that indicates if user zooming should stop animation.
  36476. */
  36477. /**
  36478. * Gets the flag that indicates if user zooming should stop animation.
  36479. */
  36480. zoomStopsAnimation: boolean;
  36481. /**
  36482. * Sets the transition time when framing the mesh, in milliseconds
  36483. */
  36484. /**
  36485. * Gets the transition time when framing the mesh, in milliseconds
  36486. */
  36487. framingTime: number;
  36488. /**
  36489. * Define if the behavior should automatically change the configured
  36490. * camera limits and sensibilities.
  36491. */
  36492. autoCorrectCameraLimitsAndSensibility: boolean;
  36493. private _onPrePointerObservableObserver;
  36494. private _onAfterCheckInputsObserver;
  36495. private _onMeshTargetChangedObserver;
  36496. private _attachedCamera;
  36497. private _isPointerDown;
  36498. private _lastInteractionTime;
  36499. /**
  36500. * Initializes the behavior.
  36501. */
  36502. init(): void;
  36503. /**
  36504. * Attaches the behavior to its arc rotate camera.
  36505. * @param camera Defines the camera to attach the behavior to
  36506. */
  36507. attach(camera: ArcRotateCamera): void;
  36508. /**
  36509. * Detaches the behavior from its current arc rotate camera.
  36510. */
  36511. detach(): void;
  36512. private _animatables;
  36513. private _betaIsAnimating;
  36514. private _betaTransition;
  36515. private _radiusTransition;
  36516. private _vectorTransition;
  36517. /**
  36518. * Targets the given mesh and updates zoom level accordingly.
  36519. * @param mesh The mesh to target.
  36520. * @param radius Optional. If a cached radius position already exists, overrides default.
  36521. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36524. */
  36525. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36526. /**
  36527. * Targets the given mesh with its children and updates zoom level accordingly.
  36528. * @param mesh The mesh to target.
  36529. * @param radius Optional. If a cached radius position already exists, overrides default.
  36530. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36533. */
  36534. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36535. /**
  36536. * Targets the given meshes with their children and updates zoom level accordingly.
  36537. * @param meshes The mesh to target.
  36538. * @param radius Optional. If a cached radius position already exists, overrides default.
  36539. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36542. */
  36543. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36544. /**
  36545. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36546. * @param minimumWorld Determines the smaller position of the bounding box extend
  36547. * @param maximumWorld Determines the bigger position of the bounding box extend
  36548. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36549. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36550. */
  36551. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36552. /**
  36553. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36554. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36555. * frustum width.
  36556. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36557. * to fully enclose the mesh in the viewing frustum.
  36558. */
  36559. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36560. /**
  36561. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36562. * is automatically returned to its default position (expected to be above ground plane).
  36563. */
  36564. private _maintainCameraAboveGround;
  36565. /**
  36566. * Returns the frustum slope based on the canvas ratio and camera FOV
  36567. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36568. */
  36569. private _getFrustumSlope;
  36570. /**
  36571. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36572. */
  36573. private _clearAnimationLocks;
  36574. /**
  36575. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36576. */
  36577. private _applyUserInteraction;
  36578. /**
  36579. * Stops and removes all animations that have been applied to the camera
  36580. */
  36581. stopAllAnimations(): void;
  36582. /**
  36583. * Gets a value indicating if the user is moving the camera
  36584. */
  36585. readonly isUserIsMoving: boolean;
  36586. /**
  36587. * The camera can move all the way towards the mesh.
  36588. */
  36589. static IgnoreBoundsSizeMode: number;
  36590. /**
  36591. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36592. */
  36593. static FitFrustumSidesMode: number;
  36594. }
  36595. }
  36596. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36597. import { Nullable } from "babylonjs/types";
  36598. import { Camera } from "babylonjs/Cameras/camera";
  36599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36600. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36601. /**
  36602. * Base class for Camera Pointer Inputs.
  36603. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36604. * for example usage.
  36605. */
  36606. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36607. /**
  36608. * Defines the camera the input is attached to.
  36609. */
  36610. abstract camera: Camera;
  36611. /**
  36612. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36613. */
  36614. protected _altKey: boolean;
  36615. protected _ctrlKey: boolean;
  36616. protected _metaKey: boolean;
  36617. protected _shiftKey: boolean;
  36618. /**
  36619. * Which mouse buttons were pressed at time of last mouse event.
  36620. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36621. */
  36622. protected _buttonsPressed: number;
  36623. /**
  36624. * Defines the buttons associated with the input to handle camera move.
  36625. */
  36626. buttons: number[];
  36627. /**
  36628. * Attach the input controls to a specific dom element to get the input from.
  36629. * @param element Defines the element the controls should be listened from
  36630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36631. */
  36632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36633. /**
  36634. * Detach the current controls from the specified dom element.
  36635. * @param element Defines the element to stop listening the inputs from
  36636. */
  36637. detachControl(element: Nullable<HTMLElement>): void;
  36638. /**
  36639. * Gets the class name of the current input.
  36640. * @returns the class name
  36641. */
  36642. getClassName(): string;
  36643. /**
  36644. * Get the friendly name associated with the input class.
  36645. * @returns the input friendly name
  36646. */
  36647. getSimpleName(): string;
  36648. /**
  36649. * Called on pointer POINTERDOUBLETAP event.
  36650. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36651. */
  36652. protected onDoubleTap(type: string): void;
  36653. /**
  36654. * Called on pointer POINTERMOVE event if only a single touch is active.
  36655. * Override this method to provide functionality.
  36656. */
  36657. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36658. /**
  36659. * Called on pointer POINTERMOVE event if multiple touches are active.
  36660. * Override this method to provide functionality.
  36661. */
  36662. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36663. /**
  36664. * Called on JS contextmenu event.
  36665. * Override this method to provide functionality.
  36666. */
  36667. protected onContextMenu(evt: PointerEvent): void;
  36668. /**
  36669. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36670. * press.
  36671. * Override this method to provide functionality.
  36672. */
  36673. protected onButtonDown(evt: PointerEvent): void;
  36674. /**
  36675. * Called each time a new POINTERUP event occurs. Ie, for each button
  36676. * release.
  36677. * Override this method to provide functionality.
  36678. */
  36679. protected onButtonUp(evt: PointerEvent): void;
  36680. /**
  36681. * Called when window becomes inactive.
  36682. * Override this method to provide functionality.
  36683. */
  36684. protected onLostFocus(): void;
  36685. private _pointerInput;
  36686. private _observer;
  36687. private _onLostFocus;
  36688. private pointA;
  36689. private pointB;
  36690. }
  36691. }
  36692. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36693. import { Nullable } from "babylonjs/types";
  36694. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36695. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36696. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36697. /**
  36698. * Manage the pointers inputs to control an arc rotate camera.
  36699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36700. */
  36701. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36702. /**
  36703. * Defines the camera the input is attached to.
  36704. */
  36705. camera: ArcRotateCamera;
  36706. /**
  36707. * Gets the class name of the current input.
  36708. * @returns the class name
  36709. */
  36710. getClassName(): string;
  36711. /**
  36712. * Defines the buttons associated with the input to handle camera move.
  36713. */
  36714. buttons: number[];
  36715. /**
  36716. * Defines the pointer angular sensibility along the X axis or how fast is
  36717. * the camera rotating.
  36718. */
  36719. angularSensibilityX: number;
  36720. /**
  36721. * Defines the pointer angular sensibility along the Y axis or how fast is
  36722. * the camera rotating.
  36723. */
  36724. angularSensibilityY: number;
  36725. /**
  36726. * Defines the pointer pinch precision or how fast is the camera zooming.
  36727. */
  36728. pinchPrecision: number;
  36729. /**
  36730. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36731. * from 0.
  36732. * It defines the percentage of current camera.radius to use as delta when
  36733. * pinch zoom is used.
  36734. */
  36735. pinchDeltaPercentage: number;
  36736. /**
  36737. * Defines the pointer panning sensibility or how fast is the camera moving.
  36738. */
  36739. panningSensibility: number;
  36740. /**
  36741. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36742. */
  36743. multiTouchPanning: boolean;
  36744. /**
  36745. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36746. * zoom (pinch) through multitouch.
  36747. */
  36748. multiTouchPanAndZoom: boolean;
  36749. /**
  36750. * Revers pinch action direction.
  36751. */
  36752. pinchInwards: boolean;
  36753. private _isPanClick;
  36754. private _twoFingerActivityCount;
  36755. private _isPinching;
  36756. /**
  36757. * Called on pointer POINTERMOVE event if only a single touch is active.
  36758. */
  36759. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36760. /**
  36761. * Called on pointer POINTERDOUBLETAP event.
  36762. */
  36763. protected onDoubleTap(type: string): void;
  36764. /**
  36765. * Called on pointer POINTERMOVE event if multiple touches are active.
  36766. */
  36767. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36768. /**
  36769. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36770. * press.
  36771. */
  36772. protected onButtonDown(evt: PointerEvent): void;
  36773. /**
  36774. * Called each time a new POINTERUP event occurs. Ie, for each button
  36775. * release.
  36776. */
  36777. protected onButtonUp(evt: PointerEvent): void;
  36778. /**
  36779. * Called when window becomes inactive.
  36780. */
  36781. protected onLostFocus(): void;
  36782. }
  36783. }
  36784. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36785. import { Nullable } from "babylonjs/types";
  36786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36787. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36788. /**
  36789. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36791. */
  36792. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36793. /**
  36794. * Defines the camera the input is attached to.
  36795. */
  36796. camera: ArcRotateCamera;
  36797. /**
  36798. * Defines the list of key codes associated with the up action (increase alpha)
  36799. */
  36800. keysUp: number[];
  36801. /**
  36802. * Defines the list of key codes associated with the down action (decrease alpha)
  36803. */
  36804. keysDown: number[];
  36805. /**
  36806. * Defines the list of key codes associated with the left action (increase beta)
  36807. */
  36808. keysLeft: number[];
  36809. /**
  36810. * Defines the list of key codes associated with the right action (decrease beta)
  36811. */
  36812. keysRight: number[];
  36813. /**
  36814. * Defines the list of key codes associated with the reset action.
  36815. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36816. */
  36817. keysReset: number[];
  36818. /**
  36819. * Defines the panning sensibility of the inputs.
  36820. * (How fast is the camera paning)
  36821. */
  36822. panningSensibility: number;
  36823. /**
  36824. * Defines the zooming sensibility of the inputs.
  36825. * (How fast is the camera zooming)
  36826. */
  36827. zoomingSensibility: number;
  36828. /**
  36829. * Defines wether maintaining the alt key down switch the movement mode from
  36830. * orientation to zoom.
  36831. */
  36832. useAltToZoom: boolean;
  36833. /**
  36834. * Rotation speed of the camera
  36835. */
  36836. angularSpeed: number;
  36837. private _keys;
  36838. private _ctrlPressed;
  36839. private _altPressed;
  36840. private _onCanvasBlurObserver;
  36841. private _onKeyboardObserver;
  36842. private _engine;
  36843. private _scene;
  36844. /**
  36845. * Attach the input controls to a specific dom element to get the input from.
  36846. * @param element Defines the element the controls should be listened from
  36847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36848. */
  36849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36850. /**
  36851. * Detach the current controls from the specified dom element.
  36852. * @param element Defines the element to stop listening the inputs from
  36853. */
  36854. detachControl(element: Nullable<HTMLElement>): void;
  36855. /**
  36856. * Update the current camera state depending on the inputs that have been used this frame.
  36857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36858. */
  36859. checkInputs(): void;
  36860. /**
  36861. * Gets the class name of the current intput.
  36862. * @returns the class name
  36863. */
  36864. getClassName(): string;
  36865. /**
  36866. * Get the friendly name associated with the input class.
  36867. * @returns the input friendly name
  36868. */
  36869. getSimpleName(): string;
  36870. }
  36871. }
  36872. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36873. import { Nullable } from "babylonjs/types";
  36874. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36875. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36876. /**
  36877. * Manage the mouse wheel inputs to control an arc rotate camera.
  36878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36879. */
  36880. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36881. /**
  36882. * Defines the camera the input is attached to.
  36883. */
  36884. camera: ArcRotateCamera;
  36885. /**
  36886. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36887. */
  36888. wheelPrecision: number;
  36889. /**
  36890. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36891. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36892. */
  36893. wheelDeltaPercentage: number;
  36894. private _wheel;
  36895. private _observer;
  36896. private computeDeltaFromMouseWheelLegacyEvent;
  36897. /**
  36898. * Attach the input controls to a specific dom element to get the input from.
  36899. * @param element Defines the element the controls should be listened from
  36900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36901. */
  36902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36903. /**
  36904. * Detach the current controls from the specified dom element.
  36905. * @param element Defines the element to stop listening the inputs from
  36906. */
  36907. detachControl(element: Nullable<HTMLElement>): void;
  36908. /**
  36909. * Gets the class name of the current intput.
  36910. * @returns the class name
  36911. */
  36912. getClassName(): string;
  36913. /**
  36914. * Get the friendly name associated with the input class.
  36915. * @returns the input friendly name
  36916. */
  36917. getSimpleName(): string;
  36918. }
  36919. }
  36920. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36921. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36922. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36923. /**
  36924. * Default Inputs manager for the ArcRotateCamera.
  36925. * It groups all the default supported inputs for ease of use.
  36926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36927. */
  36928. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36929. /**
  36930. * Instantiates a new ArcRotateCameraInputsManager.
  36931. * @param camera Defines the camera the inputs belong to
  36932. */
  36933. constructor(camera: ArcRotateCamera);
  36934. /**
  36935. * Add mouse wheel input support to the input manager.
  36936. * @returns the current input manager
  36937. */
  36938. addMouseWheel(): ArcRotateCameraInputsManager;
  36939. /**
  36940. * Add pointers input support to the input manager.
  36941. * @returns the current input manager
  36942. */
  36943. addPointers(): ArcRotateCameraInputsManager;
  36944. /**
  36945. * Add keyboard input support to the input manager.
  36946. * @returns the current input manager
  36947. */
  36948. addKeyboard(): ArcRotateCameraInputsManager;
  36949. }
  36950. }
  36951. declare module "babylonjs/Cameras/arcRotateCamera" {
  36952. import { Observable } from "babylonjs/Misc/observable";
  36953. import { Nullable } from "babylonjs/types";
  36954. import { Scene } from "babylonjs/scene";
  36955. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36957. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36958. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36959. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36960. import { Camera } from "babylonjs/Cameras/camera";
  36961. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36962. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36963. import { Collider } from "babylonjs/Collisions/collider";
  36964. /**
  36965. * This represents an orbital type of camera.
  36966. *
  36967. * 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.
  36968. * 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.
  36969. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36970. */
  36971. export class ArcRotateCamera extends TargetCamera {
  36972. /**
  36973. * Defines the rotation angle of the camera along the longitudinal axis.
  36974. */
  36975. alpha: number;
  36976. /**
  36977. * Defines the rotation angle of the camera along the latitudinal axis.
  36978. */
  36979. beta: number;
  36980. /**
  36981. * Defines the radius of the camera from it s target point.
  36982. */
  36983. radius: number;
  36984. protected _target: Vector3;
  36985. protected _targetHost: Nullable<AbstractMesh>;
  36986. /**
  36987. * Defines the target point of the camera.
  36988. * The camera looks towards it form the radius distance.
  36989. */
  36990. target: Vector3;
  36991. /**
  36992. * Define the current local position of the camera in the scene
  36993. */
  36994. position: Vector3;
  36995. protected _upVector: Vector3;
  36996. protected _upToYMatrix: Matrix;
  36997. protected _YToUpMatrix: Matrix;
  36998. /**
  36999. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37000. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37001. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37002. */
  37003. upVector: Vector3;
  37004. /**
  37005. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37006. */
  37007. setMatUp(): void;
  37008. /**
  37009. * Current inertia value on the longitudinal axis.
  37010. * The bigger this number the longer it will take for the camera to stop.
  37011. */
  37012. inertialAlphaOffset: number;
  37013. /**
  37014. * Current inertia value on the latitudinal axis.
  37015. * The bigger this number the longer it will take for the camera to stop.
  37016. */
  37017. inertialBetaOffset: number;
  37018. /**
  37019. * Current inertia value on the radius axis.
  37020. * The bigger this number the longer it will take for the camera to stop.
  37021. */
  37022. inertialRadiusOffset: number;
  37023. /**
  37024. * Minimum allowed angle on the longitudinal axis.
  37025. * This can help limiting how the Camera is able to move in the scene.
  37026. */
  37027. lowerAlphaLimit: Nullable<number>;
  37028. /**
  37029. * Maximum allowed angle on the longitudinal axis.
  37030. * This can help limiting how the Camera is able to move in the scene.
  37031. */
  37032. upperAlphaLimit: Nullable<number>;
  37033. /**
  37034. * Minimum allowed angle on the latitudinal axis.
  37035. * This can help limiting how the Camera is able to move in the scene.
  37036. */
  37037. lowerBetaLimit: number;
  37038. /**
  37039. * Maximum allowed angle on the latitudinal axis.
  37040. * This can help limiting how the Camera is able to move in the scene.
  37041. */
  37042. upperBetaLimit: number;
  37043. /**
  37044. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37045. * This can help limiting how the Camera is able to move in the scene.
  37046. */
  37047. lowerRadiusLimit: Nullable<number>;
  37048. /**
  37049. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37050. * This can help limiting how the Camera is able to move in the scene.
  37051. */
  37052. upperRadiusLimit: Nullable<number>;
  37053. /**
  37054. * Defines the current inertia value used during panning of the camera along the X axis.
  37055. */
  37056. inertialPanningX: number;
  37057. /**
  37058. * Defines the current inertia value used during panning of the camera along the Y axis.
  37059. */
  37060. inertialPanningY: number;
  37061. /**
  37062. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37063. * Basically if your fingers moves away from more than this distance you will be considered
  37064. * in pinch mode.
  37065. */
  37066. pinchToPanMaxDistance: number;
  37067. /**
  37068. * Defines the maximum distance the camera can pan.
  37069. * This could help keeping the cammera always in your scene.
  37070. */
  37071. panningDistanceLimit: Nullable<number>;
  37072. /**
  37073. * Defines the target of the camera before paning.
  37074. */
  37075. panningOriginTarget: Vector3;
  37076. /**
  37077. * Defines the value of the inertia used during panning.
  37078. * 0 would mean stop inertia and one would mean no decelleration at all.
  37079. */
  37080. panningInertia: number;
  37081. /**
  37082. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37083. */
  37084. angularSensibilityX: number;
  37085. /**
  37086. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37087. */
  37088. angularSensibilityY: number;
  37089. /**
  37090. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37091. */
  37092. pinchPrecision: number;
  37093. /**
  37094. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37095. * It will be used instead of pinchDeltaPrecision if different from 0.
  37096. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37097. */
  37098. pinchDeltaPercentage: number;
  37099. /**
  37100. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37101. */
  37102. panningSensibility: number;
  37103. /**
  37104. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37105. */
  37106. keysUp: number[];
  37107. /**
  37108. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37109. */
  37110. keysDown: number[];
  37111. /**
  37112. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37113. */
  37114. keysLeft: number[];
  37115. /**
  37116. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37117. */
  37118. keysRight: number[];
  37119. /**
  37120. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37121. */
  37122. wheelPrecision: number;
  37123. /**
  37124. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37125. * It will be used instead of pinchDeltaPrecision if different from 0.
  37126. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37127. */
  37128. wheelDeltaPercentage: number;
  37129. /**
  37130. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37131. */
  37132. zoomOnFactor: number;
  37133. /**
  37134. * Defines a screen offset for the camera position.
  37135. */
  37136. targetScreenOffset: Vector2;
  37137. /**
  37138. * Allows the camera to be completely reversed.
  37139. * If false the camera can not arrive upside down.
  37140. */
  37141. allowUpsideDown: boolean;
  37142. /**
  37143. * Define if double tap/click is used to restore the previously saved state of the camera.
  37144. */
  37145. useInputToRestoreState: boolean;
  37146. /** @hidden */
  37147. _viewMatrix: Matrix;
  37148. /** @hidden */
  37149. _useCtrlForPanning: boolean;
  37150. /** @hidden */
  37151. _panningMouseButton: number;
  37152. /**
  37153. * Defines the input associated to the camera.
  37154. */
  37155. inputs: ArcRotateCameraInputsManager;
  37156. /** @hidden */
  37157. _reset: () => void;
  37158. /**
  37159. * Defines the allowed panning axis.
  37160. */
  37161. panningAxis: Vector3;
  37162. protected _localDirection: Vector3;
  37163. protected _transformedDirection: Vector3;
  37164. private _bouncingBehavior;
  37165. /**
  37166. * Gets the bouncing behavior of the camera if it has been enabled.
  37167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37168. */
  37169. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37170. /**
  37171. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37173. */
  37174. useBouncingBehavior: boolean;
  37175. private _framingBehavior;
  37176. /**
  37177. * Gets the framing behavior of the camera if it has been enabled.
  37178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37179. */
  37180. readonly framingBehavior: Nullable<FramingBehavior>;
  37181. /**
  37182. * Defines if the framing behavior of the camera is enabled on the camera.
  37183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37184. */
  37185. useFramingBehavior: boolean;
  37186. private _autoRotationBehavior;
  37187. /**
  37188. * Gets the auto rotation behavior of the camera if it has been enabled.
  37189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37190. */
  37191. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37192. /**
  37193. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37195. */
  37196. useAutoRotationBehavior: boolean;
  37197. /**
  37198. * Observable triggered when the mesh target has been changed on the camera.
  37199. */
  37200. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37201. /**
  37202. * Event raised when the camera is colliding with a mesh.
  37203. */
  37204. onCollide: (collidedMesh: AbstractMesh) => void;
  37205. /**
  37206. * Defines whether the camera should check collision with the objects oh the scene.
  37207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37208. */
  37209. checkCollisions: boolean;
  37210. /**
  37211. * Defines the collision radius of the camera.
  37212. * This simulates a sphere around the camera.
  37213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37214. */
  37215. collisionRadius: Vector3;
  37216. protected _collider: Collider;
  37217. protected _previousPosition: Vector3;
  37218. protected _collisionVelocity: Vector3;
  37219. protected _newPosition: Vector3;
  37220. protected _previousAlpha: number;
  37221. protected _previousBeta: number;
  37222. protected _previousRadius: number;
  37223. protected _collisionTriggered: boolean;
  37224. protected _targetBoundingCenter: Nullable<Vector3>;
  37225. private _computationVector;
  37226. /**
  37227. * Instantiates a new ArcRotateCamera in a given scene
  37228. * @param name Defines the name of the camera
  37229. * @param alpha Defines the camera rotation along the logitudinal axis
  37230. * @param beta Defines the camera rotation along the latitudinal axis
  37231. * @param radius Defines the camera distance from its target
  37232. * @param target Defines the camera target
  37233. * @param scene Defines the scene the camera belongs to
  37234. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37235. */
  37236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37237. /** @hidden */
  37238. _initCache(): void;
  37239. /** @hidden */
  37240. _updateCache(ignoreParentClass?: boolean): void;
  37241. protected _getTargetPosition(): Vector3;
  37242. private _storedAlpha;
  37243. private _storedBeta;
  37244. private _storedRadius;
  37245. private _storedTarget;
  37246. /**
  37247. * Stores the current state of the camera (alpha, beta, radius and target)
  37248. * @returns the camera itself
  37249. */
  37250. storeState(): Camera;
  37251. /**
  37252. * @hidden
  37253. * Restored camera state. You must call storeState() first
  37254. */
  37255. _restoreStateValues(): boolean;
  37256. /** @hidden */
  37257. _isSynchronizedViewMatrix(): boolean;
  37258. /**
  37259. * Attached controls to the current camera.
  37260. * @param element Defines the element the controls should be listened from
  37261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37262. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37263. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37264. */
  37265. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37266. /**
  37267. * Detach the current controls from the camera.
  37268. * The camera will stop reacting to inputs.
  37269. * @param element Defines the element to stop listening the inputs from
  37270. */
  37271. detachControl(element: HTMLElement): void;
  37272. /** @hidden */
  37273. _checkInputs(): void;
  37274. protected _checkLimits(): void;
  37275. /**
  37276. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37277. */
  37278. rebuildAnglesAndRadius(): void;
  37279. /**
  37280. * Use a position to define the current camera related information like aplha, beta and radius
  37281. * @param position Defines the position to set the camera at
  37282. */
  37283. setPosition(position: Vector3): void;
  37284. /**
  37285. * Defines the target the camera should look at.
  37286. * This will automatically adapt alpha beta and radius to fit within the new target.
  37287. * @param target Defines the new target as a Vector or a mesh
  37288. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37289. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37290. */
  37291. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37292. /** @hidden */
  37293. _getViewMatrix(): Matrix;
  37294. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37295. /**
  37296. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37297. * @param meshes Defines the mesh to zoom on
  37298. * @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)
  37299. */
  37300. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37301. /**
  37302. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37303. * The target will be changed but the radius
  37304. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37305. * @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)
  37306. */
  37307. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37308. min: Vector3;
  37309. max: Vector3;
  37310. distance: number;
  37311. }, doNotUpdateMaxZ?: boolean): void;
  37312. /**
  37313. * @override
  37314. * Override Camera.createRigCamera
  37315. */
  37316. createRigCamera(name: string, cameraIndex: number): Camera;
  37317. /**
  37318. * @hidden
  37319. * @override
  37320. * Override Camera._updateRigCameras
  37321. */
  37322. _updateRigCameras(): void;
  37323. /**
  37324. * Destroy the camera and release the current resources hold by it.
  37325. */
  37326. dispose(): void;
  37327. /**
  37328. * Gets the current object class name.
  37329. * @return the class name
  37330. */
  37331. getClassName(): string;
  37332. }
  37333. }
  37334. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37335. import { Behavior } from "babylonjs/Behaviors/behavior";
  37336. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37337. /**
  37338. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37340. */
  37341. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37342. /**
  37343. * Gets the name of the behavior.
  37344. */
  37345. readonly name: string;
  37346. private _zoomStopsAnimation;
  37347. private _idleRotationSpeed;
  37348. private _idleRotationWaitTime;
  37349. private _idleRotationSpinupTime;
  37350. /**
  37351. * Sets the flag that indicates if user zooming should stop animation.
  37352. */
  37353. /**
  37354. * Gets the flag that indicates if user zooming should stop animation.
  37355. */
  37356. zoomStopsAnimation: boolean;
  37357. /**
  37358. * Sets the default speed at which the camera rotates around the model.
  37359. */
  37360. /**
  37361. * Gets the default speed at which the camera rotates around the model.
  37362. */
  37363. idleRotationSpeed: number;
  37364. /**
  37365. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37366. */
  37367. /**
  37368. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37369. */
  37370. idleRotationWaitTime: number;
  37371. /**
  37372. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37373. */
  37374. /**
  37375. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37376. */
  37377. idleRotationSpinupTime: number;
  37378. /**
  37379. * Gets a value indicating if the camera is currently rotating because of this behavior
  37380. */
  37381. readonly rotationInProgress: boolean;
  37382. private _onPrePointerObservableObserver;
  37383. private _onAfterCheckInputsObserver;
  37384. private _attachedCamera;
  37385. private _isPointerDown;
  37386. private _lastFrameTime;
  37387. private _lastInteractionTime;
  37388. private _cameraRotationSpeed;
  37389. /**
  37390. * Initializes the behavior.
  37391. */
  37392. init(): void;
  37393. /**
  37394. * Attaches the behavior to its arc rotate camera.
  37395. * @param camera Defines the camera to attach the behavior to
  37396. */
  37397. attach(camera: ArcRotateCamera): void;
  37398. /**
  37399. * Detaches the behavior from its current arc rotate camera.
  37400. */
  37401. detach(): void;
  37402. /**
  37403. * Returns true if user is scrolling.
  37404. * @return true if user is scrolling.
  37405. */
  37406. private _userIsZooming;
  37407. private _lastFrameRadius;
  37408. private _shouldAnimationStopForInteraction;
  37409. /**
  37410. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37411. */
  37412. private _applyUserInteraction;
  37413. private _userIsMoving;
  37414. }
  37415. }
  37416. declare module "babylonjs/Behaviors/Cameras/index" {
  37417. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37418. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37419. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37420. }
  37421. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37422. import { Mesh } from "babylonjs/Meshes/mesh";
  37423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37424. import { Behavior } from "babylonjs/Behaviors/behavior";
  37425. /**
  37426. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37427. */
  37428. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37429. private ui;
  37430. /**
  37431. * The name of the behavior
  37432. */
  37433. name: string;
  37434. /**
  37435. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37436. */
  37437. distanceAwayFromFace: number;
  37438. /**
  37439. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37440. */
  37441. distanceAwayFromBottomOfFace: number;
  37442. private _faceVectors;
  37443. private _target;
  37444. private _scene;
  37445. private _onRenderObserver;
  37446. private _tmpMatrix;
  37447. private _tmpVector;
  37448. /**
  37449. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37450. * @param ui The transform node that should be attched to the mesh
  37451. */
  37452. constructor(ui: TransformNode);
  37453. /**
  37454. * Initializes the behavior
  37455. */
  37456. init(): void;
  37457. private _closestFace;
  37458. private _zeroVector;
  37459. private _lookAtTmpMatrix;
  37460. private _lookAtToRef;
  37461. /**
  37462. * Attaches the AttachToBoxBehavior to the passed in mesh
  37463. * @param target The mesh that the specified node will be attached to
  37464. */
  37465. attach(target: Mesh): void;
  37466. /**
  37467. * Detaches the behavior from the mesh
  37468. */
  37469. detach(): void;
  37470. }
  37471. }
  37472. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37473. import { Behavior } from "babylonjs/Behaviors/behavior";
  37474. import { Mesh } from "babylonjs/Meshes/mesh";
  37475. /**
  37476. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37477. */
  37478. export class FadeInOutBehavior implements Behavior<Mesh> {
  37479. /**
  37480. * Time in milliseconds to delay before fading in (Default: 0)
  37481. */
  37482. delay: number;
  37483. /**
  37484. * Time in milliseconds for the mesh to fade in (Default: 300)
  37485. */
  37486. fadeInTime: number;
  37487. private _millisecondsPerFrame;
  37488. private _hovered;
  37489. private _hoverValue;
  37490. private _ownerNode;
  37491. /**
  37492. * Instatiates the FadeInOutBehavior
  37493. */
  37494. constructor();
  37495. /**
  37496. * The name of the behavior
  37497. */
  37498. readonly name: string;
  37499. /**
  37500. * Initializes the behavior
  37501. */
  37502. init(): void;
  37503. /**
  37504. * Attaches the fade behavior on the passed in mesh
  37505. * @param ownerNode The mesh that will be faded in/out once attached
  37506. */
  37507. attach(ownerNode: Mesh): void;
  37508. /**
  37509. * Detaches the behavior from the mesh
  37510. */
  37511. detach(): void;
  37512. /**
  37513. * Triggers the mesh to begin fading in or out
  37514. * @param value if the object should fade in or out (true to fade in)
  37515. */
  37516. fadeIn(value: boolean): void;
  37517. private _update;
  37518. private _setAllVisibility;
  37519. }
  37520. }
  37521. declare module "babylonjs/Misc/pivotTools" {
  37522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37523. /**
  37524. * Class containing a set of static utilities functions for managing Pivots
  37525. * @hidden
  37526. */
  37527. export class PivotTools {
  37528. private static _PivotCached;
  37529. private static _OldPivotPoint;
  37530. private static _PivotTranslation;
  37531. private static _PivotTmpVector;
  37532. /** @hidden */
  37533. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37534. /** @hidden */
  37535. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37536. }
  37537. }
  37538. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37539. import { Scene } from "babylonjs/scene";
  37540. import { Vector4 } from "babylonjs/Maths/math.vector";
  37541. import { Mesh } from "babylonjs/Meshes/mesh";
  37542. import { Nullable } from "babylonjs/types";
  37543. import { Plane } from "babylonjs/Maths/math.plane";
  37544. /**
  37545. * Class containing static functions to help procedurally build meshes
  37546. */
  37547. export class PlaneBuilder {
  37548. /**
  37549. * Creates a plane mesh
  37550. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37551. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37552. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37556. * @param name defines the name of the mesh
  37557. * @param options defines the options used to create the mesh
  37558. * @param scene defines the hosting scene
  37559. * @returns the plane mesh
  37560. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37561. */
  37562. static CreatePlane(name: string, options: {
  37563. size?: number;
  37564. width?: number;
  37565. height?: number;
  37566. sideOrientation?: number;
  37567. frontUVs?: Vector4;
  37568. backUVs?: Vector4;
  37569. updatable?: boolean;
  37570. sourcePlane?: Plane;
  37571. }, scene?: Nullable<Scene>): Mesh;
  37572. }
  37573. }
  37574. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37575. import { Behavior } from "babylonjs/Behaviors/behavior";
  37576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37577. import { Observable } from "babylonjs/Misc/observable";
  37578. import { Vector3 } from "babylonjs/Maths/math.vector";
  37579. import { Ray } from "babylonjs/Culling/ray";
  37580. import "babylonjs/Meshes/Builders/planeBuilder";
  37581. /**
  37582. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37583. */
  37584. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37585. private static _AnyMouseID;
  37586. /**
  37587. * Abstract mesh the behavior is set on
  37588. */
  37589. attachedNode: AbstractMesh;
  37590. private _dragPlane;
  37591. private _scene;
  37592. private _pointerObserver;
  37593. private _beforeRenderObserver;
  37594. private static _planeScene;
  37595. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37596. /**
  37597. * 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)
  37598. */
  37599. maxDragAngle: number;
  37600. /**
  37601. * @hidden
  37602. */
  37603. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37604. /**
  37605. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37606. */
  37607. currentDraggingPointerID: number;
  37608. /**
  37609. * The last position where the pointer hit the drag plane in world space
  37610. */
  37611. lastDragPosition: Vector3;
  37612. /**
  37613. * If the behavior is currently in a dragging state
  37614. */
  37615. dragging: boolean;
  37616. /**
  37617. * 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)
  37618. */
  37619. dragDeltaRatio: number;
  37620. /**
  37621. * If the drag plane orientation should be updated during the dragging (Default: true)
  37622. */
  37623. updateDragPlane: boolean;
  37624. private _debugMode;
  37625. private _moving;
  37626. /**
  37627. * Fires each time the attached mesh is dragged with the pointer
  37628. * * delta between last drag position and current drag position in world space
  37629. * * dragDistance along the drag axis
  37630. * * dragPlaneNormal normal of the current drag plane used during the drag
  37631. * * dragPlanePoint in world space where the drag intersects the drag plane
  37632. */
  37633. onDragObservable: Observable<{
  37634. delta: Vector3;
  37635. dragPlanePoint: Vector3;
  37636. dragPlaneNormal: Vector3;
  37637. dragDistance: number;
  37638. pointerId: number;
  37639. }>;
  37640. /**
  37641. * Fires each time a drag begins (eg. mouse down on mesh)
  37642. */
  37643. onDragStartObservable: Observable<{
  37644. dragPlanePoint: Vector3;
  37645. pointerId: number;
  37646. }>;
  37647. /**
  37648. * Fires each time a drag ends (eg. mouse release after drag)
  37649. */
  37650. onDragEndObservable: Observable<{
  37651. dragPlanePoint: Vector3;
  37652. pointerId: number;
  37653. }>;
  37654. /**
  37655. * If the attached mesh should be moved when dragged
  37656. */
  37657. moveAttached: boolean;
  37658. /**
  37659. * If the drag behavior will react to drag events (Default: true)
  37660. */
  37661. enabled: boolean;
  37662. /**
  37663. * If pointer events should start and release the drag (Default: true)
  37664. */
  37665. startAndReleaseDragOnPointerEvents: boolean;
  37666. /**
  37667. * If camera controls should be detached during the drag
  37668. */
  37669. detachCameraControls: boolean;
  37670. /**
  37671. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37672. */
  37673. useObjectOrienationForDragging: boolean;
  37674. private _options;
  37675. /**
  37676. * Creates a pointer drag behavior that can be attached to a mesh
  37677. * @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)
  37678. */
  37679. constructor(options?: {
  37680. dragAxis?: Vector3;
  37681. dragPlaneNormal?: Vector3;
  37682. });
  37683. /**
  37684. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37685. */
  37686. validateDrag: (targetPosition: Vector3) => boolean;
  37687. /**
  37688. * The name of the behavior
  37689. */
  37690. readonly name: string;
  37691. /**
  37692. * Initializes the behavior
  37693. */
  37694. init(): void;
  37695. private _tmpVector;
  37696. private _alternatePickedPoint;
  37697. private _worldDragAxis;
  37698. private _targetPosition;
  37699. private _attachedElement;
  37700. /**
  37701. * Attaches the drag behavior the passed in mesh
  37702. * @param ownerNode The mesh that will be dragged around once attached
  37703. */
  37704. attach(ownerNode: AbstractMesh): void;
  37705. /**
  37706. * Force relase the drag action by code.
  37707. */
  37708. releaseDrag(): void;
  37709. private _startDragRay;
  37710. private _lastPointerRay;
  37711. /**
  37712. * Simulates the start of a pointer drag event on the behavior
  37713. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37714. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37715. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37716. */
  37717. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37718. private _startDrag;
  37719. private _dragDelta;
  37720. private _moveDrag;
  37721. private _pickWithRayOnDragPlane;
  37722. private _pointA;
  37723. private _pointB;
  37724. private _pointC;
  37725. private _lineA;
  37726. private _lineB;
  37727. private _localAxis;
  37728. private _lookAt;
  37729. private _updateDragPlanePosition;
  37730. /**
  37731. * Detaches the behavior from the mesh
  37732. */
  37733. detach(): void;
  37734. }
  37735. }
  37736. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37737. import { Mesh } from "babylonjs/Meshes/mesh";
  37738. import { Behavior } from "babylonjs/Behaviors/behavior";
  37739. /**
  37740. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37741. */
  37742. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37743. private _dragBehaviorA;
  37744. private _dragBehaviorB;
  37745. private _startDistance;
  37746. private _initialScale;
  37747. private _targetScale;
  37748. private _ownerNode;
  37749. private _sceneRenderObserver;
  37750. /**
  37751. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37752. */
  37753. constructor();
  37754. /**
  37755. * The name of the behavior
  37756. */
  37757. readonly name: string;
  37758. /**
  37759. * Initializes the behavior
  37760. */
  37761. init(): void;
  37762. private _getCurrentDistance;
  37763. /**
  37764. * Attaches the scale behavior the passed in mesh
  37765. * @param ownerNode The mesh that will be scaled around once attached
  37766. */
  37767. attach(ownerNode: Mesh): void;
  37768. /**
  37769. * Detaches the behavior from the mesh
  37770. */
  37771. detach(): void;
  37772. }
  37773. }
  37774. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37775. import { Behavior } from "babylonjs/Behaviors/behavior";
  37776. import { Mesh } from "babylonjs/Meshes/mesh";
  37777. import { Observable } from "babylonjs/Misc/observable";
  37778. /**
  37779. * 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
  37780. */
  37781. export class SixDofDragBehavior implements Behavior<Mesh> {
  37782. private static _virtualScene;
  37783. private _ownerNode;
  37784. private _sceneRenderObserver;
  37785. private _scene;
  37786. private _targetPosition;
  37787. private _virtualOriginMesh;
  37788. private _virtualDragMesh;
  37789. private _pointerObserver;
  37790. private _moving;
  37791. private _startingOrientation;
  37792. /**
  37793. * 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)
  37794. */
  37795. private zDragFactor;
  37796. /**
  37797. * If the object should rotate to face the drag origin
  37798. */
  37799. rotateDraggedObject: boolean;
  37800. /**
  37801. * If the behavior is currently in a dragging state
  37802. */
  37803. dragging: boolean;
  37804. /**
  37805. * 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)
  37806. */
  37807. dragDeltaRatio: number;
  37808. /**
  37809. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37810. */
  37811. currentDraggingPointerID: number;
  37812. /**
  37813. * If camera controls should be detached during the drag
  37814. */
  37815. detachCameraControls: boolean;
  37816. /**
  37817. * Fires each time a drag starts
  37818. */
  37819. onDragStartObservable: Observable<{}>;
  37820. /**
  37821. * Fires each time a drag ends (eg. mouse release after drag)
  37822. */
  37823. onDragEndObservable: Observable<{}>;
  37824. /**
  37825. * 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
  37826. */
  37827. constructor();
  37828. /**
  37829. * The name of the behavior
  37830. */
  37831. readonly name: string;
  37832. /**
  37833. * Initializes the behavior
  37834. */
  37835. init(): void;
  37836. /**
  37837. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37838. */
  37839. private readonly _pointerCamera;
  37840. /**
  37841. * Attaches the scale behavior the passed in mesh
  37842. * @param ownerNode The mesh that will be scaled around once attached
  37843. */
  37844. attach(ownerNode: Mesh): void;
  37845. /**
  37846. * Detaches the behavior from the mesh
  37847. */
  37848. detach(): void;
  37849. }
  37850. }
  37851. declare module "babylonjs/Behaviors/Meshes/index" {
  37852. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37853. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37854. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37855. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37856. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37857. }
  37858. declare module "babylonjs/Behaviors/index" {
  37859. export * from "babylonjs/Behaviors/behavior";
  37860. export * from "babylonjs/Behaviors/Cameras/index";
  37861. export * from "babylonjs/Behaviors/Meshes/index";
  37862. }
  37863. declare module "babylonjs/Bones/boneIKController" {
  37864. import { Bone } from "babylonjs/Bones/bone";
  37865. import { Vector3 } from "babylonjs/Maths/math.vector";
  37866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37867. import { Nullable } from "babylonjs/types";
  37868. /**
  37869. * Class used to apply inverse kinematics to bones
  37870. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37871. */
  37872. export class BoneIKController {
  37873. private static _tmpVecs;
  37874. private static _tmpQuat;
  37875. private static _tmpMats;
  37876. /**
  37877. * Gets or sets the target mesh
  37878. */
  37879. targetMesh: AbstractMesh;
  37880. /** Gets or sets the mesh used as pole */
  37881. poleTargetMesh: AbstractMesh;
  37882. /**
  37883. * Gets or sets the bone used as pole
  37884. */
  37885. poleTargetBone: Nullable<Bone>;
  37886. /**
  37887. * Gets or sets the target position
  37888. */
  37889. targetPosition: Vector3;
  37890. /**
  37891. * Gets or sets the pole target position
  37892. */
  37893. poleTargetPosition: Vector3;
  37894. /**
  37895. * Gets or sets the pole target local offset
  37896. */
  37897. poleTargetLocalOffset: Vector3;
  37898. /**
  37899. * Gets or sets the pole angle
  37900. */
  37901. poleAngle: number;
  37902. /**
  37903. * Gets or sets the mesh associated with the controller
  37904. */
  37905. mesh: AbstractMesh;
  37906. /**
  37907. * 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)
  37908. */
  37909. slerpAmount: number;
  37910. private _bone1Quat;
  37911. private _bone1Mat;
  37912. private _bone2Ang;
  37913. private _bone1;
  37914. private _bone2;
  37915. private _bone1Length;
  37916. private _bone2Length;
  37917. private _maxAngle;
  37918. private _maxReach;
  37919. private _rightHandedSystem;
  37920. private _bendAxis;
  37921. private _slerping;
  37922. private _adjustRoll;
  37923. /**
  37924. * Gets or sets maximum allowed angle
  37925. */
  37926. maxAngle: number;
  37927. /**
  37928. * Creates a new BoneIKController
  37929. * @param mesh defines the mesh to control
  37930. * @param bone defines the bone to control
  37931. * @param options defines options to set up the controller
  37932. */
  37933. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37934. targetMesh?: AbstractMesh;
  37935. poleTargetMesh?: AbstractMesh;
  37936. poleTargetBone?: Bone;
  37937. poleTargetLocalOffset?: Vector3;
  37938. poleAngle?: number;
  37939. bendAxis?: Vector3;
  37940. maxAngle?: number;
  37941. slerpAmount?: number;
  37942. });
  37943. private _setMaxAngle;
  37944. /**
  37945. * Force the controller to update the bones
  37946. */
  37947. update(): void;
  37948. }
  37949. }
  37950. declare module "babylonjs/Bones/boneLookController" {
  37951. import { Vector3 } from "babylonjs/Maths/math.vector";
  37952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37953. import { Bone } from "babylonjs/Bones/bone";
  37954. import { Space } from "babylonjs/Maths/math.axis";
  37955. /**
  37956. * Class used to make a bone look toward a point in space
  37957. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37958. */
  37959. export class BoneLookController {
  37960. private static _tmpVecs;
  37961. private static _tmpQuat;
  37962. private static _tmpMats;
  37963. /**
  37964. * The target Vector3 that the bone will look at
  37965. */
  37966. target: Vector3;
  37967. /**
  37968. * The mesh that the bone is attached to
  37969. */
  37970. mesh: AbstractMesh;
  37971. /**
  37972. * The bone that will be looking to the target
  37973. */
  37974. bone: Bone;
  37975. /**
  37976. * The up axis of the coordinate system that is used when the bone is rotated
  37977. */
  37978. upAxis: Vector3;
  37979. /**
  37980. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37981. */
  37982. upAxisSpace: Space;
  37983. /**
  37984. * Used to make an adjustment to the yaw of the bone
  37985. */
  37986. adjustYaw: number;
  37987. /**
  37988. * Used to make an adjustment to the pitch of the bone
  37989. */
  37990. adjustPitch: number;
  37991. /**
  37992. * Used to make an adjustment to the roll of the bone
  37993. */
  37994. adjustRoll: number;
  37995. /**
  37996. * 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)
  37997. */
  37998. slerpAmount: number;
  37999. private _minYaw;
  38000. private _maxYaw;
  38001. private _minPitch;
  38002. private _maxPitch;
  38003. private _minYawSin;
  38004. private _minYawCos;
  38005. private _maxYawSin;
  38006. private _maxYawCos;
  38007. private _midYawConstraint;
  38008. private _minPitchTan;
  38009. private _maxPitchTan;
  38010. private _boneQuat;
  38011. private _slerping;
  38012. private _transformYawPitch;
  38013. private _transformYawPitchInv;
  38014. private _firstFrameSkipped;
  38015. private _yawRange;
  38016. private _fowardAxis;
  38017. /**
  38018. * Gets or sets the minimum yaw angle that the bone can look to
  38019. */
  38020. minYaw: number;
  38021. /**
  38022. * Gets or sets the maximum yaw angle that the bone can look to
  38023. */
  38024. maxYaw: number;
  38025. /**
  38026. * Gets or sets the minimum pitch angle that the bone can look to
  38027. */
  38028. minPitch: number;
  38029. /**
  38030. * Gets or sets the maximum pitch angle that the bone can look to
  38031. */
  38032. maxPitch: number;
  38033. /**
  38034. * Create a BoneLookController
  38035. * @param mesh the mesh that the bone belongs to
  38036. * @param bone the bone that will be looking to the target
  38037. * @param target the target Vector3 to look at
  38038. * @param options optional settings:
  38039. * * maxYaw: the maximum angle the bone will yaw to
  38040. * * minYaw: the minimum angle the bone will yaw to
  38041. * * maxPitch: the maximum angle the bone will pitch to
  38042. * * minPitch: the minimum angle the bone will yaw to
  38043. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38044. * * upAxis: the up axis of the coordinate system
  38045. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38046. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38047. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38048. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38049. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38050. * * adjustRoll: used to make an adjustment to the roll of the bone
  38051. **/
  38052. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38053. maxYaw?: number;
  38054. minYaw?: number;
  38055. maxPitch?: number;
  38056. minPitch?: number;
  38057. slerpAmount?: number;
  38058. upAxis?: Vector3;
  38059. upAxisSpace?: Space;
  38060. yawAxis?: Vector3;
  38061. pitchAxis?: Vector3;
  38062. adjustYaw?: number;
  38063. adjustPitch?: number;
  38064. adjustRoll?: number;
  38065. });
  38066. /**
  38067. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38068. */
  38069. update(): void;
  38070. private _getAngleDiff;
  38071. private _getAngleBetween;
  38072. private _isAngleBetween;
  38073. }
  38074. }
  38075. declare module "babylonjs/Bones/index" {
  38076. export * from "babylonjs/Bones/bone";
  38077. export * from "babylonjs/Bones/boneIKController";
  38078. export * from "babylonjs/Bones/boneLookController";
  38079. export * from "babylonjs/Bones/skeleton";
  38080. }
  38081. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38082. import { Nullable } from "babylonjs/types";
  38083. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38084. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38085. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38086. /**
  38087. * Manage the gamepad inputs to control an arc rotate camera.
  38088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38089. */
  38090. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38091. /**
  38092. * Defines the camera the input is attached to.
  38093. */
  38094. camera: ArcRotateCamera;
  38095. /**
  38096. * Defines the gamepad the input is gathering event from.
  38097. */
  38098. gamepad: Nullable<Gamepad>;
  38099. /**
  38100. * Defines the gamepad rotation sensiblity.
  38101. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38102. */
  38103. gamepadRotationSensibility: number;
  38104. /**
  38105. * Defines the gamepad move sensiblity.
  38106. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38107. */
  38108. gamepadMoveSensibility: number;
  38109. private _onGamepadConnectedObserver;
  38110. private _onGamepadDisconnectedObserver;
  38111. /**
  38112. * Attach the input controls to a specific dom element to get the input from.
  38113. * @param element Defines the element the controls should be listened from
  38114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38115. */
  38116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38117. /**
  38118. * Detach the current controls from the specified dom element.
  38119. * @param element Defines the element to stop listening the inputs from
  38120. */
  38121. detachControl(element: Nullable<HTMLElement>): void;
  38122. /**
  38123. * Update the current camera state depending on the inputs that have been used this frame.
  38124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38125. */
  38126. checkInputs(): void;
  38127. /**
  38128. * Gets the class name of the current intput.
  38129. * @returns the class name
  38130. */
  38131. getClassName(): string;
  38132. /**
  38133. * Get the friendly name associated with the input class.
  38134. * @returns the input friendly name
  38135. */
  38136. getSimpleName(): string;
  38137. }
  38138. }
  38139. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38140. import { Nullable } from "babylonjs/types";
  38141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38142. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38143. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38144. interface ArcRotateCameraInputsManager {
  38145. /**
  38146. * Add orientation input support to the input manager.
  38147. * @returns the current input manager
  38148. */
  38149. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38150. }
  38151. }
  38152. /**
  38153. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38155. */
  38156. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38157. /**
  38158. * Defines the camera the input is attached to.
  38159. */
  38160. camera: ArcRotateCamera;
  38161. /**
  38162. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38163. */
  38164. alphaCorrection: number;
  38165. /**
  38166. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38167. */
  38168. gammaCorrection: number;
  38169. private _alpha;
  38170. private _gamma;
  38171. private _dirty;
  38172. private _deviceOrientationHandler;
  38173. /**
  38174. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38175. */
  38176. constructor();
  38177. /**
  38178. * Attach the input controls to a specific dom element to get the input from.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. */
  38182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38183. /** @hidden */
  38184. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38185. /**
  38186. * Update the current camera state depending on the inputs that have been used this frame.
  38187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38188. */
  38189. checkInputs(): void;
  38190. /**
  38191. * Detach the current controls from the specified dom element.
  38192. * @param element Defines the element to stop listening the inputs from
  38193. */
  38194. detachControl(element: Nullable<HTMLElement>): void;
  38195. /**
  38196. * Gets the class name of the current intput.
  38197. * @returns the class name
  38198. */
  38199. getClassName(): string;
  38200. /**
  38201. * Get the friendly name associated with the input class.
  38202. * @returns the input friendly name
  38203. */
  38204. getSimpleName(): string;
  38205. }
  38206. }
  38207. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38208. import { Nullable } from "babylonjs/types";
  38209. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38210. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38211. /**
  38212. * Listen to mouse events to control the camera.
  38213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38214. */
  38215. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38216. /**
  38217. * Defines the camera the input is attached to.
  38218. */
  38219. camera: FlyCamera;
  38220. /**
  38221. * Defines if touch is enabled. (Default is true.)
  38222. */
  38223. touchEnabled: boolean;
  38224. /**
  38225. * Defines the buttons associated with the input to handle camera rotation.
  38226. */
  38227. buttons: number[];
  38228. /**
  38229. * Assign buttons for Yaw control.
  38230. */
  38231. buttonsYaw: number[];
  38232. /**
  38233. * Assign buttons for Pitch control.
  38234. */
  38235. buttonsPitch: number[];
  38236. /**
  38237. * Assign buttons for Roll control.
  38238. */
  38239. buttonsRoll: number[];
  38240. /**
  38241. * Detect if any button is being pressed while mouse is moved.
  38242. * -1 = Mouse locked.
  38243. * 0 = Left button.
  38244. * 1 = Middle Button.
  38245. * 2 = Right Button.
  38246. */
  38247. activeButton: number;
  38248. /**
  38249. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38250. * Higher values reduce its sensitivity.
  38251. */
  38252. angularSensibility: number;
  38253. private _mousemoveCallback;
  38254. private _observer;
  38255. private _rollObserver;
  38256. private previousPosition;
  38257. private noPreventDefault;
  38258. private element;
  38259. /**
  38260. * Listen to mouse events to control the camera.
  38261. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38263. */
  38264. constructor(touchEnabled?: boolean);
  38265. /**
  38266. * Attach the mouse control to the HTML DOM element.
  38267. * @param element Defines the element that listens to the input events.
  38268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38269. */
  38270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38271. /**
  38272. * Detach the current controls from the specified dom element.
  38273. * @param element Defines the element to stop listening the inputs from
  38274. */
  38275. detachControl(element: Nullable<HTMLElement>): void;
  38276. /**
  38277. * Gets the class name of the current input.
  38278. * @returns the class name.
  38279. */
  38280. getClassName(): string;
  38281. /**
  38282. * Get the friendly name associated with the input class.
  38283. * @returns the input's friendly name.
  38284. */
  38285. getSimpleName(): string;
  38286. private _pointerInput;
  38287. private _onMouseMove;
  38288. /**
  38289. * Rotate camera by mouse offset.
  38290. */
  38291. private rotateCamera;
  38292. }
  38293. }
  38294. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38295. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38296. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38297. /**
  38298. * Default Inputs manager for the FlyCamera.
  38299. * It groups all the default supported inputs for ease of use.
  38300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38301. */
  38302. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38303. /**
  38304. * Instantiates a new FlyCameraInputsManager.
  38305. * @param camera Defines the camera the inputs belong to.
  38306. */
  38307. constructor(camera: FlyCamera);
  38308. /**
  38309. * Add keyboard input support to the input manager.
  38310. * @returns the new FlyCameraKeyboardMoveInput().
  38311. */
  38312. addKeyboard(): FlyCameraInputsManager;
  38313. /**
  38314. * Add mouse input support to the input manager.
  38315. * @param touchEnabled Enable touch screen support.
  38316. * @returns the new FlyCameraMouseInput().
  38317. */
  38318. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38319. }
  38320. }
  38321. declare module "babylonjs/Cameras/flyCamera" {
  38322. import { Scene } from "babylonjs/scene";
  38323. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38325. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38326. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38327. /**
  38328. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38329. * such as in a 3D Space Shooter or a Flight Simulator.
  38330. */
  38331. export class FlyCamera extends TargetCamera {
  38332. /**
  38333. * Define the collision ellipsoid of the camera.
  38334. * This is helpful for simulating a camera body, like a player's body.
  38335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38336. */
  38337. ellipsoid: Vector3;
  38338. /**
  38339. * Define an offset for the position of the ellipsoid around the camera.
  38340. * This can be helpful if the camera is attached away from the player's body center,
  38341. * such as at its head.
  38342. */
  38343. ellipsoidOffset: Vector3;
  38344. /**
  38345. * Enable or disable collisions of the camera with the rest of the scene objects.
  38346. */
  38347. checkCollisions: boolean;
  38348. /**
  38349. * Enable or disable gravity on the camera.
  38350. */
  38351. applyGravity: boolean;
  38352. /**
  38353. * Define the current direction the camera is moving to.
  38354. */
  38355. cameraDirection: Vector3;
  38356. /**
  38357. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38358. * This overrides and empties cameraRotation.
  38359. */
  38360. rotationQuaternion: Quaternion;
  38361. /**
  38362. * Track Roll to maintain the wanted Rolling when looking around.
  38363. */
  38364. _trackRoll: number;
  38365. /**
  38366. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38367. */
  38368. rollCorrect: number;
  38369. /**
  38370. * Mimic a banked turn, Rolling the camera when Yawing.
  38371. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38372. */
  38373. bankedTurn: boolean;
  38374. /**
  38375. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38376. */
  38377. bankedTurnLimit: number;
  38378. /**
  38379. * Value of 0 disables the banked Roll.
  38380. * Value of 1 is equal to the Yaw angle in radians.
  38381. */
  38382. bankedTurnMultiplier: number;
  38383. /**
  38384. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38385. */
  38386. inputs: FlyCameraInputsManager;
  38387. /**
  38388. * Gets the input sensibility for mouse input.
  38389. * Higher values reduce sensitivity.
  38390. */
  38391. /**
  38392. * Sets the input sensibility for a mouse input.
  38393. * Higher values reduce sensitivity.
  38394. */
  38395. angularSensibility: number;
  38396. /**
  38397. * Get the keys for camera movement forward.
  38398. */
  38399. /**
  38400. * Set the keys for camera movement forward.
  38401. */
  38402. keysForward: number[];
  38403. /**
  38404. * Get the keys for camera movement backward.
  38405. */
  38406. keysBackward: number[];
  38407. /**
  38408. * Get the keys for camera movement up.
  38409. */
  38410. /**
  38411. * Set the keys for camera movement up.
  38412. */
  38413. keysUp: number[];
  38414. /**
  38415. * Get the keys for camera movement down.
  38416. */
  38417. /**
  38418. * Set the keys for camera movement down.
  38419. */
  38420. keysDown: number[];
  38421. /**
  38422. * Get the keys for camera movement left.
  38423. */
  38424. /**
  38425. * Set the keys for camera movement left.
  38426. */
  38427. keysLeft: number[];
  38428. /**
  38429. * Set the keys for camera movement right.
  38430. */
  38431. /**
  38432. * Set the keys for camera movement right.
  38433. */
  38434. keysRight: number[];
  38435. /**
  38436. * Event raised when the camera collides with a mesh in the scene.
  38437. */
  38438. onCollide: (collidedMesh: AbstractMesh) => void;
  38439. private _collider;
  38440. private _needMoveForGravity;
  38441. private _oldPosition;
  38442. private _diffPosition;
  38443. private _newPosition;
  38444. /** @hidden */
  38445. _localDirection: Vector3;
  38446. /** @hidden */
  38447. _transformedDirection: Vector3;
  38448. /**
  38449. * Instantiates a FlyCamera.
  38450. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38451. * such as in a 3D Space Shooter or a Flight Simulator.
  38452. * @param name Define the name of the camera in the scene.
  38453. * @param position Define the starting position of the camera in the scene.
  38454. * @param scene Define the scene the camera belongs to.
  38455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38456. */
  38457. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38458. /**
  38459. * Attach a control to the HTML DOM element.
  38460. * @param element Defines the element that listens to the input events.
  38461. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38462. */
  38463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38464. /**
  38465. * Detach a control from the HTML DOM element.
  38466. * The camera will stop reacting to that input.
  38467. * @param element Defines the element that listens to the input events.
  38468. */
  38469. detachControl(element: HTMLElement): void;
  38470. private _collisionMask;
  38471. /**
  38472. * Get the mask that the camera ignores in collision events.
  38473. */
  38474. /**
  38475. * Set the mask that the camera ignores in collision events.
  38476. */
  38477. collisionMask: number;
  38478. /** @hidden */
  38479. _collideWithWorld(displacement: Vector3): void;
  38480. /** @hidden */
  38481. private _onCollisionPositionChange;
  38482. /** @hidden */
  38483. _checkInputs(): void;
  38484. /** @hidden */
  38485. _decideIfNeedsToMove(): boolean;
  38486. /** @hidden */
  38487. _updatePosition(): void;
  38488. /**
  38489. * Restore the Roll to its target value at the rate specified.
  38490. * @param rate - Higher means slower restoring.
  38491. * @hidden
  38492. */
  38493. restoreRoll(rate: number): void;
  38494. /**
  38495. * Destroy the camera and release the current resources held by it.
  38496. */
  38497. dispose(): void;
  38498. /**
  38499. * Get the current object class name.
  38500. * @returns the class name.
  38501. */
  38502. getClassName(): string;
  38503. }
  38504. }
  38505. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38506. import { Nullable } from "babylonjs/types";
  38507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38508. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38509. /**
  38510. * Listen to keyboard events to control the camera.
  38511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38512. */
  38513. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38514. /**
  38515. * Defines the camera the input is attached to.
  38516. */
  38517. camera: FlyCamera;
  38518. /**
  38519. * The list of keyboard keys used to control the forward move of the camera.
  38520. */
  38521. keysForward: number[];
  38522. /**
  38523. * The list of keyboard keys used to control the backward move of the camera.
  38524. */
  38525. keysBackward: number[];
  38526. /**
  38527. * The list of keyboard keys used to control the forward move of the camera.
  38528. */
  38529. keysUp: number[];
  38530. /**
  38531. * The list of keyboard keys used to control the backward move of the camera.
  38532. */
  38533. keysDown: number[];
  38534. /**
  38535. * The list of keyboard keys used to control the right strafe move of the camera.
  38536. */
  38537. keysRight: number[];
  38538. /**
  38539. * The list of keyboard keys used to control the left strafe move of the camera.
  38540. */
  38541. keysLeft: number[];
  38542. private _keys;
  38543. private _onCanvasBlurObserver;
  38544. private _onKeyboardObserver;
  38545. private _engine;
  38546. private _scene;
  38547. /**
  38548. * Attach the input controls to a specific dom element to get the input from.
  38549. * @param element Defines the element the controls should be listened from
  38550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38551. */
  38552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38553. /**
  38554. * Detach the current controls from the specified dom element.
  38555. * @param element Defines the element to stop listening the inputs from
  38556. */
  38557. detachControl(element: Nullable<HTMLElement>): void;
  38558. /**
  38559. * Gets the class name of the current intput.
  38560. * @returns the class name
  38561. */
  38562. getClassName(): string;
  38563. /** @hidden */
  38564. _onLostFocus(e: FocusEvent): void;
  38565. /**
  38566. * Get the friendly name associated with the input class.
  38567. * @returns the input friendly name
  38568. */
  38569. getSimpleName(): string;
  38570. /**
  38571. * Update the current camera state depending on the inputs that have been used this frame.
  38572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38573. */
  38574. checkInputs(): void;
  38575. }
  38576. }
  38577. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38578. import { Nullable } from "babylonjs/types";
  38579. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38580. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38581. /**
  38582. * Manage the mouse wheel inputs to control a follow camera.
  38583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38584. */
  38585. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38586. /**
  38587. * Defines the camera the input is attached to.
  38588. */
  38589. camera: FollowCamera;
  38590. /**
  38591. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38592. */
  38593. axisControlRadius: boolean;
  38594. /**
  38595. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38596. */
  38597. axisControlHeight: boolean;
  38598. /**
  38599. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38600. */
  38601. axisControlRotation: boolean;
  38602. /**
  38603. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38604. * relation to mouseWheel events.
  38605. */
  38606. wheelPrecision: number;
  38607. /**
  38608. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38609. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38610. */
  38611. wheelDeltaPercentage: number;
  38612. private _wheel;
  38613. private _observer;
  38614. /**
  38615. * Attach the input controls to a specific dom element to get the input from.
  38616. * @param element Defines the element the controls should be listened from
  38617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38618. */
  38619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38620. /**
  38621. * Detach the current controls from the specified dom element.
  38622. * @param element Defines the element to stop listening the inputs from
  38623. */
  38624. detachControl(element: Nullable<HTMLElement>): void;
  38625. /**
  38626. * Gets the class name of the current intput.
  38627. * @returns the class name
  38628. */
  38629. getClassName(): string;
  38630. /**
  38631. * Get the friendly name associated with the input class.
  38632. * @returns the input friendly name
  38633. */
  38634. getSimpleName(): string;
  38635. }
  38636. }
  38637. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38638. import { Nullable } from "babylonjs/types";
  38639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38640. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38641. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38642. /**
  38643. * Manage the pointers inputs to control an follow camera.
  38644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38645. */
  38646. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38647. /**
  38648. * Defines the camera the input is attached to.
  38649. */
  38650. camera: FollowCamera;
  38651. /**
  38652. * Gets the class name of the current input.
  38653. * @returns the class name
  38654. */
  38655. getClassName(): string;
  38656. /**
  38657. * Defines the pointer angular sensibility along the X axis or how fast is
  38658. * the camera rotating.
  38659. * A negative number will reverse the axis direction.
  38660. */
  38661. angularSensibilityX: number;
  38662. /**
  38663. * Defines the pointer angular sensibility along the Y axis or how fast is
  38664. * the camera rotating.
  38665. * A negative number will reverse the axis direction.
  38666. */
  38667. angularSensibilityY: number;
  38668. /**
  38669. * Defines the pointer pinch precision or how fast is the camera zooming.
  38670. * A negative number will reverse the axis direction.
  38671. */
  38672. pinchPrecision: number;
  38673. /**
  38674. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38675. * from 0.
  38676. * It defines the percentage of current camera.radius to use as delta when
  38677. * pinch zoom is used.
  38678. */
  38679. pinchDeltaPercentage: number;
  38680. /**
  38681. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38682. */
  38683. axisXControlRadius: boolean;
  38684. /**
  38685. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38686. */
  38687. axisXControlHeight: boolean;
  38688. /**
  38689. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38690. */
  38691. axisXControlRotation: boolean;
  38692. /**
  38693. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38694. */
  38695. axisYControlRadius: boolean;
  38696. /**
  38697. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38698. */
  38699. axisYControlHeight: boolean;
  38700. /**
  38701. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38702. */
  38703. axisYControlRotation: boolean;
  38704. /**
  38705. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38706. */
  38707. axisPinchControlRadius: boolean;
  38708. /**
  38709. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38710. */
  38711. axisPinchControlHeight: boolean;
  38712. /**
  38713. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38714. */
  38715. axisPinchControlRotation: boolean;
  38716. /**
  38717. * Log error messages if basic misconfiguration has occurred.
  38718. */
  38719. warningEnable: boolean;
  38720. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38721. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38722. private _warningCounter;
  38723. private _warning;
  38724. }
  38725. }
  38726. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38727. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38728. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38729. /**
  38730. * Default Inputs manager for the FollowCamera.
  38731. * It groups all the default supported inputs for ease of use.
  38732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38733. */
  38734. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38735. /**
  38736. * Instantiates a new FollowCameraInputsManager.
  38737. * @param camera Defines the camera the inputs belong to
  38738. */
  38739. constructor(camera: FollowCamera);
  38740. /**
  38741. * Add keyboard input support to the input manager.
  38742. * @returns the current input manager
  38743. */
  38744. addKeyboard(): FollowCameraInputsManager;
  38745. /**
  38746. * Add mouse wheel input support to the input manager.
  38747. * @returns the current input manager
  38748. */
  38749. addMouseWheel(): FollowCameraInputsManager;
  38750. /**
  38751. * Add pointers input support to the input manager.
  38752. * @returns the current input manager
  38753. */
  38754. addPointers(): FollowCameraInputsManager;
  38755. /**
  38756. * Add orientation input support to the input manager.
  38757. * @returns the current input manager
  38758. */
  38759. addVRDeviceOrientation(): FollowCameraInputsManager;
  38760. }
  38761. }
  38762. declare module "babylonjs/Cameras/followCamera" {
  38763. import { Nullable } from "babylonjs/types";
  38764. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38765. import { Scene } from "babylonjs/scene";
  38766. import { Vector3 } from "babylonjs/Maths/math.vector";
  38767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38768. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38769. /**
  38770. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38771. * an arc rotate version arcFollowCamera are available.
  38772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38773. */
  38774. export class FollowCamera extends TargetCamera {
  38775. /**
  38776. * Distance the follow camera should follow an object at
  38777. */
  38778. radius: number;
  38779. /**
  38780. * Minimum allowed distance of the camera to the axis of rotation
  38781. * (The camera can not get closer).
  38782. * This can help limiting how the Camera is able to move in the scene.
  38783. */
  38784. lowerRadiusLimit: Nullable<number>;
  38785. /**
  38786. * Maximum allowed distance of the camera to the axis of rotation
  38787. * (The camera can not get further).
  38788. * This can help limiting how the Camera is able to move in the scene.
  38789. */
  38790. upperRadiusLimit: Nullable<number>;
  38791. /**
  38792. * Define a rotation offset between the camera and the object it follows
  38793. */
  38794. rotationOffset: number;
  38795. /**
  38796. * Minimum allowed angle to camera position relative to target object.
  38797. * This can help limiting how the Camera is able to move in the scene.
  38798. */
  38799. lowerRotationOffsetLimit: Nullable<number>;
  38800. /**
  38801. * Maximum allowed angle to camera position relative to target object.
  38802. * This can help limiting how the Camera is able to move in the scene.
  38803. */
  38804. upperRotationOffsetLimit: Nullable<number>;
  38805. /**
  38806. * Define a height offset between the camera and the object it follows.
  38807. * It can help following an object from the top (like a car chaing a plane)
  38808. */
  38809. heightOffset: number;
  38810. /**
  38811. * Minimum allowed height of camera position relative to target object.
  38812. * This can help limiting how the Camera is able to move in the scene.
  38813. */
  38814. lowerHeightOffsetLimit: Nullable<number>;
  38815. /**
  38816. * Maximum allowed height of camera position relative to target object.
  38817. * This can help limiting how the Camera is able to move in the scene.
  38818. */
  38819. upperHeightOffsetLimit: Nullable<number>;
  38820. /**
  38821. * Define how fast the camera can accelerate to follow it s target.
  38822. */
  38823. cameraAcceleration: number;
  38824. /**
  38825. * Define the speed limit of the camera following an object.
  38826. */
  38827. maxCameraSpeed: number;
  38828. /**
  38829. * Define the target of the camera.
  38830. */
  38831. lockedTarget: Nullable<AbstractMesh>;
  38832. /**
  38833. * Defines the input associated with the camera.
  38834. */
  38835. inputs: FollowCameraInputsManager;
  38836. /**
  38837. * Instantiates the follow camera.
  38838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38839. * @param name Define the name of the camera in the scene
  38840. * @param position Define the position of the camera
  38841. * @param scene Define the scene the camera belong to
  38842. * @param lockedTarget Define the target of the camera
  38843. */
  38844. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38845. private _follow;
  38846. /**
  38847. * Attached controls to the current camera.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the camera.
  38854. * The camera will stop reacting to inputs.
  38855. * @param element Defines the element to stop listening the inputs from
  38856. */
  38857. detachControl(element: HTMLElement): void;
  38858. /** @hidden */
  38859. _checkInputs(): void;
  38860. private _checkLimits;
  38861. /**
  38862. * Gets the camera class name.
  38863. * @returns the class name
  38864. */
  38865. getClassName(): string;
  38866. }
  38867. /**
  38868. * Arc Rotate version of the follow camera.
  38869. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38870. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38871. */
  38872. export class ArcFollowCamera extends TargetCamera {
  38873. /** The longitudinal angle of the camera */
  38874. alpha: number;
  38875. /** The latitudinal angle of the camera */
  38876. beta: number;
  38877. /** The radius of the camera from its target */
  38878. radius: number;
  38879. /** Define the camera target (the messh it should follow) */
  38880. target: Nullable<AbstractMesh>;
  38881. private _cartesianCoordinates;
  38882. /**
  38883. * Instantiates a new ArcFollowCamera
  38884. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38885. * @param name Define the name of the camera
  38886. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38887. * @param beta Define the rotation angle of the camera around the elevation axis
  38888. * @param radius Define the radius of the camera from its target point
  38889. * @param target Define the target of the camera
  38890. * @param scene Define the scene the camera belongs to
  38891. */
  38892. constructor(name: string,
  38893. /** The longitudinal angle of the camera */
  38894. alpha: number,
  38895. /** The latitudinal angle of the camera */
  38896. beta: number,
  38897. /** The radius of the camera from its target */
  38898. radius: number,
  38899. /** Define the camera target (the messh it should follow) */
  38900. target: Nullable<AbstractMesh>, scene: Scene);
  38901. private _follow;
  38902. /** @hidden */
  38903. _checkInputs(): void;
  38904. /**
  38905. * Returns the class name of the object.
  38906. * It is mostly used internally for serialization purposes.
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38913. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38914. import { Nullable } from "babylonjs/types";
  38915. /**
  38916. * Manage the keyboard inputs to control the movement of a follow camera.
  38917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38918. */
  38919. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38920. /**
  38921. * Defines the camera the input is attached to.
  38922. */
  38923. camera: FollowCamera;
  38924. /**
  38925. * Defines the list of key codes associated with the up action (increase heightOffset)
  38926. */
  38927. keysHeightOffsetIncr: number[];
  38928. /**
  38929. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38930. */
  38931. keysHeightOffsetDecr: number[];
  38932. /**
  38933. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38934. */
  38935. keysHeightOffsetModifierAlt: boolean;
  38936. /**
  38937. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38938. */
  38939. keysHeightOffsetModifierCtrl: boolean;
  38940. /**
  38941. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38942. */
  38943. keysHeightOffsetModifierShift: boolean;
  38944. /**
  38945. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38946. */
  38947. keysRotationOffsetIncr: number[];
  38948. /**
  38949. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38950. */
  38951. keysRotationOffsetDecr: number[];
  38952. /**
  38953. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38954. */
  38955. keysRotationOffsetModifierAlt: boolean;
  38956. /**
  38957. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38958. */
  38959. keysRotationOffsetModifierCtrl: boolean;
  38960. /**
  38961. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38962. */
  38963. keysRotationOffsetModifierShift: boolean;
  38964. /**
  38965. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38966. */
  38967. keysRadiusIncr: number[];
  38968. /**
  38969. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38970. */
  38971. keysRadiusDecr: number[];
  38972. /**
  38973. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38974. */
  38975. keysRadiusModifierAlt: boolean;
  38976. /**
  38977. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38978. */
  38979. keysRadiusModifierCtrl: boolean;
  38980. /**
  38981. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38982. */
  38983. keysRadiusModifierShift: boolean;
  38984. /**
  38985. * Defines the rate of change of heightOffset.
  38986. */
  38987. heightSensibility: number;
  38988. /**
  38989. * Defines the rate of change of rotationOffset.
  38990. */
  38991. rotationSensibility: number;
  38992. /**
  38993. * Defines the rate of change of radius.
  38994. */
  38995. radiusSensibility: number;
  38996. private _keys;
  38997. private _ctrlPressed;
  38998. private _altPressed;
  38999. private _shiftPressed;
  39000. private _onCanvasBlurObserver;
  39001. private _onKeyboardObserver;
  39002. private _engine;
  39003. private _scene;
  39004. /**
  39005. * Attach the input controls to a specific dom element to get the input from.
  39006. * @param element Defines the element the controls should be listened from
  39007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39008. */
  39009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39010. /**
  39011. * Detach the current controls from the specified dom element.
  39012. * @param element Defines the element to stop listening the inputs from
  39013. */
  39014. detachControl(element: Nullable<HTMLElement>): void;
  39015. /**
  39016. * Update the current camera state depending on the inputs that have been used this frame.
  39017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39018. */
  39019. checkInputs(): void;
  39020. /**
  39021. * Gets the class name of the current input.
  39022. * @returns the class name
  39023. */
  39024. getClassName(): string;
  39025. /**
  39026. * Get the friendly name associated with the input class.
  39027. * @returns the input friendly name
  39028. */
  39029. getSimpleName(): string;
  39030. /**
  39031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39032. * allow modification of the heightOffset value.
  39033. */
  39034. private _modifierHeightOffset;
  39035. /**
  39036. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39037. * allow modification of the rotationOffset value.
  39038. */
  39039. private _modifierRotationOffset;
  39040. /**
  39041. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39042. * allow modification of the radius value.
  39043. */
  39044. private _modifierRadius;
  39045. }
  39046. }
  39047. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39048. import { Nullable } from "babylonjs/types";
  39049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39051. import { Observable } from "babylonjs/Misc/observable";
  39052. module "babylonjs/Cameras/freeCameraInputsManager" {
  39053. interface FreeCameraInputsManager {
  39054. /**
  39055. * @hidden
  39056. */
  39057. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39058. /**
  39059. * Add orientation input support to the input manager.
  39060. * @returns the current input manager
  39061. */
  39062. addDeviceOrientation(): FreeCameraInputsManager;
  39063. }
  39064. }
  39065. /**
  39066. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39067. * Screen rotation is taken into account.
  39068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39069. */
  39070. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39071. private _camera;
  39072. private _screenOrientationAngle;
  39073. private _constantTranform;
  39074. private _screenQuaternion;
  39075. private _alpha;
  39076. private _beta;
  39077. private _gamma;
  39078. /**
  39079. * Can be used to detect if a device orientation sensor is availible on a device
  39080. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39081. * @returns a promise that will resolve on orientation change
  39082. */
  39083. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39084. /**
  39085. * @hidden
  39086. */
  39087. _onDeviceOrientationChangedObservable: Observable<void>;
  39088. /**
  39089. * Instantiates a new input
  39090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39091. */
  39092. constructor();
  39093. /**
  39094. * Define the camera controlled by the input.
  39095. */
  39096. camera: FreeCamera;
  39097. /**
  39098. * Attach the input controls to a specific dom element to get the input from.
  39099. * @param element Defines the element the controls should be listened from
  39100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39101. */
  39102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39103. private _orientationChanged;
  39104. private _deviceOrientation;
  39105. /**
  39106. * Detach the current controls from the specified dom element.
  39107. * @param element Defines the element to stop listening the inputs from
  39108. */
  39109. detachControl(element: Nullable<HTMLElement>): void;
  39110. /**
  39111. * Update the current camera state depending on the inputs that have been used this frame.
  39112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39113. */
  39114. checkInputs(): void;
  39115. /**
  39116. * Gets the class name of the current intput.
  39117. * @returns the class name
  39118. */
  39119. getClassName(): string;
  39120. /**
  39121. * Get the friendly name associated with the input class.
  39122. * @returns the input friendly name
  39123. */
  39124. getSimpleName(): string;
  39125. }
  39126. }
  39127. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39128. import { Nullable } from "babylonjs/types";
  39129. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39130. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39131. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39132. /**
  39133. * Manage the gamepad inputs to control a free camera.
  39134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39135. */
  39136. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39137. /**
  39138. * Define the camera the input is attached to.
  39139. */
  39140. camera: FreeCamera;
  39141. /**
  39142. * Define the Gamepad controlling the input
  39143. */
  39144. gamepad: Nullable<Gamepad>;
  39145. /**
  39146. * Defines the gamepad rotation sensiblity.
  39147. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39148. */
  39149. gamepadAngularSensibility: number;
  39150. /**
  39151. * Defines the gamepad move sensiblity.
  39152. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39153. */
  39154. gamepadMoveSensibility: number;
  39155. private _onGamepadConnectedObserver;
  39156. private _onGamepadDisconnectedObserver;
  39157. private _cameraTransform;
  39158. private _deltaTransform;
  39159. private _vector3;
  39160. private _vector2;
  39161. /**
  39162. * Attach the input controls to a specific dom element to get the input from.
  39163. * @param element Defines the element the controls should be listened from
  39164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39165. */
  39166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39167. /**
  39168. * Detach the current controls from the specified dom element.
  39169. * @param element Defines the element to stop listening the inputs from
  39170. */
  39171. detachControl(element: Nullable<HTMLElement>): void;
  39172. /**
  39173. * Update the current camera state depending on the inputs that have been used this frame.
  39174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39175. */
  39176. checkInputs(): void;
  39177. /**
  39178. * Gets the class name of the current intput.
  39179. * @returns the class name
  39180. */
  39181. getClassName(): string;
  39182. /**
  39183. * Get the friendly name associated with the input class.
  39184. * @returns the input friendly name
  39185. */
  39186. getSimpleName(): string;
  39187. }
  39188. }
  39189. declare module "babylonjs/Misc/virtualJoystick" {
  39190. import { Nullable } from "babylonjs/types";
  39191. import { Vector3 } from "babylonjs/Maths/math.vector";
  39192. /**
  39193. * Defines the potential axis of a Joystick
  39194. */
  39195. export enum JoystickAxis {
  39196. /** X axis */
  39197. X = 0,
  39198. /** Y axis */
  39199. Y = 1,
  39200. /** Z axis */
  39201. Z = 2
  39202. }
  39203. /**
  39204. * Class used to define virtual joystick (used in touch mode)
  39205. */
  39206. export class VirtualJoystick {
  39207. /**
  39208. * Gets or sets a boolean indicating that left and right values must be inverted
  39209. */
  39210. reverseLeftRight: boolean;
  39211. /**
  39212. * Gets or sets a boolean indicating that up and down values must be inverted
  39213. */
  39214. reverseUpDown: boolean;
  39215. /**
  39216. * Gets the offset value for the position (ie. the change of the position value)
  39217. */
  39218. deltaPosition: Vector3;
  39219. /**
  39220. * Gets a boolean indicating if the virtual joystick was pressed
  39221. */
  39222. pressed: boolean;
  39223. /**
  39224. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39225. */
  39226. static Canvas: Nullable<HTMLCanvasElement>;
  39227. private static _globalJoystickIndex;
  39228. private static vjCanvasContext;
  39229. private static vjCanvasWidth;
  39230. private static vjCanvasHeight;
  39231. private static halfWidth;
  39232. private _action;
  39233. private _axisTargetedByLeftAndRight;
  39234. private _axisTargetedByUpAndDown;
  39235. private _joystickSensibility;
  39236. private _inversedSensibility;
  39237. private _joystickPointerID;
  39238. private _joystickColor;
  39239. private _joystickPointerPos;
  39240. private _joystickPreviousPointerPos;
  39241. private _joystickPointerStartPos;
  39242. private _deltaJoystickVector;
  39243. private _leftJoystick;
  39244. private _touches;
  39245. private _onPointerDownHandlerRef;
  39246. private _onPointerMoveHandlerRef;
  39247. private _onPointerUpHandlerRef;
  39248. private _onResize;
  39249. /**
  39250. * Creates a new virtual joystick
  39251. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39252. */
  39253. constructor(leftJoystick?: boolean);
  39254. /**
  39255. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39256. * @param newJoystickSensibility defines the new sensibility
  39257. */
  39258. setJoystickSensibility(newJoystickSensibility: number): void;
  39259. private _onPointerDown;
  39260. private _onPointerMove;
  39261. private _onPointerUp;
  39262. /**
  39263. * Change the color of the virtual joystick
  39264. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39265. */
  39266. setJoystickColor(newColor: string): void;
  39267. /**
  39268. * Defines a callback to call when the joystick is touched
  39269. * @param action defines the callback
  39270. */
  39271. setActionOnTouch(action: () => any): void;
  39272. /**
  39273. * Defines which axis you'd like to control for left & right
  39274. * @param axis defines the axis to use
  39275. */
  39276. setAxisForLeftRight(axis: JoystickAxis): void;
  39277. /**
  39278. * Defines which axis you'd like to control for up & down
  39279. * @param axis defines the axis to use
  39280. */
  39281. setAxisForUpDown(axis: JoystickAxis): void;
  39282. private _drawVirtualJoystick;
  39283. /**
  39284. * Release internal HTML canvas
  39285. */
  39286. releaseCanvas(): void;
  39287. }
  39288. }
  39289. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39290. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39291. import { Nullable } from "babylonjs/types";
  39292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39294. module "babylonjs/Cameras/freeCameraInputsManager" {
  39295. interface FreeCameraInputsManager {
  39296. /**
  39297. * Add virtual joystick input support to the input manager.
  39298. * @returns the current input manager
  39299. */
  39300. addVirtualJoystick(): FreeCameraInputsManager;
  39301. }
  39302. }
  39303. /**
  39304. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39306. */
  39307. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39308. /**
  39309. * Defines the camera the input is attached to.
  39310. */
  39311. camera: FreeCamera;
  39312. private _leftjoystick;
  39313. private _rightjoystick;
  39314. /**
  39315. * Gets the left stick of the virtual joystick.
  39316. * @returns The virtual Joystick
  39317. */
  39318. getLeftJoystick(): VirtualJoystick;
  39319. /**
  39320. * Gets the right stick of the virtual joystick.
  39321. * @returns The virtual Joystick
  39322. */
  39323. getRightJoystick(): VirtualJoystick;
  39324. /**
  39325. * Update the current camera state depending on the inputs that have been used this frame.
  39326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39327. */
  39328. checkInputs(): void;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. /**
  39336. * Detach the current controls from the specified dom element.
  39337. * @param element Defines the element to stop listening the inputs from
  39338. */
  39339. detachControl(element: Nullable<HTMLElement>): void;
  39340. /**
  39341. * Gets the class name of the current intput.
  39342. * @returns the class name
  39343. */
  39344. getClassName(): string;
  39345. /**
  39346. * Get the friendly name associated with the input class.
  39347. * @returns the input friendly name
  39348. */
  39349. getSimpleName(): string;
  39350. }
  39351. }
  39352. declare module "babylonjs/Cameras/Inputs/index" {
  39353. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39354. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39355. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39356. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39357. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39358. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39359. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39360. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39361. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39362. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39363. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39364. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39365. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39366. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39367. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39368. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39369. }
  39370. declare module "babylonjs/Cameras/touchCamera" {
  39371. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39372. import { Scene } from "babylonjs/scene";
  39373. import { Vector3 } from "babylonjs/Maths/math.vector";
  39374. /**
  39375. * This represents a FPS type of camera controlled by touch.
  39376. * This is like a universal camera minus the Gamepad controls.
  39377. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39378. */
  39379. export class TouchCamera extends FreeCamera {
  39380. /**
  39381. * Defines the touch sensibility for rotation.
  39382. * The higher the faster.
  39383. */
  39384. touchAngularSensibility: number;
  39385. /**
  39386. * Defines the touch sensibility for move.
  39387. * The higher the faster.
  39388. */
  39389. touchMoveSensibility: number;
  39390. /**
  39391. * Instantiates a new touch camera.
  39392. * This represents a FPS type of camera controlled by touch.
  39393. * This is like a universal camera minus the Gamepad controls.
  39394. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39395. * @param name Define the name of the camera in the scene
  39396. * @param position Define the start position of the camera in the scene
  39397. * @param scene Define the scene the camera belongs to
  39398. */
  39399. constructor(name: string, position: Vector3, scene: Scene);
  39400. /**
  39401. * Gets the current object class name.
  39402. * @return the class name
  39403. */
  39404. getClassName(): string;
  39405. /** @hidden */
  39406. _setupInputs(): void;
  39407. }
  39408. }
  39409. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39410. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39411. import { Scene } from "babylonjs/scene";
  39412. import { Vector3 } from "babylonjs/Maths/math.vector";
  39413. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39414. import { Axis } from "babylonjs/Maths/math.axis";
  39415. /**
  39416. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39417. * being tilted forward or back and left or right.
  39418. */
  39419. export class DeviceOrientationCamera extends FreeCamera {
  39420. private _initialQuaternion;
  39421. private _quaternionCache;
  39422. private _tmpDragQuaternion;
  39423. /**
  39424. * Creates a new device orientation camera
  39425. * @param name The name of the camera
  39426. * @param position The start position camera
  39427. * @param scene The scene the camera belongs to
  39428. */
  39429. constructor(name: string, position: Vector3, scene: Scene);
  39430. /**
  39431. * @hidden
  39432. * Disabled pointer input on first orientation sensor update (Default: true)
  39433. */
  39434. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39435. private _dragFactor;
  39436. /**
  39437. * Enabled turning on the y axis when the orientation sensor is active
  39438. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39439. */
  39440. enableHorizontalDragging(dragFactor?: number): void;
  39441. /**
  39442. * Gets the current instance class name ("DeviceOrientationCamera").
  39443. * This helps avoiding instanceof at run time.
  39444. * @returns the class name
  39445. */
  39446. getClassName(): string;
  39447. /**
  39448. * @hidden
  39449. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39450. */
  39451. _checkInputs(): void;
  39452. /**
  39453. * Reset the camera to its default orientation on the specified axis only.
  39454. * @param axis The axis to reset
  39455. */
  39456. resetToCurrentRotation(axis?: Axis): void;
  39457. }
  39458. }
  39459. declare module "babylonjs/Gamepads/xboxGamepad" {
  39460. import { Observable } from "babylonjs/Misc/observable";
  39461. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39462. /**
  39463. * Defines supported buttons for XBox360 compatible gamepads
  39464. */
  39465. export enum Xbox360Button {
  39466. /** A */
  39467. A = 0,
  39468. /** B */
  39469. B = 1,
  39470. /** X */
  39471. X = 2,
  39472. /** Y */
  39473. Y = 3,
  39474. /** Start */
  39475. Start = 4,
  39476. /** Back */
  39477. Back = 5,
  39478. /** Left button */
  39479. LB = 6,
  39480. /** Right button */
  39481. RB = 7,
  39482. /** Left stick */
  39483. LeftStick = 8,
  39484. /** Right stick */
  39485. RightStick = 9
  39486. }
  39487. /** Defines values for XBox360 DPad */
  39488. export enum Xbox360Dpad {
  39489. /** Up */
  39490. Up = 0,
  39491. /** Down */
  39492. Down = 1,
  39493. /** Left */
  39494. Left = 2,
  39495. /** Right */
  39496. Right = 3
  39497. }
  39498. /**
  39499. * Defines a XBox360 gamepad
  39500. */
  39501. export class Xbox360Pad extends Gamepad {
  39502. private _leftTrigger;
  39503. private _rightTrigger;
  39504. private _onlefttriggerchanged;
  39505. private _onrighttriggerchanged;
  39506. private _onbuttondown;
  39507. private _onbuttonup;
  39508. private _ondpaddown;
  39509. private _ondpadup;
  39510. /** Observable raised when a button is pressed */
  39511. onButtonDownObservable: Observable<Xbox360Button>;
  39512. /** Observable raised when a button is released */
  39513. onButtonUpObservable: Observable<Xbox360Button>;
  39514. /** Observable raised when a pad is pressed */
  39515. onPadDownObservable: Observable<Xbox360Dpad>;
  39516. /** Observable raised when a pad is released */
  39517. onPadUpObservable: Observable<Xbox360Dpad>;
  39518. private _buttonA;
  39519. private _buttonB;
  39520. private _buttonX;
  39521. private _buttonY;
  39522. private _buttonBack;
  39523. private _buttonStart;
  39524. private _buttonLB;
  39525. private _buttonRB;
  39526. private _buttonLeftStick;
  39527. private _buttonRightStick;
  39528. private _dPadUp;
  39529. private _dPadDown;
  39530. private _dPadLeft;
  39531. private _dPadRight;
  39532. private _isXboxOnePad;
  39533. /**
  39534. * Creates a new XBox360 gamepad object
  39535. * @param id defines the id of this gamepad
  39536. * @param index defines its index
  39537. * @param gamepad defines the internal HTML gamepad object
  39538. * @param xboxOne defines if it is a XBox One gamepad
  39539. */
  39540. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39541. /**
  39542. * Defines the callback to call when left trigger is pressed
  39543. * @param callback defines the callback to use
  39544. */
  39545. onlefttriggerchanged(callback: (value: number) => void): void;
  39546. /**
  39547. * Defines the callback to call when right trigger is pressed
  39548. * @param callback defines the callback to use
  39549. */
  39550. onrighttriggerchanged(callback: (value: number) => void): void;
  39551. /**
  39552. * Gets the left trigger value
  39553. */
  39554. /**
  39555. * Sets the left trigger value
  39556. */
  39557. leftTrigger: number;
  39558. /**
  39559. * Gets the right trigger value
  39560. */
  39561. /**
  39562. * Sets the right trigger value
  39563. */
  39564. rightTrigger: number;
  39565. /**
  39566. * Defines the callback to call when a button is pressed
  39567. * @param callback defines the callback to use
  39568. */
  39569. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39570. /**
  39571. * Defines the callback to call when a button is released
  39572. * @param callback defines the callback to use
  39573. */
  39574. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39575. /**
  39576. * Defines the callback to call when a pad is pressed
  39577. * @param callback defines the callback to use
  39578. */
  39579. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39580. /**
  39581. * Defines the callback to call when a pad is released
  39582. * @param callback defines the callback to use
  39583. */
  39584. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39585. private _setButtonValue;
  39586. private _setDPadValue;
  39587. /**
  39588. * Gets the value of the `A` button
  39589. */
  39590. /**
  39591. * Sets the value of the `A` button
  39592. */
  39593. buttonA: number;
  39594. /**
  39595. * Gets the value of the `B` button
  39596. */
  39597. /**
  39598. * Sets the value of the `B` button
  39599. */
  39600. buttonB: number;
  39601. /**
  39602. * Gets the value of the `X` button
  39603. */
  39604. /**
  39605. * Sets the value of the `X` button
  39606. */
  39607. buttonX: number;
  39608. /**
  39609. * Gets the value of the `Y` button
  39610. */
  39611. /**
  39612. * Sets the value of the `Y` button
  39613. */
  39614. buttonY: number;
  39615. /**
  39616. * Gets the value of the `Start` button
  39617. */
  39618. /**
  39619. * Sets the value of the `Start` button
  39620. */
  39621. buttonStart: number;
  39622. /**
  39623. * Gets the value of the `Back` button
  39624. */
  39625. /**
  39626. * Sets the value of the `Back` button
  39627. */
  39628. buttonBack: number;
  39629. /**
  39630. * Gets the value of the `Left` button
  39631. */
  39632. /**
  39633. * Sets the value of the `Left` button
  39634. */
  39635. buttonLB: number;
  39636. /**
  39637. * Gets the value of the `Right` button
  39638. */
  39639. /**
  39640. * Sets the value of the `Right` button
  39641. */
  39642. buttonRB: number;
  39643. /**
  39644. * Gets the value of the Left joystick
  39645. */
  39646. /**
  39647. * Sets the value of the Left joystick
  39648. */
  39649. buttonLeftStick: number;
  39650. /**
  39651. * Gets the value of the Right joystick
  39652. */
  39653. /**
  39654. * Sets the value of the Right joystick
  39655. */
  39656. buttonRightStick: number;
  39657. /**
  39658. * Gets the value of D-pad up
  39659. */
  39660. /**
  39661. * Sets the value of D-pad up
  39662. */
  39663. dPadUp: number;
  39664. /**
  39665. * Gets the value of D-pad down
  39666. */
  39667. /**
  39668. * Sets the value of D-pad down
  39669. */
  39670. dPadDown: number;
  39671. /**
  39672. * Gets the value of D-pad left
  39673. */
  39674. /**
  39675. * Sets the value of D-pad left
  39676. */
  39677. dPadLeft: number;
  39678. /**
  39679. * Gets the value of D-pad right
  39680. */
  39681. /**
  39682. * Sets the value of D-pad right
  39683. */
  39684. dPadRight: number;
  39685. /**
  39686. * Force the gamepad to synchronize with device values
  39687. */
  39688. update(): void;
  39689. /**
  39690. * Disposes the gamepad
  39691. */
  39692. dispose(): void;
  39693. }
  39694. }
  39695. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39696. import { Observable } from "babylonjs/Misc/observable";
  39697. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39698. /**
  39699. * Defines supported buttons for DualShock compatible gamepads
  39700. */
  39701. export enum DualShockButton {
  39702. /** Cross */
  39703. Cross = 0,
  39704. /** Circle */
  39705. Circle = 1,
  39706. /** Square */
  39707. Square = 2,
  39708. /** Triangle */
  39709. Triangle = 3,
  39710. /** Options */
  39711. Options = 4,
  39712. /** Share */
  39713. Share = 5,
  39714. /** L1 */
  39715. L1 = 6,
  39716. /** R1 */
  39717. R1 = 7,
  39718. /** Left stick */
  39719. LeftStick = 8,
  39720. /** Right stick */
  39721. RightStick = 9
  39722. }
  39723. /** Defines values for DualShock DPad */
  39724. export enum DualShockDpad {
  39725. /** Up */
  39726. Up = 0,
  39727. /** Down */
  39728. Down = 1,
  39729. /** Left */
  39730. Left = 2,
  39731. /** Right */
  39732. Right = 3
  39733. }
  39734. /**
  39735. * Defines a DualShock gamepad
  39736. */
  39737. export class DualShockPad extends Gamepad {
  39738. private _leftTrigger;
  39739. private _rightTrigger;
  39740. private _onlefttriggerchanged;
  39741. private _onrighttriggerchanged;
  39742. private _onbuttondown;
  39743. private _onbuttonup;
  39744. private _ondpaddown;
  39745. private _ondpadup;
  39746. /** Observable raised when a button is pressed */
  39747. onButtonDownObservable: Observable<DualShockButton>;
  39748. /** Observable raised when a button is released */
  39749. onButtonUpObservable: Observable<DualShockButton>;
  39750. /** Observable raised when a pad is pressed */
  39751. onPadDownObservable: Observable<DualShockDpad>;
  39752. /** Observable raised when a pad is released */
  39753. onPadUpObservable: Observable<DualShockDpad>;
  39754. private _buttonCross;
  39755. private _buttonCircle;
  39756. private _buttonSquare;
  39757. private _buttonTriangle;
  39758. private _buttonShare;
  39759. private _buttonOptions;
  39760. private _buttonL1;
  39761. private _buttonR1;
  39762. private _buttonLeftStick;
  39763. private _buttonRightStick;
  39764. private _dPadUp;
  39765. private _dPadDown;
  39766. private _dPadLeft;
  39767. private _dPadRight;
  39768. /**
  39769. * Creates a new DualShock gamepad object
  39770. * @param id defines the id of this gamepad
  39771. * @param index defines its index
  39772. * @param gamepad defines the internal HTML gamepad object
  39773. */
  39774. constructor(id: string, index: number, gamepad: any);
  39775. /**
  39776. * Defines the callback to call when left trigger is pressed
  39777. * @param callback defines the callback to use
  39778. */
  39779. onlefttriggerchanged(callback: (value: number) => void): void;
  39780. /**
  39781. * Defines the callback to call when right trigger is pressed
  39782. * @param callback defines the callback to use
  39783. */
  39784. onrighttriggerchanged(callback: (value: number) => void): void;
  39785. /**
  39786. * Gets the left trigger value
  39787. */
  39788. /**
  39789. * Sets the left trigger value
  39790. */
  39791. leftTrigger: number;
  39792. /**
  39793. * Gets the right trigger value
  39794. */
  39795. /**
  39796. * Sets the right trigger value
  39797. */
  39798. rightTrigger: number;
  39799. /**
  39800. * Defines the callback to call when a button is pressed
  39801. * @param callback defines the callback to use
  39802. */
  39803. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39804. /**
  39805. * Defines the callback to call when a button is released
  39806. * @param callback defines the callback to use
  39807. */
  39808. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39809. /**
  39810. * Defines the callback to call when a pad is pressed
  39811. * @param callback defines the callback to use
  39812. */
  39813. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39814. /**
  39815. * Defines the callback to call when a pad is released
  39816. * @param callback defines the callback to use
  39817. */
  39818. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39819. private _setButtonValue;
  39820. private _setDPadValue;
  39821. /**
  39822. * Gets the value of the `Cross` button
  39823. */
  39824. /**
  39825. * Sets the value of the `Cross` button
  39826. */
  39827. buttonCross: number;
  39828. /**
  39829. * Gets the value of the `Circle` button
  39830. */
  39831. /**
  39832. * Sets the value of the `Circle` button
  39833. */
  39834. buttonCircle: number;
  39835. /**
  39836. * Gets the value of the `Square` button
  39837. */
  39838. /**
  39839. * Sets the value of the `Square` button
  39840. */
  39841. buttonSquare: number;
  39842. /**
  39843. * Gets the value of the `Triangle` button
  39844. */
  39845. /**
  39846. * Sets the value of the `Triangle` button
  39847. */
  39848. buttonTriangle: number;
  39849. /**
  39850. * Gets the value of the `Options` button
  39851. */
  39852. /**
  39853. * Sets the value of the `Options` button
  39854. */
  39855. buttonOptions: number;
  39856. /**
  39857. * Gets the value of the `Share` button
  39858. */
  39859. /**
  39860. * Sets the value of the `Share` button
  39861. */
  39862. buttonShare: number;
  39863. /**
  39864. * Gets the value of the `L1` button
  39865. */
  39866. /**
  39867. * Sets the value of the `L1` button
  39868. */
  39869. buttonL1: number;
  39870. /**
  39871. * Gets the value of the `R1` button
  39872. */
  39873. /**
  39874. * Sets the value of the `R1` button
  39875. */
  39876. buttonR1: number;
  39877. /**
  39878. * Gets the value of the Left joystick
  39879. */
  39880. /**
  39881. * Sets the value of the Left joystick
  39882. */
  39883. buttonLeftStick: number;
  39884. /**
  39885. * Gets the value of the Right joystick
  39886. */
  39887. /**
  39888. * Sets the value of the Right joystick
  39889. */
  39890. buttonRightStick: number;
  39891. /**
  39892. * Gets the value of D-pad up
  39893. */
  39894. /**
  39895. * Sets the value of D-pad up
  39896. */
  39897. dPadUp: number;
  39898. /**
  39899. * Gets the value of D-pad down
  39900. */
  39901. /**
  39902. * Sets the value of D-pad down
  39903. */
  39904. dPadDown: number;
  39905. /**
  39906. * Gets the value of D-pad left
  39907. */
  39908. /**
  39909. * Sets the value of D-pad left
  39910. */
  39911. dPadLeft: number;
  39912. /**
  39913. * Gets the value of D-pad right
  39914. */
  39915. /**
  39916. * Sets the value of D-pad right
  39917. */
  39918. dPadRight: number;
  39919. /**
  39920. * Force the gamepad to synchronize with device values
  39921. */
  39922. update(): void;
  39923. /**
  39924. * Disposes the gamepad
  39925. */
  39926. dispose(): void;
  39927. }
  39928. }
  39929. declare module "babylonjs/Gamepads/gamepadManager" {
  39930. import { Observable } from "babylonjs/Misc/observable";
  39931. import { Nullable } from "babylonjs/types";
  39932. import { Scene } from "babylonjs/scene";
  39933. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39934. /**
  39935. * Manager for handling gamepads
  39936. */
  39937. export class GamepadManager {
  39938. private _scene?;
  39939. private _babylonGamepads;
  39940. private _oneGamepadConnected;
  39941. /** @hidden */
  39942. _isMonitoring: boolean;
  39943. private _gamepadEventSupported;
  39944. private _gamepadSupport;
  39945. /**
  39946. * observable to be triggered when the gamepad controller has been connected
  39947. */
  39948. onGamepadConnectedObservable: Observable<Gamepad>;
  39949. /**
  39950. * observable to be triggered when the gamepad controller has been disconnected
  39951. */
  39952. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39953. private _onGamepadConnectedEvent;
  39954. private _onGamepadDisconnectedEvent;
  39955. /**
  39956. * Initializes the gamepad manager
  39957. * @param _scene BabylonJS scene
  39958. */
  39959. constructor(_scene?: Scene | undefined);
  39960. /**
  39961. * The gamepads in the game pad manager
  39962. */
  39963. readonly gamepads: Gamepad[];
  39964. /**
  39965. * Get the gamepad controllers based on type
  39966. * @param type The type of gamepad controller
  39967. * @returns Nullable gamepad
  39968. */
  39969. getGamepadByType(type?: number): Nullable<Gamepad>;
  39970. /**
  39971. * Disposes the gamepad manager
  39972. */
  39973. dispose(): void;
  39974. private _addNewGamepad;
  39975. private _startMonitoringGamepads;
  39976. private _stopMonitoringGamepads;
  39977. /** @hidden */
  39978. _checkGamepadsStatus(): void;
  39979. private _updateGamepadObjects;
  39980. }
  39981. }
  39982. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39983. import { Nullable } from "babylonjs/types";
  39984. import { Scene } from "babylonjs/scene";
  39985. import { ISceneComponent } from "babylonjs/sceneComponent";
  39986. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39987. module "babylonjs/scene" {
  39988. interface Scene {
  39989. /** @hidden */
  39990. _gamepadManager: Nullable<GamepadManager>;
  39991. /**
  39992. * Gets the gamepad manager associated with the scene
  39993. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39994. */
  39995. gamepadManager: GamepadManager;
  39996. }
  39997. }
  39998. module "babylonjs/Cameras/freeCameraInputsManager" {
  39999. /**
  40000. * Interface representing a free camera inputs manager
  40001. */
  40002. interface FreeCameraInputsManager {
  40003. /**
  40004. * Adds gamepad input support to the FreeCameraInputsManager.
  40005. * @returns the FreeCameraInputsManager
  40006. */
  40007. addGamepad(): FreeCameraInputsManager;
  40008. }
  40009. }
  40010. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40011. /**
  40012. * Interface representing an arc rotate camera inputs manager
  40013. */
  40014. interface ArcRotateCameraInputsManager {
  40015. /**
  40016. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40017. * @returns the camera inputs manager
  40018. */
  40019. addGamepad(): ArcRotateCameraInputsManager;
  40020. }
  40021. }
  40022. /**
  40023. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40024. */
  40025. export class GamepadSystemSceneComponent implements ISceneComponent {
  40026. /**
  40027. * The component name helpfull to identify the component in the list of scene components.
  40028. */
  40029. readonly name: string;
  40030. /**
  40031. * The scene the component belongs to.
  40032. */
  40033. scene: Scene;
  40034. /**
  40035. * Creates a new instance of the component for the given scene
  40036. * @param scene Defines the scene to register the component in
  40037. */
  40038. constructor(scene: Scene);
  40039. /**
  40040. * Registers the component in a given scene
  40041. */
  40042. register(): void;
  40043. /**
  40044. * Rebuilds the elements related to this component in case of
  40045. * context lost for instance.
  40046. */
  40047. rebuild(): void;
  40048. /**
  40049. * Disposes the component and the associated ressources
  40050. */
  40051. dispose(): void;
  40052. private _beforeCameraUpdate;
  40053. }
  40054. }
  40055. declare module "babylonjs/Cameras/universalCamera" {
  40056. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40057. import { Scene } from "babylonjs/scene";
  40058. import { Vector3 } from "babylonjs/Maths/math.vector";
  40059. import "babylonjs/Gamepads/gamepadSceneComponent";
  40060. /**
  40061. * 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,
  40062. * which still works and will still be found in many Playgrounds.
  40063. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40064. */
  40065. export class UniversalCamera extends TouchCamera {
  40066. /**
  40067. * Defines the gamepad rotation sensiblity.
  40068. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40069. */
  40070. gamepadAngularSensibility: number;
  40071. /**
  40072. * Defines the gamepad move sensiblity.
  40073. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40074. */
  40075. gamepadMoveSensibility: number;
  40076. /**
  40077. * 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,
  40078. * which still works and will still be found in many Playgrounds.
  40079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40080. * @param name Define the name of the camera in the scene
  40081. * @param position Define the start position of the camera in the scene
  40082. * @param scene Define the scene the camera belongs to
  40083. */
  40084. constructor(name: string, position: Vector3, scene: Scene);
  40085. /**
  40086. * Gets the current object class name.
  40087. * @return the class name
  40088. */
  40089. getClassName(): string;
  40090. }
  40091. }
  40092. declare module "babylonjs/Cameras/gamepadCamera" {
  40093. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40094. import { Scene } from "babylonjs/scene";
  40095. import { Vector3 } from "babylonjs/Maths/math.vector";
  40096. /**
  40097. * This represents a FPS type of camera. This is only here for back compat purpose.
  40098. * Please use the UniversalCamera instead as both are identical.
  40099. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40100. */
  40101. export class GamepadCamera extends UniversalCamera {
  40102. /**
  40103. * Instantiates a new Gamepad Camera
  40104. * This represents a FPS type of camera. This is only here for back compat purpose.
  40105. * Please use the UniversalCamera instead as both are identical.
  40106. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40107. * @param name Define the name of the camera in the scene
  40108. * @param position Define the start position of the camera in the scene
  40109. * @param scene Define the scene the camera belongs to
  40110. */
  40111. constructor(name: string, position: Vector3, scene: Scene);
  40112. /**
  40113. * Gets the current object class name.
  40114. * @return the class name
  40115. */
  40116. getClassName(): string;
  40117. }
  40118. }
  40119. declare module "babylonjs/Shaders/pass.fragment" {
  40120. /** @hidden */
  40121. export var passPixelShader: {
  40122. name: string;
  40123. shader: string;
  40124. };
  40125. }
  40126. declare module "babylonjs/Shaders/passCube.fragment" {
  40127. /** @hidden */
  40128. export var passCubePixelShader: {
  40129. name: string;
  40130. shader: string;
  40131. };
  40132. }
  40133. declare module "babylonjs/PostProcesses/passPostProcess" {
  40134. import { Nullable } from "babylonjs/types";
  40135. import { Camera } from "babylonjs/Cameras/camera";
  40136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40137. import { Engine } from "babylonjs/Engines/engine";
  40138. import "babylonjs/Shaders/pass.fragment";
  40139. import "babylonjs/Shaders/passCube.fragment";
  40140. /**
  40141. * PassPostProcess which produces an output the same as it's input
  40142. */
  40143. export class PassPostProcess extends PostProcess {
  40144. /**
  40145. * Creates the PassPostProcess
  40146. * @param name The name of the effect.
  40147. * @param options The required width/height ratio to downsize to before computing the render pass.
  40148. * @param camera The camera to apply the render pass to.
  40149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40150. * @param engine The engine which the post process will be applied. (default: current engine)
  40151. * @param reusable If the post process can be reused on the same frame. (default: false)
  40152. * @param textureType The type of texture to be used when performing the post processing.
  40153. * @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)
  40154. */
  40155. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40156. }
  40157. /**
  40158. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40159. */
  40160. export class PassCubePostProcess extends PostProcess {
  40161. private _face;
  40162. /**
  40163. * Gets or sets the cube face to display.
  40164. * * 0 is +X
  40165. * * 1 is -X
  40166. * * 2 is +Y
  40167. * * 3 is -Y
  40168. * * 4 is +Z
  40169. * * 5 is -Z
  40170. */
  40171. face: number;
  40172. /**
  40173. * Creates the PassCubePostProcess
  40174. * @param name The name of the effect.
  40175. * @param options The required width/height ratio to downsize to before computing the render pass.
  40176. * @param camera The camera to apply the render pass to.
  40177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40178. * @param engine The engine which the post process will be applied. (default: current engine)
  40179. * @param reusable If the post process can be reused on the same frame. (default: false)
  40180. * @param textureType The type of texture to be used when performing the post processing.
  40181. * @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)
  40182. */
  40183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40184. }
  40185. }
  40186. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40187. /** @hidden */
  40188. export var anaglyphPixelShader: {
  40189. name: string;
  40190. shader: string;
  40191. };
  40192. }
  40193. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40194. import { Engine } from "babylonjs/Engines/engine";
  40195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40196. import { Camera } from "babylonjs/Cameras/camera";
  40197. import "babylonjs/Shaders/anaglyph.fragment";
  40198. /**
  40199. * Postprocess used to generate anaglyphic rendering
  40200. */
  40201. export class AnaglyphPostProcess extends PostProcess {
  40202. private _passedProcess;
  40203. /**
  40204. * Creates a new AnaglyphPostProcess
  40205. * @param name defines postprocess name
  40206. * @param options defines creation options or target ratio scale
  40207. * @param rigCameras defines cameras using this postprocess
  40208. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40209. * @param engine defines hosting engine
  40210. * @param reusable defines if the postprocess will be reused multiple times per frame
  40211. */
  40212. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40213. }
  40214. }
  40215. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40216. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40218. import { Scene } from "babylonjs/scene";
  40219. import { Vector3 } from "babylonjs/Maths/math.vector";
  40220. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40221. /**
  40222. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40223. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40224. */
  40225. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40226. /**
  40227. * Creates a new AnaglyphArcRotateCamera
  40228. * @param name defines camera name
  40229. * @param alpha defines alpha angle (in radians)
  40230. * @param beta defines beta angle (in radians)
  40231. * @param radius defines radius
  40232. * @param target defines camera target
  40233. * @param interaxialDistance defines distance between each color axis
  40234. * @param scene defines the hosting scene
  40235. */
  40236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40237. /**
  40238. * Gets camera class name
  40239. * @returns AnaglyphArcRotateCamera
  40240. */
  40241. getClassName(): string;
  40242. }
  40243. }
  40244. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40246. import { Scene } from "babylonjs/scene";
  40247. import { Vector3 } from "babylonjs/Maths/math.vector";
  40248. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40249. /**
  40250. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40251. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40252. */
  40253. export class AnaglyphFreeCamera extends FreeCamera {
  40254. /**
  40255. * Creates a new AnaglyphFreeCamera
  40256. * @param name defines camera name
  40257. * @param position defines initial position
  40258. * @param interaxialDistance defines distance between each color axis
  40259. * @param scene defines the hosting scene
  40260. */
  40261. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40262. /**
  40263. * Gets camera class name
  40264. * @returns AnaglyphFreeCamera
  40265. */
  40266. getClassName(): string;
  40267. }
  40268. }
  40269. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40270. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40271. import { Scene } from "babylonjs/scene";
  40272. import { Vector3 } from "babylonjs/Maths/math.vector";
  40273. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40274. /**
  40275. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40276. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40277. */
  40278. export class AnaglyphGamepadCamera extends GamepadCamera {
  40279. /**
  40280. * Creates a new AnaglyphGamepadCamera
  40281. * @param name defines camera name
  40282. * @param position defines initial position
  40283. * @param interaxialDistance defines distance between each color axis
  40284. * @param scene defines the hosting scene
  40285. */
  40286. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40287. /**
  40288. * Gets camera class name
  40289. * @returns AnaglyphGamepadCamera
  40290. */
  40291. getClassName(): string;
  40292. }
  40293. }
  40294. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40295. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40296. import { Scene } from "babylonjs/scene";
  40297. import { Vector3 } from "babylonjs/Maths/math.vector";
  40298. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40299. /**
  40300. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40301. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40302. */
  40303. export class AnaglyphUniversalCamera extends UniversalCamera {
  40304. /**
  40305. * Creates a new AnaglyphUniversalCamera
  40306. * @param name defines camera name
  40307. * @param position defines initial position
  40308. * @param interaxialDistance defines distance between each color axis
  40309. * @param scene defines the hosting scene
  40310. */
  40311. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40312. /**
  40313. * Gets camera class name
  40314. * @returns AnaglyphUniversalCamera
  40315. */
  40316. getClassName(): string;
  40317. }
  40318. }
  40319. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40320. /** @hidden */
  40321. export var stereoscopicInterlacePixelShader: {
  40322. name: string;
  40323. shader: string;
  40324. };
  40325. }
  40326. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40327. import { Camera } from "babylonjs/Cameras/camera";
  40328. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40329. import { Engine } from "babylonjs/Engines/engine";
  40330. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40331. /**
  40332. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40333. */
  40334. export class StereoscopicInterlacePostProcess extends PostProcess {
  40335. private _stepSize;
  40336. private _passedProcess;
  40337. /**
  40338. * Initializes a StereoscopicInterlacePostProcess
  40339. * @param name The name of the effect.
  40340. * @param rigCameras The rig cameras to be appled to the post process
  40341. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40343. * @param engine The engine which the post process will be applied. (default: current engine)
  40344. * @param reusable If the post process can be reused on the same frame. (default: false)
  40345. */
  40346. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40347. }
  40348. }
  40349. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40350. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40351. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40352. import { Scene } from "babylonjs/scene";
  40353. import { Vector3 } from "babylonjs/Maths/math.vector";
  40354. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40355. /**
  40356. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40357. * @see http://doc.babylonjs.com/features/cameras
  40358. */
  40359. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40360. /**
  40361. * Creates a new StereoscopicArcRotateCamera
  40362. * @param name defines camera name
  40363. * @param alpha defines alpha angle (in radians)
  40364. * @param beta defines beta angle (in radians)
  40365. * @param radius defines radius
  40366. * @param target defines camera target
  40367. * @param interaxialDistance defines distance between each color axis
  40368. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40369. * @param scene defines the hosting scene
  40370. */
  40371. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40372. /**
  40373. * Gets camera class name
  40374. * @returns StereoscopicArcRotateCamera
  40375. */
  40376. getClassName(): string;
  40377. }
  40378. }
  40379. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40381. import { Scene } from "babylonjs/scene";
  40382. import { Vector3 } from "babylonjs/Maths/math.vector";
  40383. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40384. /**
  40385. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40386. * @see http://doc.babylonjs.com/features/cameras
  40387. */
  40388. export class StereoscopicFreeCamera extends FreeCamera {
  40389. /**
  40390. * Creates a new StereoscopicFreeCamera
  40391. * @param name defines camera name
  40392. * @param position defines initial position
  40393. * @param interaxialDistance defines distance between each color axis
  40394. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40395. * @param scene defines the hosting scene
  40396. */
  40397. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40398. /**
  40399. * Gets camera class name
  40400. * @returns StereoscopicFreeCamera
  40401. */
  40402. getClassName(): string;
  40403. }
  40404. }
  40405. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40406. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40407. import { Scene } from "babylonjs/scene";
  40408. import { Vector3 } from "babylonjs/Maths/math.vector";
  40409. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40410. /**
  40411. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40412. * @see http://doc.babylonjs.com/features/cameras
  40413. */
  40414. export class StereoscopicGamepadCamera extends GamepadCamera {
  40415. /**
  40416. * Creates a new StereoscopicGamepadCamera
  40417. * @param name defines camera name
  40418. * @param position defines initial position
  40419. * @param interaxialDistance defines distance between each color axis
  40420. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40421. * @param scene defines the hosting scene
  40422. */
  40423. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40424. /**
  40425. * Gets camera class name
  40426. * @returns StereoscopicGamepadCamera
  40427. */
  40428. getClassName(): string;
  40429. }
  40430. }
  40431. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40432. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40433. import { Scene } from "babylonjs/scene";
  40434. import { Vector3 } from "babylonjs/Maths/math.vector";
  40435. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40436. /**
  40437. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40438. * @see http://doc.babylonjs.com/features/cameras
  40439. */
  40440. export class StereoscopicUniversalCamera extends UniversalCamera {
  40441. /**
  40442. * Creates a new StereoscopicUniversalCamera
  40443. * @param name defines camera name
  40444. * @param position defines initial position
  40445. * @param interaxialDistance defines distance between each color axis
  40446. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40447. * @param scene defines the hosting scene
  40448. */
  40449. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40450. /**
  40451. * Gets camera class name
  40452. * @returns StereoscopicUniversalCamera
  40453. */
  40454. getClassName(): string;
  40455. }
  40456. }
  40457. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40458. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40459. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40460. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40461. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40462. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40463. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40464. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40465. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40466. }
  40467. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40469. import { Scene } from "babylonjs/scene";
  40470. import { Vector3 } from "babylonjs/Maths/math.vector";
  40471. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40472. /**
  40473. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40474. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40475. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40476. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40477. */
  40478. export class VirtualJoysticksCamera extends FreeCamera {
  40479. /**
  40480. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40481. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40482. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40483. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40484. * @param name Define the name of the camera in the scene
  40485. * @param position Define the start position of the camera in the scene
  40486. * @param scene Define the scene the camera belongs to
  40487. */
  40488. constructor(name: string, position: Vector3, scene: Scene);
  40489. /**
  40490. * Gets the current object class name.
  40491. * @return the class name
  40492. */
  40493. getClassName(): string;
  40494. }
  40495. }
  40496. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40497. import { Matrix } from "babylonjs/Maths/math.vector";
  40498. /**
  40499. * This represents all the required metrics to create a VR camera.
  40500. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40501. */
  40502. export class VRCameraMetrics {
  40503. /**
  40504. * Define the horizontal resolution off the screen.
  40505. */
  40506. hResolution: number;
  40507. /**
  40508. * Define the vertical resolution off the screen.
  40509. */
  40510. vResolution: number;
  40511. /**
  40512. * Define the horizontal screen size.
  40513. */
  40514. hScreenSize: number;
  40515. /**
  40516. * Define the vertical screen size.
  40517. */
  40518. vScreenSize: number;
  40519. /**
  40520. * Define the vertical screen center position.
  40521. */
  40522. vScreenCenter: number;
  40523. /**
  40524. * Define the distance of the eyes to the screen.
  40525. */
  40526. eyeToScreenDistance: number;
  40527. /**
  40528. * Define the distance between both lenses
  40529. */
  40530. lensSeparationDistance: number;
  40531. /**
  40532. * Define the distance between both viewer's eyes.
  40533. */
  40534. interpupillaryDistance: number;
  40535. /**
  40536. * Define the distortion factor of the VR postprocess.
  40537. * Please, touch with care.
  40538. */
  40539. distortionK: number[];
  40540. /**
  40541. * Define the chromatic aberration correction factors for the VR post process.
  40542. */
  40543. chromaAbCorrection: number[];
  40544. /**
  40545. * Define the scale factor of the post process.
  40546. * The smaller the better but the slower.
  40547. */
  40548. postProcessScaleFactor: number;
  40549. /**
  40550. * Define an offset for the lens center.
  40551. */
  40552. lensCenterOffset: number;
  40553. /**
  40554. * Define if the current vr camera should compensate the distortion of the lense or not.
  40555. */
  40556. compensateDistortion: boolean;
  40557. /**
  40558. * Defines if multiview should be enabled when rendering (Default: false)
  40559. */
  40560. multiviewEnabled: boolean;
  40561. /**
  40562. * Gets the rendering aspect ratio based on the provided resolutions.
  40563. */
  40564. readonly aspectRatio: number;
  40565. /**
  40566. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40567. */
  40568. readonly aspectRatioFov: number;
  40569. /**
  40570. * @hidden
  40571. */
  40572. readonly leftHMatrix: Matrix;
  40573. /**
  40574. * @hidden
  40575. */
  40576. readonly rightHMatrix: Matrix;
  40577. /**
  40578. * @hidden
  40579. */
  40580. readonly leftPreViewMatrix: Matrix;
  40581. /**
  40582. * @hidden
  40583. */
  40584. readonly rightPreViewMatrix: Matrix;
  40585. /**
  40586. * Get the default VRMetrics based on the most generic setup.
  40587. * @returns the default vr metrics
  40588. */
  40589. static GetDefault(): VRCameraMetrics;
  40590. }
  40591. }
  40592. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40593. /** @hidden */
  40594. export var vrDistortionCorrectionPixelShader: {
  40595. name: string;
  40596. shader: string;
  40597. };
  40598. }
  40599. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40600. import { Camera } from "babylonjs/Cameras/camera";
  40601. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40602. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40603. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40604. /**
  40605. * VRDistortionCorrectionPostProcess used for mobile VR
  40606. */
  40607. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40608. private _isRightEye;
  40609. private _distortionFactors;
  40610. private _postProcessScaleFactor;
  40611. private _lensCenterOffset;
  40612. private _scaleIn;
  40613. private _scaleFactor;
  40614. private _lensCenter;
  40615. /**
  40616. * Initializes the VRDistortionCorrectionPostProcess
  40617. * @param name The name of the effect.
  40618. * @param camera The camera to apply the render pass to.
  40619. * @param isRightEye If this is for the right eye distortion
  40620. * @param vrMetrics All the required metrics for the VR camera
  40621. */
  40622. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40623. }
  40624. }
  40625. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40626. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40628. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40629. import { Scene } from "babylonjs/scene";
  40630. import { Vector3 } from "babylonjs/Maths/math.vector";
  40631. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40632. import "babylonjs/Cameras/RigModes/vrRigMode";
  40633. /**
  40634. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40635. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40636. */
  40637. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40638. /**
  40639. * Creates a new VRDeviceOrientationArcRotateCamera
  40640. * @param name defines camera name
  40641. * @param alpha defines the camera rotation along the logitudinal axis
  40642. * @param beta defines the camera rotation along the latitudinal axis
  40643. * @param radius defines the camera distance from its target
  40644. * @param target defines the camera target
  40645. * @param scene defines the scene the camera belongs to
  40646. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40647. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40648. */
  40649. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40650. /**
  40651. * Gets camera class name
  40652. * @returns VRDeviceOrientationArcRotateCamera
  40653. */
  40654. getClassName(): string;
  40655. }
  40656. }
  40657. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40658. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40659. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40660. import { Scene } from "babylonjs/scene";
  40661. import { Vector3 } from "babylonjs/Maths/math.vector";
  40662. import "babylonjs/Cameras/RigModes/vrRigMode";
  40663. /**
  40664. * Camera used to simulate VR rendering (based on FreeCamera)
  40665. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40666. */
  40667. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40668. /**
  40669. * Creates a new VRDeviceOrientationFreeCamera
  40670. * @param name defines camera name
  40671. * @param position defines the start position of the camera
  40672. * @param scene defines the scene the camera belongs to
  40673. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40674. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40675. */
  40676. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40677. /**
  40678. * Gets camera class name
  40679. * @returns VRDeviceOrientationFreeCamera
  40680. */
  40681. getClassName(): string;
  40682. }
  40683. }
  40684. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40685. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40686. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40687. import { Scene } from "babylonjs/scene";
  40688. import { Vector3 } from "babylonjs/Maths/math.vector";
  40689. import "babylonjs/Gamepads/gamepadSceneComponent";
  40690. /**
  40691. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40692. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40693. */
  40694. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40695. /**
  40696. * Creates a new VRDeviceOrientationGamepadCamera
  40697. * @param name defines camera name
  40698. * @param position defines the start position of the camera
  40699. * @param scene defines the scene the camera belongs to
  40700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40702. */
  40703. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40704. /**
  40705. * Gets camera class name
  40706. * @returns VRDeviceOrientationGamepadCamera
  40707. */
  40708. getClassName(): string;
  40709. }
  40710. }
  40711. declare module "babylonjs/Materials/pushMaterial" {
  40712. import { Nullable } from "babylonjs/types";
  40713. import { Scene } from "babylonjs/scene";
  40714. import { Matrix } from "babylonjs/Maths/math.vector";
  40715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40716. import { Mesh } from "babylonjs/Meshes/mesh";
  40717. import { Material } from "babylonjs/Materials/material";
  40718. import { Effect } from "babylonjs/Materials/effect";
  40719. /**
  40720. * Base class of materials working in push mode in babylon JS
  40721. * @hidden
  40722. */
  40723. export class PushMaterial extends Material {
  40724. protected _activeEffect: Effect;
  40725. protected _normalMatrix: Matrix;
  40726. /**
  40727. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40728. * This means that the material can keep using a previous shader while a new one is being compiled.
  40729. * This is mostly used when shader parallel compilation is supported (true by default)
  40730. */
  40731. allowShaderHotSwapping: boolean;
  40732. constructor(name: string, scene: Scene);
  40733. getEffect(): Effect;
  40734. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40735. /**
  40736. * Binds the given world matrix to the active effect
  40737. *
  40738. * @param world the matrix to bind
  40739. */
  40740. bindOnlyWorldMatrix(world: Matrix): void;
  40741. /**
  40742. * Binds the given normal matrix to the active effect
  40743. *
  40744. * @param normalMatrix the matrix to bind
  40745. */
  40746. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40747. bind(world: Matrix, mesh?: Mesh): void;
  40748. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40749. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40750. }
  40751. }
  40752. declare module "babylonjs/Materials/materialFlags" {
  40753. /**
  40754. * This groups all the flags used to control the materials channel.
  40755. */
  40756. export class MaterialFlags {
  40757. private static _DiffuseTextureEnabled;
  40758. /**
  40759. * Are diffuse textures enabled in the application.
  40760. */
  40761. static DiffuseTextureEnabled: boolean;
  40762. private static _AmbientTextureEnabled;
  40763. /**
  40764. * Are ambient textures enabled in the application.
  40765. */
  40766. static AmbientTextureEnabled: boolean;
  40767. private static _OpacityTextureEnabled;
  40768. /**
  40769. * Are opacity textures enabled in the application.
  40770. */
  40771. static OpacityTextureEnabled: boolean;
  40772. private static _ReflectionTextureEnabled;
  40773. /**
  40774. * Are reflection textures enabled in the application.
  40775. */
  40776. static ReflectionTextureEnabled: boolean;
  40777. private static _EmissiveTextureEnabled;
  40778. /**
  40779. * Are emissive textures enabled in the application.
  40780. */
  40781. static EmissiveTextureEnabled: boolean;
  40782. private static _SpecularTextureEnabled;
  40783. /**
  40784. * Are specular textures enabled in the application.
  40785. */
  40786. static SpecularTextureEnabled: boolean;
  40787. private static _BumpTextureEnabled;
  40788. /**
  40789. * Are bump textures enabled in the application.
  40790. */
  40791. static BumpTextureEnabled: boolean;
  40792. private static _LightmapTextureEnabled;
  40793. /**
  40794. * Are lightmap textures enabled in the application.
  40795. */
  40796. static LightmapTextureEnabled: boolean;
  40797. private static _RefractionTextureEnabled;
  40798. /**
  40799. * Are refraction textures enabled in the application.
  40800. */
  40801. static RefractionTextureEnabled: boolean;
  40802. private static _ColorGradingTextureEnabled;
  40803. /**
  40804. * Are color grading textures enabled in the application.
  40805. */
  40806. static ColorGradingTextureEnabled: boolean;
  40807. private static _FresnelEnabled;
  40808. /**
  40809. * Are fresnels enabled in the application.
  40810. */
  40811. static FresnelEnabled: boolean;
  40812. private static _ClearCoatTextureEnabled;
  40813. /**
  40814. * Are clear coat textures enabled in the application.
  40815. */
  40816. static ClearCoatTextureEnabled: boolean;
  40817. private static _ClearCoatBumpTextureEnabled;
  40818. /**
  40819. * Are clear coat bump textures enabled in the application.
  40820. */
  40821. static ClearCoatBumpTextureEnabled: boolean;
  40822. private static _ClearCoatTintTextureEnabled;
  40823. /**
  40824. * Are clear coat tint textures enabled in the application.
  40825. */
  40826. static ClearCoatTintTextureEnabled: boolean;
  40827. private static _SheenTextureEnabled;
  40828. /**
  40829. * Are sheen textures enabled in the application.
  40830. */
  40831. static SheenTextureEnabled: boolean;
  40832. private static _AnisotropicTextureEnabled;
  40833. /**
  40834. * Are anisotropic textures enabled in the application.
  40835. */
  40836. static AnisotropicTextureEnabled: boolean;
  40837. private static _ThicknessTextureEnabled;
  40838. /**
  40839. * Are thickness textures enabled in the application.
  40840. */
  40841. static ThicknessTextureEnabled: boolean;
  40842. }
  40843. }
  40844. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40845. /** @hidden */
  40846. export var defaultFragmentDeclaration: {
  40847. name: string;
  40848. shader: string;
  40849. };
  40850. }
  40851. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40852. /** @hidden */
  40853. export var defaultUboDeclaration: {
  40854. name: string;
  40855. shader: string;
  40856. };
  40857. }
  40858. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40859. /** @hidden */
  40860. export var lightFragmentDeclaration: {
  40861. name: string;
  40862. shader: string;
  40863. };
  40864. }
  40865. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40866. /** @hidden */
  40867. export var lightUboDeclaration: {
  40868. name: string;
  40869. shader: string;
  40870. };
  40871. }
  40872. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40873. /** @hidden */
  40874. export var lightsFragmentFunctions: {
  40875. name: string;
  40876. shader: string;
  40877. };
  40878. }
  40879. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40880. /** @hidden */
  40881. export var shadowsFragmentFunctions: {
  40882. name: string;
  40883. shader: string;
  40884. };
  40885. }
  40886. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40887. /** @hidden */
  40888. export var fresnelFunction: {
  40889. name: string;
  40890. shader: string;
  40891. };
  40892. }
  40893. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40894. /** @hidden */
  40895. export var reflectionFunction: {
  40896. name: string;
  40897. shader: string;
  40898. };
  40899. }
  40900. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40901. /** @hidden */
  40902. export var bumpFragmentFunctions: {
  40903. name: string;
  40904. shader: string;
  40905. };
  40906. }
  40907. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40908. /** @hidden */
  40909. export var logDepthDeclaration: {
  40910. name: string;
  40911. shader: string;
  40912. };
  40913. }
  40914. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40915. /** @hidden */
  40916. export var bumpFragment: {
  40917. name: string;
  40918. shader: string;
  40919. };
  40920. }
  40921. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40922. /** @hidden */
  40923. export var depthPrePass: {
  40924. name: string;
  40925. shader: string;
  40926. };
  40927. }
  40928. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40929. /** @hidden */
  40930. export var lightFragment: {
  40931. name: string;
  40932. shader: string;
  40933. };
  40934. }
  40935. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40936. /** @hidden */
  40937. export var logDepthFragment: {
  40938. name: string;
  40939. shader: string;
  40940. };
  40941. }
  40942. declare module "babylonjs/Shaders/default.fragment" {
  40943. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40944. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40946. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40947. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40948. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40949. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40950. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40951. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40952. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40953. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40954. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40955. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40956. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40957. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40958. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40959. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40960. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40961. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40962. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40963. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40964. /** @hidden */
  40965. export var defaultPixelShader: {
  40966. name: string;
  40967. shader: string;
  40968. };
  40969. }
  40970. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40971. /** @hidden */
  40972. export var defaultVertexDeclaration: {
  40973. name: string;
  40974. shader: string;
  40975. };
  40976. }
  40977. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40978. /** @hidden */
  40979. export var bumpVertexDeclaration: {
  40980. name: string;
  40981. shader: string;
  40982. };
  40983. }
  40984. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40985. /** @hidden */
  40986. export var bumpVertex: {
  40987. name: string;
  40988. shader: string;
  40989. };
  40990. }
  40991. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40992. /** @hidden */
  40993. export var fogVertex: {
  40994. name: string;
  40995. shader: string;
  40996. };
  40997. }
  40998. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40999. /** @hidden */
  41000. export var shadowsVertex: {
  41001. name: string;
  41002. shader: string;
  41003. };
  41004. }
  41005. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41006. /** @hidden */
  41007. export var pointCloudVertex: {
  41008. name: string;
  41009. shader: string;
  41010. };
  41011. }
  41012. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41013. /** @hidden */
  41014. export var logDepthVertex: {
  41015. name: string;
  41016. shader: string;
  41017. };
  41018. }
  41019. declare module "babylonjs/Shaders/default.vertex" {
  41020. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41021. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41023. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41024. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41025. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41026. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41027. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41028. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41029. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41030. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41032. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41034. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41035. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41036. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41037. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41038. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41039. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41040. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41041. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41042. /** @hidden */
  41043. export var defaultVertexShader: {
  41044. name: string;
  41045. shader: string;
  41046. };
  41047. }
  41048. declare module "babylonjs/Materials/standardMaterial" {
  41049. import { SmartArray } from "babylonjs/Misc/smartArray";
  41050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41051. import { Nullable } from "babylonjs/types";
  41052. import { Scene } from "babylonjs/scene";
  41053. import { Matrix } from "babylonjs/Maths/math.vector";
  41054. import { Color3 } from "babylonjs/Maths/math.color";
  41055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41057. import { Mesh } from "babylonjs/Meshes/mesh";
  41058. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41059. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41060. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41061. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41062. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41064. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41065. import "babylonjs/Shaders/default.fragment";
  41066. import "babylonjs/Shaders/default.vertex";
  41067. /** @hidden */
  41068. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41069. MAINUV1: boolean;
  41070. MAINUV2: boolean;
  41071. DIFFUSE: boolean;
  41072. DIFFUSEDIRECTUV: number;
  41073. AMBIENT: boolean;
  41074. AMBIENTDIRECTUV: number;
  41075. OPACITY: boolean;
  41076. OPACITYDIRECTUV: number;
  41077. OPACITYRGB: boolean;
  41078. REFLECTION: boolean;
  41079. EMISSIVE: boolean;
  41080. EMISSIVEDIRECTUV: number;
  41081. SPECULAR: boolean;
  41082. SPECULARDIRECTUV: number;
  41083. BUMP: boolean;
  41084. BUMPDIRECTUV: number;
  41085. PARALLAX: boolean;
  41086. PARALLAXOCCLUSION: boolean;
  41087. SPECULAROVERALPHA: boolean;
  41088. CLIPPLANE: boolean;
  41089. CLIPPLANE2: boolean;
  41090. CLIPPLANE3: boolean;
  41091. CLIPPLANE4: boolean;
  41092. ALPHATEST: boolean;
  41093. DEPTHPREPASS: boolean;
  41094. ALPHAFROMDIFFUSE: boolean;
  41095. POINTSIZE: boolean;
  41096. FOG: boolean;
  41097. SPECULARTERM: boolean;
  41098. DIFFUSEFRESNEL: boolean;
  41099. OPACITYFRESNEL: boolean;
  41100. REFLECTIONFRESNEL: boolean;
  41101. REFRACTIONFRESNEL: boolean;
  41102. EMISSIVEFRESNEL: boolean;
  41103. FRESNEL: boolean;
  41104. NORMAL: boolean;
  41105. UV1: boolean;
  41106. UV2: boolean;
  41107. VERTEXCOLOR: boolean;
  41108. VERTEXALPHA: boolean;
  41109. NUM_BONE_INFLUENCERS: number;
  41110. BonesPerMesh: number;
  41111. BONETEXTURE: boolean;
  41112. INSTANCES: boolean;
  41113. GLOSSINESS: boolean;
  41114. ROUGHNESS: boolean;
  41115. EMISSIVEASILLUMINATION: boolean;
  41116. LINKEMISSIVEWITHDIFFUSE: boolean;
  41117. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41118. LIGHTMAP: boolean;
  41119. LIGHTMAPDIRECTUV: number;
  41120. OBJECTSPACE_NORMALMAP: boolean;
  41121. USELIGHTMAPASSHADOWMAP: boolean;
  41122. REFLECTIONMAP_3D: boolean;
  41123. REFLECTIONMAP_SPHERICAL: boolean;
  41124. REFLECTIONMAP_PLANAR: boolean;
  41125. REFLECTIONMAP_CUBIC: boolean;
  41126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41127. REFLECTIONMAP_PROJECTION: boolean;
  41128. REFLECTIONMAP_SKYBOX: boolean;
  41129. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41130. REFLECTIONMAP_EXPLICIT: boolean;
  41131. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41132. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41133. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41134. INVERTCUBICMAP: boolean;
  41135. LOGARITHMICDEPTH: boolean;
  41136. REFRACTION: boolean;
  41137. REFRACTIONMAP_3D: boolean;
  41138. REFLECTIONOVERALPHA: boolean;
  41139. TWOSIDEDLIGHTING: boolean;
  41140. SHADOWFLOAT: boolean;
  41141. MORPHTARGETS: boolean;
  41142. MORPHTARGETS_NORMAL: boolean;
  41143. MORPHTARGETS_TANGENT: boolean;
  41144. MORPHTARGETS_UV: boolean;
  41145. NUM_MORPH_INFLUENCERS: number;
  41146. NONUNIFORMSCALING: boolean;
  41147. PREMULTIPLYALPHA: boolean;
  41148. IMAGEPROCESSING: boolean;
  41149. VIGNETTE: boolean;
  41150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41151. VIGNETTEBLENDMODEOPAQUE: boolean;
  41152. TONEMAPPING: boolean;
  41153. TONEMAPPING_ACES: boolean;
  41154. CONTRAST: boolean;
  41155. COLORCURVES: boolean;
  41156. COLORGRADING: boolean;
  41157. COLORGRADING3D: boolean;
  41158. SAMPLER3DGREENDEPTH: boolean;
  41159. SAMPLER3DBGRMAP: boolean;
  41160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41161. MULTIVIEW: boolean;
  41162. /**
  41163. * If the reflection texture on this material is in linear color space
  41164. * @hidden
  41165. */
  41166. IS_REFLECTION_LINEAR: boolean;
  41167. /**
  41168. * If the refraction texture on this material is in linear color space
  41169. * @hidden
  41170. */
  41171. IS_REFRACTION_LINEAR: boolean;
  41172. EXPOSURE: boolean;
  41173. constructor();
  41174. setReflectionMode(modeToEnable: string): void;
  41175. }
  41176. /**
  41177. * This is the default material used in Babylon. It is the best trade off between quality
  41178. * and performances.
  41179. * @see http://doc.babylonjs.com/babylon101/materials
  41180. */
  41181. export class StandardMaterial extends PushMaterial {
  41182. private _diffuseTexture;
  41183. /**
  41184. * The basic texture of the material as viewed under a light.
  41185. */
  41186. diffuseTexture: Nullable<BaseTexture>;
  41187. private _ambientTexture;
  41188. /**
  41189. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41190. */
  41191. ambientTexture: Nullable<BaseTexture>;
  41192. private _opacityTexture;
  41193. /**
  41194. * Define the transparency of the material from a texture.
  41195. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41196. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41197. */
  41198. opacityTexture: Nullable<BaseTexture>;
  41199. private _reflectionTexture;
  41200. /**
  41201. * Define the texture used to display the reflection.
  41202. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41203. */
  41204. reflectionTexture: Nullable<BaseTexture>;
  41205. private _emissiveTexture;
  41206. /**
  41207. * Define texture of the material as if self lit.
  41208. * This will be mixed in the final result even in the absence of light.
  41209. */
  41210. emissiveTexture: Nullable<BaseTexture>;
  41211. private _specularTexture;
  41212. /**
  41213. * Define how the color and intensity of the highlight given by the light in the material.
  41214. */
  41215. specularTexture: Nullable<BaseTexture>;
  41216. private _bumpTexture;
  41217. /**
  41218. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41219. * 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.
  41220. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41221. */
  41222. bumpTexture: Nullable<BaseTexture>;
  41223. private _lightmapTexture;
  41224. /**
  41225. * Complex lighting can be computationally expensive to compute at runtime.
  41226. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41227. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41228. */
  41229. lightmapTexture: Nullable<BaseTexture>;
  41230. private _refractionTexture;
  41231. /**
  41232. * Define the texture used to display the refraction.
  41233. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41234. */
  41235. refractionTexture: Nullable<BaseTexture>;
  41236. /**
  41237. * The color of the material lit by the environmental background lighting.
  41238. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41239. */
  41240. ambientColor: Color3;
  41241. /**
  41242. * The basic color of the material as viewed under a light.
  41243. */
  41244. diffuseColor: Color3;
  41245. /**
  41246. * Define how the color and intensity of the highlight given by the light in the material.
  41247. */
  41248. specularColor: Color3;
  41249. /**
  41250. * Define the color of the material as if self lit.
  41251. * This will be mixed in the final result even in the absence of light.
  41252. */
  41253. emissiveColor: Color3;
  41254. /**
  41255. * Defines how sharp are the highlights in the material.
  41256. * The bigger the value the sharper giving a more glossy feeling to the result.
  41257. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41258. */
  41259. specularPower: number;
  41260. private _useAlphaFromDiffuseTexture;
  41261. /**
  41262. * Does the transparency come from the diffuse texture alpha channel.
  41263. */
  41264. useAlphaFromDiffuseTexture: boolean;
  41265. private _useEmissiveAsIllumination;
  41266. /**
  41267. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41268. */
  41269. useEmissiveAsIllumination: boolean;
  41270. private _linkEmissiveWithDiffuse;
  41271. /**
  41272. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41273. * the emissive level when the final color is close to one.
  41274. */
  41275. linkEmissiveWithDiffuse: boolean;
  41276. private _useSpecularOverAlpha;
  41277. /**
  41278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41280. */
  41281. useSpecularOverAlpha: boolean;
  41282. private _useReflectionOverAlpha;
  41283. /**
  41284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41286. */
  41287. useReflectionOverAlpha: boolean;
  41288. private _disableLighting;
  41289. /**
  41290. * Does lights from the scene impacts this material.
  41291. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41292. */
  41293. disableLighting: boolean;
  41294. private _useObjectSpaceNormalMap;
  41295. /**
  41296. * Allows using an object space normal map (instead of tangent space).
  41297. */
  41298. useObjectSpaceNormalMap: boolean;
  41299. private _useParallax;
  41300. /**
  41301. * Is parallax enabled or not.
  41302. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41303. */
  41304. useParallax: boolean;
  41305. private _useParallaxOcclusion;
  41306. /**
  41307. * Is parallax occlusion enabled or not.
  41308. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41309. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41310. */
  41311. useParallaxOcclusion: boolean;
  41312. /**
  41313. * 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.
  41314. */
  41315. parallaxScaleBias: number;
  41316. private _roughness;
  41317. /**
  41318. * Helps to define how blurry the reflections should appears in the material.
  41319. */
  41320. roughness: number;
  41321. /**
  41322. * In case of refraction, define the value of the index of refraction.
  41323. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41324. */
  41325. indexOfRefraction: number;
  41326. /**
  41327. * Invert the refraction texture alongside the y axis.
  41328. * It can be useful with procedural textures or probe for instance.
  41329. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41330. */
  41331. invertRefractionY: boolean;
  41332. /**
  41333. * Defines the alpha limits in alpha test mode.
  41334. */
  41335. alphaCutOff: number;
  41336. private _useLightmapAsShadowmap;
  41337. /**
  41338. * In case of light mapping, define whether the map contains light or shadow informations.
  41339. */
  41340. useLightmapAsShadowmap: boolean;
  41341. private _diffuseFresnelParameters;
  41342. /**
  41343. * Define the diffuse fresnel parameters of the material.
  41344. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41345. */
  41346. diffuseFresnelParameters: FresnelParameters;
  41347. private _opacityFresnelParameters;
  41348. /**
  41349. * Define the opacity fresnel parameters of the material.
  41350. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41351. */
  41352. opacityFresnelParameters: FresnelParameters;
  41353. private _reflectionFresnelParameters;
  41354. /**
  41355. * Define the reflection fresnel parameters of the material.
  41356. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41357. */
  41358. reflectionFresnelParameters: FresnelParameters;
  41359. private _refractionFresnelParameters;
  41360. /**
  41361. * Define the refraction fresnel parameters of the material.
  41362. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41363. */
  41364. refractionFresnelParameters: FresnelParameters;
  41365. private _emissiveFresnelParameters;
  41366. /**
  41367. * Define the emissive fresnel parameters of the material.
  41368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41369. */
  41370. emissiveFresnelParameters: FresnelParameters;
  41371. private _useReflectionFresnelFromSpecular;
  41372. /**
  41373. * If true automatically deducts the fresnels values from the material specularity.
  41374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41375. */
  41376. useReflectionFresnelFromSpecular: boolean;
  41377. private _useGlossinessFromSpecularMapAlpha;
  41378. /**
  41379. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41380. */
  41381. useGlossinessFromSpecularMapAlpha: boolean;
  41382. private _maxSimultaneousLights;
  41383. /**
  41384. * Defines the maximum number of lights that can be used in the material
  41385. */
  41386. maxSimultaneousLights: number;
  41387. private _invertNormalMapX;
  41388. /**
  41389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41390. */
  41391. invertNormalMapX: boolean;
  41392. private _invertNormalMapY;
  41393. /**
  41394. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41395. */
  41396. invertNormalMapY: boolean;
  41397. private _twoSidedLighting;
  41398. /**
  41399. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41400. */
  41401. twoSidedLighting: boolean;
  41402. /**
  41403. * Default configuration related to image processing available in the standard Material.
  41404. */
  41405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41406. /**
  41407. * Gets the image processing configuration used either in this material.
  41408. */
  41409. /**
  41410. * Sets the Default image processing configuration used either in the this material.
  41411. *
  41412. * If sets to null, the scene one is in use.
  41413. */
  41414. imageProcessingConfiguration: ImageProcessingConfiguration;
  41415. /**
  41416. * Keep track of the image processing observer to allow dispose and replace.
  41417. */
  41418. private _imageProcessingObserver;
  41419. /**
  41420. * Attaches a new image processing configuration to the Standard Material.
  41421. * @param configuration
  41422. */
  41423. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41424. /**
  41425. * Gets wether the color curves effect is enabled.
  41426. */
  41427. /**
  41428. * Sets wether the color curves effect is enabled.
  41429. */
  41430. cameraColorCurvesEnabled: boolean;
  41431. /**
  41432. * Gets wether the color grading effect is enabled.
  41433. */
  41434. /**
  41435. * Gets wether the color grading effect is enabled.
  41436. */
  41437. cameraColorGradingEnabled: boolean;
  41438. /**
  41439. * Gets wether tonemapping is enabled or not.
  41440. */
  41441. /**
  41442. * Sets wether tonemapping is enabled or not
  41443. */
  41444. cameraToneMappingEnabled: boolean;
  41445. /**
  41446. * The camera exposure used on this material.
  41447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41448. * This corresponds to a photographic exposure.
  41449. */
  41450. /**
  41451. * The camera exposure used on this material.
  41452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41453. * This corresponds to a photographic exposure.
  41454. */
  41455. cameraExposure: number;
  41456. /**
  41457. * Gets The camera contrast used on this material.
  41458. */
  41459. /**
  41460. * Sets The camera contrast used on this material.
  41461. */
  41462. cameraContrast: number;
  41463. /**
  41464. * Gets the Color Grading 2D Lookup Texture.
  41465. */
  41466. /**
  41467. * Sets the Color Grading 2D Lookup Texture.
  41468. */
  41469. cameraColorGradingTexture: Nullable<BaseTexture>;
  41470. /**
  41471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41473. * 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;
  41474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41475. */
  41476. /**
  41477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41479. * 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;
  41480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41481. */
  41482. cameraColorCurves: Nullable<ColorCurves>;
  41483. /**
  41484. * Custom callback helping to override the default shader used in the material.
  41485. */
  41486. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41487. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41488. protected _worldViewProjectionMatrix: Matrix;
  41489. protected _globalAmbientColor: Color3;
  41490. protected _useLogarithmicDepth: boolean;
  41491. /**
  41492. * Instantiates a new standard material.
  41493. * This is the default material used in Babylon. It is the best trade off between quality
  41494. * and performances.
  41495. * @see http://doc.babylonjs.com/babylon101/materials
  41496. * @param name Define the name of the material in the scene
  41497. * @param scene Define the scene the material belong to
  41498. */
  41499. constructor(name: string, scene: Scene);
  41500. /**
  41501. * Gets a boolean indicating that current material needs to register RTT
  41502. */
  41503. readonly hasRenderTargetTextures: boolean;
  41504. /**
  41505. * Gets the current class name of the material e.g. "StandardMaterial"
  41506. * Mainly use in serialization.
  41507. * @returns the class name
  41508. */
  41509. getClassName(): string;
  41510. /**
  41511. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41512. * You can try switching to logarithmic depth.
  41513. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41514. */
  41515. useLogarithmicDepth: boolean;
  41516. /**
  41517. * Specifies if the material will require alpha blending
  41518. * @returns a boolean specifying if alpha blending is needed
  41519. */
  41520. needAlphaBlending(): boolean;
  41521. /**
  41522. * Specifies if this material should be rendered in alpha test mode
  41523. * @returns a boolean specifying if an alpha test is needed.
  41524. */
  41525. needAlphaTesting(): boolean;
  41526. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41527. /**
  41528. * Get the texture used for alpha test purpose.
  41529. * @returns the diffuse texture in case of the standard material.
  41530. */
  41531. getAlphaTestTexture(): Nullable<BaseTexture>;
  41532. /**
  41533. * Get if the submesh is ready to be used and all its information available.
  41534. * Child classes can use it to update shaders
  41535. * @param mesh defines the mesh to check
  41536. * @param subMesh defines which submesh to check
  41537. * @param useInstances specifies that instances should be used
  41538. * @returns a boolean indicating that the submesh is ready or not
  41539. */
  41540. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41541. /**
  41542. * Builds the material UBO layouts.
  41543. * Used internally during the effect preparation.
  41544. */
  41545. buildUniformLayout(): void;
  41546. /**
  41547. * Unbinds the material from the mesh
  41548. */
  41549. unbind(): void;
  41550. /**
  41551. * Binds the submesh to this material by preparing the effect and shader to draw
  41552. * @param world defines the world transformation matrix
  41553. * @param mesh defines the mesh containing the submesh
  41554. * @param subMesh defines the submesh to bind the material to
  41555. */
  41556. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41557. /**
  41558. * Get the list of animatables in the material.
  41559. * @returns the list of animatables object used in the material
  41560. */
  41561. getAnimatables(): IAnimatable[];
  41562. /**
  41563. * Gets the active textures from the material
  41564. * @returns an array of textures
  41565. */
  41566. getActiveTextures(): BaseTexture[];
  41567. /**
  41568. * Specifies if the material uses a texture
  41569. * @param texture defines the texture to check against the material
  41570. * @returns a boolean specifying if the material uses the texture
  41571. */
  41572. hasTexture(texture: BaseTexture): boolean;
  41573. /**
  41574. * Disposes the material
  41575. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41576. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41577. */
  41578. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41579. /**
  41580. * Makes a duplicate of the material, and gives it a new name
  41581. * @param name defines the new name for the duplicated material
  41582. * @returns the cloned material
  41583. */
  41584. clone(name: string): StandardMaterial;
  41585. /**
  41586. * Serializes this material in a JSON representation
  41587. * @returns the serialized material object
  41588. */
  41589. serialize(): any;
  41590. /**
  41591. * Creates a standard material from parsed material data
  41592. * @param source defines the JSON representation of the material
  41593. * @param scene defines the hosting scene
  41594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41595. * @returns a new standard material
  41596. */
  41597. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41598. /**
  41599. * Are diffuse textures enabled in the application.
  41600. */
  41601. static DiffuseTextureEnabled: boolean;
  41602. /**
  41603. * Are ambient textures enabled in the application.
  41604. */
  41605. static AmbientTextureEnabled: boolean;
  41606. /**
  41607. * Are opacity textures enabled in the application.
  41608. */
  41609. static OpacityTextureEnabled: boolean;
  41610. /**
  41611. * Are reflection textures enabled in the application.
  41612. */
  41613. static ReflectionTextureEnabled: boolean;
  41614. /**
  41615. * Are emissive textures enabled in the application.
  41616. */
  41617. static EmissiveTextureEnabled: boolean;
  41618. /**
  41619. * Are specular textures enabled in the application.
  41620. */
  41621. static SpecularTextureEnabled: boolean;
  41622. /**
  41623. * Are bump textures enabled in the application.
  41624. */
  41625. static BumpTextureEnabled: boolean;
  41626. /**
  41627. * Are lightmap textures enabled in the application.
  41628. */
  41629. static LightmapTextureEnabled: boolean;
  41630. /**
  41631. * Are refraction textures enabled in the application.
  41632. */
  41633. static RefractionTextureEnabled: boolean;
  41634. /**
  41635. * Are color grading textures enabled in the application.
  41636. */
  41637. static ColorGradingTextureEnabled: boolean;
  41638. /**
  41639. * Are fresnels enabled in the application.
  41640. */
  41641. static FresnelEnabled: boolean;
  41642. }
  41643. }
  41644. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41645. import { Scene } from "babylonjs/scene";
  41646. import { Texture } from "babylonjs/Materials/Textures/texture";
  41647. /**
  41648. * A class extending Texture allowing drawing on a texture
  41649. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41650. */
  41651. export class DynamicTexture extends Texture {
  41652. private _generateMipMaps;
  41653. private _canvas;
  41654. private _context;
  41655. private _engine;
  41656. /**
  41657. * Creates a DynamicTexture
  41658. * @param name defines the name of the texture
  41659. * @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
  41660. * @param scene defines the scene where you want the texture
  41661. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41662. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41663. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41664. */
  41665. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41666. /**
  41667. * Get the current class name of the texture useful for serialization or dynamic coding.
  41668. * @returns "DynamicTexture"
  41669. */
  41670. getClassName(): string;
  41671. /**
  41672. * Gets the current state of canRescale
  41673. */
  41674. readonly canRescale: boolean;
  41675. private _recreate;
  41676. /**
  41677. * Scales the texture
  41678. * @param ratio the scale factor to apply to both width and height
  41679. */
  41680. scale(ratio: number): void;
  41681. /**
  41682. * Resizes the texture
  41683. * @param width the new width
  41684. * @param height the new height
  41685. */
  41686. scaleTo(width: number, height: number): void;
  41687. /**
  41688. * Gets the context of the canvas used by the texture
  41689. * @returns the canvas context of the dynamic texture
  41690. */
  41691. getContext(): CanvasRenderingContext2D;
  41692. /**
  41693. * Clears the texture
  41694. */
  41695. clear(): void;
  41696. /**
  41697. * Updates the texture
  41698. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41699. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41700. */
  41701. update(invertY?: boolean, premulAlpha?: boolean): void;
  41702. /**
  41703. * Draws text onto the texture
  41704. * @param text defines the text to be drawn
  41705. * @param x defines the placement of the text from the left
  41706. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41707. * @param font defines the font to be used with font-style, font-size, font-name
  41708. * @param color defines the color used for the text
  41709. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41710. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41711. * @param update defines whether texture is immediately update (default is true)
  41712. */
  41713. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41714. /**
  41715. * Clones the texture
  41716. * @returns the clone of the texture.
  41717. */
  41718. clone(): DynamicTexture;
  41719. /**
  41720. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41721. * @returns a serialized dynamic texture object
  41722. */
  41723. serialize(): any;
  41724. /** @hidden */
  41725. _rebuild(): void;
  41726. }
  41727. }
  41728. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41729. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41730. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41731. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41732. /** @hidden */
  41733. export var imageProcessingPixelShader: {
  41734. name: string;
  41735. shader: string;
  41736. };
  41737. }
  41738. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41739. import { Nullable } from "babylonjs/types";
  41740. import { Color4 } from "babylonjs/Maths/math.color";
  41741. import { Camera } from "babylonjs/Cameras/camera";
  41742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41743. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41744. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41746. import { Engine } from "babylonjs/Engines/engine";
  41747. import "babylonjs/Shaders/imageProcessing.fragment";
  41748. import "babylonjs/Shaders/postprocess.vertex";
  41749. /**
  41750. * ImageProcessingPostProcess
  41751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41752. */
  41753. export class ImageProcessingPostProcess extends PostProcess {
  41754. /**
  41755. * Default configuration related to image processing available in the PBR Material.
  41756. */
  41757. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41758. /**
  41759. * Gets the image processing configuration used either in this material.
  41760. */
  41761. /**
  41762. * Sets the Default image processing configuration used either in the this material.
  41763. *
  41764. * If sets to null, the scene one is in use.
  41765. */
  41766. imageProcessingConfiguration: ImageProcessingConfiguration;
  41767. /**
  41768. * Keep track of the image processing observer to allow dispose and replace.
  41769. */
  41770. private _imageProcessingObserver;
  41771. /**
  41772. * Attaches a new image processing configuration to the PBR Material.
  41773. * @param configuration
  41774. */
  41775. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41776. /**
  41777. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41778. */
  41779. /**
  41780. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41781. */
  41782. colorCurves: Nullable<ColorCurves>;
  41783. /**
  41784. * Gets wether the color curves effect is enabled.
  41785. */
  41786. /**
  41787. * Sets wether the color curves effect is enabled.
  41788. */
  41789. colorCurvesEnabled: boolean;
  41790. /**
  41791. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41792. */
  41793. /**
  41794. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41795. */
  41796. colorGradingTexture: Nullable<BaseTexture>;
  41797. /**
  41798. * Gets wether the color grading effect is enabled.
  41799. */
  41800. /**
  41801. * Gets wether the color grading effect is enabled.
  41802. */
  41803. colorGradingEnabled: boolean;
  41804. /**
  41805. * Gets exposure used in the effect.
  41806. */
  41807. /**
  41808. * Sets exposure used in the effect.
  41809. */
  41810. exposure: number;
  41811. /**
  41812. * Gets wether tonemapping is enabled or not.
  41813. */
  41814. /**
  41815. * Sets wether tonemapping is enabled or not
  41816. */
  41817. toneMappingEnabled: boolean;
  41818. /**
  41819. * Gets the type of tone mapping effect.
  41820. */
  41821. /**
  41822. * Sets the type of tone mapping effect.
  41823. */
  41824. toneMappingType: number;
  41825. /**
  41826. * Gets contrast used in the effect.
  41827. */
  41828. /**
  41829. * Sets contrast used in the effect.
  41830. */
  41831. contrast: number;
  41832. /**
  41833. * Gets Vignette stretch size.
  41834. */
  41835. /**
  41836. * Sets Vignette stretch size.
  41837. */
  41838. vignetteStretch: number;
  41839. /**
  41840. * Gets Vignette centre X Offset.
  41841. */
  41842. /**
  41843. * Sets Vignette centre X Offset.
  41844. */
  41845. vignetteCentreX: number;
  41846. /**
  41847. * Gets Vignette centre Y Offset.
  41848. */
  41849. /**
  41850. * Sets Vignette centre Y Offset.
  41851. */
  41852. vignetteCentreY: number;
  41853. /**
  41854. * Gets Vignette weight or intensity of the vignette effect.
  41855. */
  41856. /**
  41857. * Sets Vignette weight or intensity of the vignette effect.
  41858. */
  41859. vignetteWeight: number;
  41860. /**
  41861. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41862. * if vignetteEnabled is set to true.
  41863. */
  41864. /**
  41865. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41866. * if vignetteEnabled is set to true.
  41867. */
  41868. vignetteColor: Color4;
  41869. /**
  41870. * Gets Camera field of view used by the Vignette effect.
  41871. */
  41872. /**
  41873. * Sets Camera field of view used by the Vignette effect.
  41874. */
  41875. vignetteCameraFov: number;
  41876. /**
  41877. * Gets the vignette blend mode allowing different kind of effect.
  41878. */
  41879. /**
  41880. * Sets the vignette blend mode allowing different kind of effect.
  41881. */
  41882. vignetteBlendMode: number;
  41883. /**
  41884. * Gets wether the vignette effect is enabled.
  41885. */
  41886. /**
  41887. * Sets wether the vignette effect is enabled.
  41888. */
  41889. vignetteEnabled: boolean;
  41890. private _fromLinearSpace;
  41891. /**
  41892. * Gets wether the input of the processing is in Gamma or Linear Space.
  41893. */
  41894. /**
  41895. * Sets wether the input of the processing is in Gamma or Linear Space.
  41896. */
  41897. fromLinearSpace: boolean;
  41898. /**
  41899. * Defines cache preventing GC.
  41900. */
  41901. private _defines;
  41902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41903. /**
  41904. * "ImageProcessingPostProcess"
  41905. * @returns "ImageProcessingPostProcess"
  41906. */
  41907. getClassName(): string;
  41908. protected _updateParameters(): void;
  41909. dispose(camera?: Camera): void;
  41910. }
  41911. }
  41912. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41913. import { Scene } from "babylonjs/scene";
  41914. import { Color3 } from "babylonjs/Maths/math.color";
  41915. import { Mesh } from "babylonjs/Meshes/mesh";
  41916. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41917. import { Nullable } from "babylonjs/types";
  41918. /**
  41919. * Class containing static functions to help procedurally build meshes
  41920. */
  41921. export class GroundBuilder {
  41922. /**
  41923. * Creates a ground mesh
  41924. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41925. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41927. * @param name defines the name of the mesh
  41928. * @param options defines the options used to create the mesh
  41929. * @param scene defines the hosting scene
  41930. * @returns the ground mesh
  41931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41932. */
  41933. static CreateGround(name: string, options: {
  41934. width?: number;
  41935. height?: number;
  41936. subdivisions?: number;
  41937. subdivisionsX?: number;
  41938. subdivisionsY?: number;
  41939. updatable?: boolean;
  41940. }, scene: any): Mesh;
  41941. /**
  41942. * Creates a tiled ground mesh
  41943. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41944. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41945. * * 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
  41946. * * 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
  41947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41948. * @param name defines the name of the mesh
  41949. * @param options defines the options used to create the mesh
  41950. * @param scene defines the hosting scene
  41951. * @returns the tiled ground mesh
  41952. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41953. */
  41954. static CreateTiledGround(name: string, options: {
  41955. xmin: number;
  41956. zmin: number;
  41957. xmax: number;
  41958. zmax: number;
  41959. subdivisions?: {
  41960. w: number;
  41961. h: number;
  41962. };
  41963. precision?: {
  41964. w: number;
  41965. h: number;
  41966. };
  41967. updatable?: boolean;
  41968. }, scene?: Nullable<Scene>): Mesh;
  41969. /**
  41970. * Creates a ground mesh from a height map
  41971. * * The parameter `url` sets the URL of the height map image resource.
  41972. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41973. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41974. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41975. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41976. * * 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.
  41977. * * 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).
  41978. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41980. * @param name defines the name of the mesh
  41981. * @param url defines the url to the height map
  41982. * @param options defines the options used to create the mesh
  41983. * @param scene defines the hosting scene
  41984. * @returns the ground mesh
  41985. * @see https://doc.babylonjs.com/babylon101/height_map
  41986. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41987. */
  41988. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41989. width?: number;
  41990. height?: number;
  41991. subdivisions?: number;
  41992. minHeight?: number;
  41993. maxHeight?: number;
  41994. colorFilter?: Color3;
  41995. alphaFilter?: number;
  41996. updatable?: boolean;
  41997. onReady?: (mesh: GroundMesh) => void;
  41998. }, scene?: Nullable<Scene>): GroundMesh;
  41999. }
  42000. }
  42001. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42002. import { Vector4 } from "babylonjs/Maths/math.vector";
  42003. import { Mesh } from "babylonjs/Meshes/mesh";
  42004. /**
  42005. * Class containing static functions to help procedurally build meshes
  42006. */
  42007. export class TorusBuilder {
  42008. /**
  42009. * Creates a torus mesh
  42010. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42011. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42012. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42016. * @param name defines the name of the mesh
  42017. * @param options defines the options used to create the mesh
  42018. * @param scene defines the hosting scene
  42019. * @returns the torus mesh
  42020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42021. */
  42022. static CreateTorus(name: string, options: {
  42023. diameter?: number;
  42024. thickness?: number;
  42025. tessellation?: number;
  42026. updatable?: boolean;
  42027. sideOrientation?: number;
  42028. frontUVs?: Vector4;
  42029. backUVs?: Vector4;
  42030. }, scene: any): Mesh;
  42031. }
  42032. }
  42033. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42034. import { Vector4 } from "babylonjs/Maths/math.vector";
  42035. import { Color4 } from "babylonjs/Maths/math.color";
  42036. import { Mesh } from "babylonjs/Meshes/mesh";
  42037. /**
  42038. * Class containing static functions to help procedurally build meshes
  42039. */
  42040. export class CylinderBuilder {
  42041. /**
  42042. * Creates a cylinder or a cone mesh
  42043. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42044. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42045. * * 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.
  42046. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42047. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42048. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42049. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42050. * * 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).
  42051. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42052. * * 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).
  42053. * * 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
  42054. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42055. * * 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
  42056. * * 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.
  42057. * * If `enclose` is false, a ring surface is one element.
  42058. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42059. * * 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
  42060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42063. * @param name defines the name of the mesh
  42064. * @param options defines the options used to create the mesh
  42065. * @param scene defines the hosting scene
  42066. * @returns the cylinder mesh
  42067. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42068. */
  42069. static CreateCylinder(name: string, options: {
  42070. height?: number;
  42071. diameterTop?: number;
  42072. diameterBottom?: number;
  42073. diameter?: number;
  42074. tessellation?: number;
  42075. subdivisions?: number;
  42076. arc?: number;
  42077. faceColors?: Color4[];
  42078. faceUV?: Vector4[];
  42079. updatable?: boolean;
  42080. hasRings?: boolean;
  42081. enclose?: boolean;
  42082. cap?: number;
  42083. sideOrientation?: number;
  42084. frontUVs?: Vector4;
  42085. backUVs?: Vector4;
  42086. }, scene: any): Mesh;
  42087. }
  42088. }
  42089. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42090. import { Observable } from "babylonjs/Misc/observable";
  42091. import { Nullable } from "babylonjs/types";
  42092. import { Camera } from "babylonjs/Cameras/camera";
  42093. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42094. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42095. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42096. import { Scene } from "babylonjs/scene";
  42097. import { Vector3 } from "babylonjs/Maths/math.vector";
  42098. import { Color3 } from "babylonjs/Maths/math.color";
  42099. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42101. import { Mesh } from "babylonjs/Meshes/mesh";
  42102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42104. import "babylonjs/Meshes/Builders/groundBuilder";
  42105. import "babylonjs/Meshes/Builders/torusBuilder";
  42106. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42107. import "babylonjs/Gamepads/gamepadSceneComponent";
  42108. import "babylonjs/Animations/animatable";
  42109. /**
  42110. * Options to modify the vr teleportation behavior.
  42111. */
  42112. export interface VRTeleportationOptions {
  42113. /**
  42114. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42115. */
  42116. floorMeshName?: string;
  42117. /**
  42118. * A list of meshes to be used as the teleportation floor. (default: empty)
  42119. */
  42120. floorMeshes?: Mesh[];
  42121. }
  42122. /**
  42123. * Options to modify the vr experience helper's behavior.
  42124. */
  42125. export interface VRExperienceHelperOptions extends WebVROptions {
  42126. /**
  42127. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42128. */
  42129. createDeviceOrientationCamera?: boolean;
  42130. /**
  42131. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42132. */
  42133. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42134. /**
  42135. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42136. */
  42137. laserToggle?: boolean;
  42138. /**
  42139. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42140. */
  42141. floorMeshes?: Mesh[];
  42142. /**
  42143. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42144. */
  42145. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42146. }
  42147. /**
  42148. * Event containing information after VR has been entered
  42149. */
  42150. export class OnAfterEnteringVRObservableEvent {
  42151. /**
  42152. * If entering vr was successful
  42153. */
  42154. success: boolean;
  42155. }
  42156. /**
  42157. * Helps to quickly add VR support to an existing scene.
  42158. * See http://doc.babylonjs.com/how_to/webvr_helper
  42159. */
  42160. export class VRExperienceHelper {
  42161. /** Options to modify the vr experience helper's behavior. */
  42162. webVROptions: VRExperienceHelperOptions;
  42163. private _scene;
  42164. private _position;
  42165. private _btnVR;
  42166. private _btnVRDisplayed;
  42167. private _webVRsupported;
  42168. private _webVRready;
  42169. private _webVRrequesting;
  42170. private _webVRpresenting;
  42171. private _hasEnteredVR;
  42172. private _fullscreenVRpresenting;
  42173. private _canvas;
  42174. private _webVRCamera;
  42175. private _vrDeviceOrientationCamera;
  42176. private _deviceOrientationCamera;
  42177. private _existingCamera;
  42178. private _onKeyDown;
  42179. private _onVrDisplayPresentChange;
  42180. private _onVRDisplayChanged;
  42181. private _onVRRequestPresentStart;
  42182. private _onVRRequestPresentComplete;
  42183. /**
  42184. * 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)
  42185. */
  42186. enableGazeEvenWhenNoPointerLock: boolean;
  42187. /**
  42188. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42189. */
  42190. exitVROnDoubleTap: boolean;
  42191. /**
  42192. * Observable raised right before entering VR.
  42193. */
  42194. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42195. /**
  42196. * Observable raised when entering VR has completed.
  42197. */
  42198. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42199. /**
  42200. * Observable raised when exiting VR.
  42201. */
  42202. onExitingVRObservable: Observable<VRExperienceHelper>;
  42203. /**
  42204. * Observable raised when controller mesh is loaded.
  42205. */
  42206. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42207. /** Return this.onEnteringVRObservable
  42208. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42209. */
  42210. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42211. /** Return this.onExitingVRObservable
  42212. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42213. */
  42214. readonly onExitingVR: Observable<VRExperienceHelper>;
  42215. /** Return this.onControllerMeshLoadedObservable
  42216. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42217. */
  42218. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42219. private _rayLength;
  42220. private _useCustomVRButton;
  42221. private _teleportationRequested;
  42222. private _teleportActive;
  42223. private _floorMeshName;
  42224. private _floorMeshesCollection;
  42225. private _rotationAllowed;
  42226. private _teleportBackwardsVector;
  42227. private _teleportationTarget;
  42228. private _isDefaultTeleportationTarget;
  42229. private _postProcessMove;
  42230. private _teleportationFillColor;
  42231. private _teleportationBorderColor;
  42232. private _rotationAngle;
  42233. private _haloCenter;
  42234. private _cameraGazer;
  42235. private _padSensibilityUp;
  42236. private _padSensibilityDown;
  42237. private _leftController;
  42238. private _rightController;
  42239. /**
  42240. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42241. */
  42242. onNewMeshSelected: Observable<AbstractMesh>;
  42243. /**
  42244. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42245. */
  42246. onNewMeshPicked: Observable<PickingInfo>;
  42247. private _circleEase;
  42248. /**
  42249. * Observable raised before camera teleportation
  42250. */
  42251. onBeforeCameraTeleport: Observable<Vector3>;
  42252. /**
  42253. * Observable raised after camera teleportation
  42254. */
  42255. onAfterCameraTeleport: Observable<Vector3>;
  42256. /**
  42257. * Observable raised when current selected mesh gets unselected
  42258. */
  42259. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42260. private _raySelectionPredicate;
  42261. /**
  42262. * To be optionaly changed by user to define custom ray selection
  42263. */
  42264. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42265. /**
  42266. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42267. */
  42268. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42269. /**
  42270. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42271. */
  42272. teleportationEnabled: boolean;
  42273. private _defaultHeight;
  42274. private _teleportationInitialized;
  42275. private _interactionsEnabled;
  42276. private _interactionsRequested;
  42277. private _displayGaze;
  42278. private _displayLaserPointer;
  42279. /**
  42280. * The mesh used to display where the user is going to teleport.
  42281. */
  42282. /**
  42283. * Sets the mesh to be used to display where the user is going to teleport.
  42284. */
  42285. teleportationTarget: Mesh;
  42286. /**
  42287. * 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
  42288. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42289. * See http://doc.babylonjs.com/resources/baking_transformations
  42290. */
  42291. gazeTrackerMesh: Mesh;
  42292. /**
  42293. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42294. */
  42295. updateGazeTrackerScale: boolean;
  42296. /**
  42297. * If the gaze trackers color should be updated when selecting meshes
  42298. */
  42299. updateGazeTrackerColor: boolean;
  42300. /**
  42301. * The gaze tracking mesh corresponding to the left controller
  42302. */
  42303. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42304. /**
  42305. * The gaze tracking mesh corresponding to the right controller
  42306. */
  42307. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42308. /**
  42309. * If the ray of the gaze should be displayed.
  42310. */
  42311. /**
  42312. * Sets if the ray of the gaze should be displayed.
  42313. */
  42314. displayGaze: boolean;
  42315. /**
  42316. * If the ray of the LaserPointer should be displayed.
  42317. */
  42318. /**
  42319. * Sets if the ray of the LaserPointer should be displayed.
  42320. */
  42321. displayLaserPointer: boolean;
  42322. /**
  42323. * The deviceOrientationCamera used as the camera when not in VR.
  42324. */
  42325. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42326. /**
  42327. * Based on the current WebVR support, returns the current VR camera used.
  42328. */
  42329. readonly currentVRCamera: Nullable<Camera>;
  42330. /**
  42331. * The webVRCamera which is used when in VR.
  42332. */
  42333. readonly webVRCamera: WebVRFreeCamera;
  42334. /**
  42335. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42336. */
  42337. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42338. /**
  42339. * The html button that is used to trigger entering into VR.
  42340. */
  42341. readonly vrButton: Nullable<HTMLButtonElement>;
  42342. private readonly _teleportationRequestInitiated;
  42343. /**
  42344. * Defines wether or not Pointer lock should be requested when switching to
  42345. * full screen.
  42346. */
  42347. requestPointerLockOnFullScreen: boolean;
  42348. /**
  42349. * Instantiates a VRExperienceHelper.
  42350. * Helps to quickly add VR support to an existing scene.
  42351. * @param scene The scene the VRExperienceHelper belongs to.
  42352. * @param webVROptions Options to modify the vr experience helper's behavior.
  42353. */
  42354. constructor(scene: Scene,
  42355. /** Options to modify the vr experience helper's behavior. */
  42356. webVROptions?: VRExperienceHelperOptions);
  42357. private _onDefaultMeshLoaded;
  42358. private _onResize;
  42359. private _onFullscreenChange;
  42360. /**
  42361. * Gets a value indicating if we are currently in VR mode.
  42362. */
  42363. readonly isInVRMode: boolean;
  42364. private onVrDisplayPresentChange;
  42365. private onVRDisplayChanged;
  42366. private moveButtonToBottomRight;
  42367. private displayVRButton;
  42368. private updateButtonVisibility;
  42369. private _cachedAngularSensibility;
  42370. /**
  42371. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42372. * Otherwise, will use the fullscreen API.
  42373. */
  42374. enterVR(): void;
  42375. /**
  42376. * Attempt to exit VR, or fullscreen.
  42377. */
  42378. exitVR(): void;
  42379. /**
  42380. * The position of the vr experience helper.
  42381. */
  42382. /**
  42383. * Sets the position of the vr experience helper.
  42384. */
  42385. position: Vector3;
  42386. /**
  42387. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42388. */
  42389. enableInteractions(): void;
  42390. private readonly _noControllerIsActive;
  42391. private beforeRender;
  42392. private _isTeleportationFloor;
  42393. /**
  42394. * Adds a floor mesh to be used for teleportation.
  42395. * @param floorMesh the mesh to be used for teleportation.
  42396. */
  42397. addFloorMesh(floorMesh: Mesh): void;
  42398. /**
  42399. * Removes a floor mesh from being used for teleportation.
  42400. * @param floorMesh the mesh to be removed.
  42401. */
  42402. removeFloorMesh(floorMesh: Mesh): void;
  42403. /**
  42404. * Enables interactions and teleportation using the VR controllers and gaze.
  42405. * @param vrTeleportationOptions options to modify teleportation behavior.
  42406. */
  42407. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42408. private _onNewGamepadConnected;
  42409. private _tryEnableInteractionOnController;
  42410. private _onNewGamepadDisconnected;
  42411. private _enableInteractionOnController;
  42412. private _checkTeleportWithRay;
  42413. private _checkRotate;
  42414. private _checkTeleportBackwards;
  42415. private _enableTeleportationOnController;
  42416. private _createTeleportationCircles;
  42417. private _displayTeleportationTarget;
  42418. private _hideTeleportationTarget;
  42419. private _rotateCamera;
  42420. private _moveTeleportationSelectorTo;
  42421. private _workingVector;
  42422. private _workingQuaternion;
  42423. private _workingMatrix;
  42424. /**
  42425. * Teleports the users feet to the desired location
  42426. * @param location The location where the user's feet should be placed
  42427. */
  42428. teleportCamera(location: Vector3): void;
  42429. private _convertNormalToDirectionOfRay;
  42430. private _castRayAndSelectObject;
  42431. private _notifySelectedMeshUnselected;
  42432. /**
  42433. * Sets the color of the laser ray from the vr controllers.
  42434. * @param color new color for the ray.
  42435. */
  42436. changeLaserColor(color: Color3): void;
  42437. /**
  42438. * Sets the color of the ray from the vr headsets gaze.
  42439. * @param color new color for the ray.
  42440. */
  42441. changeGazeColor(color: Color3): void;
  42442. /**
  42443. * Exits VR and disposes of the vr experience helper
  42444. */
  42445. dispose(): void;
  42446. /**
  42447. * Gets the name of the VRExperienceHelper class
  42448. * @returns "VRExperienceHelper"
  42449. */
  42450. getClassName(): string;
  42451. }
  42452. }
  42453. declare module "babylonjs/Cameras/VR/index" {
  42454. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42455. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42456. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42457. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42458. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42459. export * from "babylonjs/Cameras/VR/webVRCamera";
  42460. }
  42461. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42462. import { Observable } from "babylonjs/Misc/observable";
  42463. import { Nullable } from "babylonjs/types";
  42464. import { IDisposable, Scene } from "babylonjs/scene";
  42465. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42466. /**
  42467. * Manages an XRSession to work with Babylon's engine
  42468. * @see https://doc.babylonjs.com/how_to/webxr
  42469. */
  42470. export class WebXRSessionManager implements IDisposable {
  42471. private scene;
  42472. /**
  42473. * Fires every time a new xrFrame arrives which can be used to update the camera
  42474. */
  42475. onXRFrameObservable: Observable<any>;
  42476. /**
  42477. * Fires when the xr session is ended either by the device or manually done
  42478. */
  42479. onXRSessionEnded: Observable<any>;
  42480. /**
  42481. * Underlying xr session
  42482. */
  42483. session: XRSession;
  42484. /**
  42485. * Type of reference space used when creating the session
  42486. */
  42487. referenceSpace: XRReferenceSpace;
  42488. /** @hidden */
  42489. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42490. /**
  42491. * Current XR frame
  42492. */
  42493. currentFrame: Nullable<XRFrame>;
  42494. private _xrNavigator;
  42495. private baseLayer;
  42496. /**
  42497. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42498. * @param scene The scene which the session should be created for
  42499. */
  42500. constructor(scene: Scene);
  42501. /**
  42502. * Initializes the manager
  42503. * After initialization enterXR can be called to start an XR session
  42504. * @returns Promise which resolves after it is initialized
  42505. */
  42506. initializeAsync(): Promise<void>;
  42507. /**
  42508. * Initializes an xr session
  42509. * @param xrSessionMode mode to initialize
  42510. * @returns a promise which will resolve once the session has been initialized
  42511. */
  42512. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42513. /**
  42514. * Sets the reference space on the xr session
  42515. * @param referenceSpace space to set
  42516. * @returns a promise that will resolve once the reference space has been set
  42517. */
  42518. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42519. /**
  42520. * Updates the render state of the session
  42521. * @param state state to set
  42522. * @returns a promise that resolves once the render state has been updated
  42523. */
  42524. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42525. /**
  42526. * Starts rendering to the xr layer
  42527. * @returns a promise that will resolve once rendering has started
  42528. */
  42529. startRenderingToXRAsync(): Promise<void>;
  42530. /**
  42531. * Stops the xrSession and restores the renderloop
  42532. * @returns Promise which resolves after it exits XR
  42533. */
  42534. exitXRAsync(): Promise<unknown>;
  42535. /**
  42536. * Checks if a session would be supported for the creation options specified
  42537. * @param sessionMode session mode to check if supported eg. immersive-vr
  42538. * @returns true if supported
  42539. */
  42540. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42541. /**
  42542. * @hidden
  42543. * Converts the render layer of xrSession to a render target
  42544. * @param session session to create render target for
  42545. * @param scene scene the new render target should be created for
  42546. */
  42547. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42548. /**
  42549. * Disposes of the session manager
  42550. */
  42551. dispose(): void;
  42552. }
  42553. }
  42554. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42555. import { Scene } from "babylonjs/scene";
  42556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42557. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42558. /**
  42559. * WebXR Camera which holds the views for the xrSession
  42560. * @see https://doc.babylonjs.com/how_to/webxr
  42561. */
  42562. export class WebXRCamera extends FreeCamera {
  42563. private static _TmpMatrix;
  42564. /**
  42565. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42566. * @param name the name of the camera
  42567. * @param scene the scene to add the camera to
  42568. */
  42569. constructor(name: string, scene: Scene);
  42570. private _updateNumberOfRigCameras;
  42571. /** @hidden */
  42572. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42573. /**
  42574. * Updates the cameras position from the current pose information of the XR session
  42575. * @param xrSessionManager the session containing pose information
  42576. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42577. */
  42578. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42579. }
  42580. }
  42581. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42582. import { Nullable } from "babylonjs/types";
  42583. import { IDisposable } from "babylonjs/scene";
  42584. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42585. /**
  42586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42587. */
  42588. export class WebXRManagedOutputCanvas implements IDisposable {
  42589. private helper;
  42590. private _canvas;
  42591. /**
  42592. * xrpresent context of the canvas which can be used to display/mirror xr content
  42593. */
  42594. canvasContext: WebGLRenderingContext;
  42595. /**
  42596. * xr layer for the canvas
  42597. */
  42598. xrLayer: Nullable<XRWebGLLayer>;
  42599. /**
  42600. * Initializes the xr layer for the session
  42601. * @param xrSession xr session
  42602. * @returns a promise that will resolve once the XR Layer has been created
  42603. */
  42604. initializeXRLayerAsync(xrSession: any): any;
  42605. /**
  42606. * Initializes the canvas to be added/removed upon entering/exiting xr
  42607. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42608. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42609. */
  42610. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42611. /**
  42612. * Disposes of the object
  42613. */
  42614. dispose(): void;
  42615. private _setManagedOutputCanvas;
  42616. private _addCanvas;
  42617. private _removeCanvas;
  42618. }
  42619. }
  42620. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42621. import { Observable } from "babylonjs/Misc/observable";
  42622. import { IDisposable, Scene } from "babylonjs/scene";
  42623. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42625. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42626. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42627. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42628. /**
  42629. * States of the webXR experience
  42630. */
  42631. export enum WebXRState {
  42632. /**
  42633. * Transitioning to being in XR mode
  42634. */
  42635. ENTERING_XR = 0,
  42636. /**
  42637. * Transitioning to non XR mode
  42638. */
  42639. EXITING_XR = 1,
  42640. /**
  42641. * In XR mode and presenting
  42642. */
  42643. IN_XR = 2,
  42644. /**
  42645. * Not entered XR mode
  42646. */
  42647. NOT_IN_XR = 3
  42648. }
  42649. /**
  42650. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42651. * @see https://doc.babylonjs.com/how_to/webxr
  42652. */
  42653. export class WebXRExperienceHelper implements IDisposable {
  42654. private scene;
  42655. /**
  42656. * 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
  42657. */
  42658. container: AbstractMesh;
  42659. /**
  42660. * Camera used to render xr content
  42661. */
  42662. camera: WebXRCamera;
  42663. /**
  42664. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42665. */
  42666. state: WebXRState;
  42667. private _setState;
  42668. private static _TmpVector;
  42669. /**
  42670. * Fires when the state of the experience helper has changed
  42671. */
  42672. onStateChangedObservable: Observable<WebXRState>;
  42673. /** Session manager used to keep track of xr session */
  42674. sessionManager: WebXRSessionManager;
  42675. private _nonVRCamera;
  42676. private _originalSceneAutoClear;
  42677. private _supported;
  42678. /**
  42679. * Creates the experience helper
  42680. * @param scene the scene to attach the experience helper to
  42681. * @returns a promise for the experience helper
  42682. */
  42683. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42684. /**
  42685. * Creates a WebXRExperienceHelper
  42686. * @param scene The scene the helper should be created in
  42687. */
  42688. private constructor();
  42689. /**
  42690. * Exits XR mode and returns the scene to its original state
  42691. * @returns promise that resolves after xr mode has exited
  42692. */
  42693. exitXRAsync(): Promise<unknown>;
  42694. /**
  42695. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42696. * @param sessionCreationOptions options for the XR session
  42697. * @param referenceSpaceType frame of reference of the XR session
  42698. * @param outputCanvas the output canvas that will be used to enter XR mode
  42699. * @returns promise that resolves after xr mode has entered
  42700. */
  42701. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42702. /**
  42703. * Updates the global position of the camera by moving the camera's container
  42704. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42705. * @param position The desired global position of the camera
  42706. */
  42707. setPositionOfCameraUsingContainer(position: Vector3): void;
  42708. /**
  42709. * Rotates the xr camera by rotating the camera's container around the camera's position
  42710. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42711. * @param rotation the desired quaternion rotation to apply to the camera
  42712. */
  42713. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42714. /**
  42715. * Disposes of the experience helper
  42716. */
  42717. dispose(): void;
  42718. }
  42719. }
  42720. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42721. import { Nullable } from "babylonjs/types";
  42722. import { Observable } from "babylonjs/Misc/observable";
  42723. import { IDisposable, Scene } from "babylonjs/scene";
  42724. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42725. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42726. /**
  42727. * Button which can be used to enter a different mode of XR
  42728. */
  42729. export class WebXREnterExitUIButton {
  42730. /** button element */
  42731. element: HTMLElement;
  42732. /** XR initialization options for the button */
  42733. sessionMode: XRSessionMode;
  42734. /** Reference space type */
  42735. referenceSpaceType: XRReferenceSpaceType;
  42736. /**
  42737. * Creates a WebXREnterExitUIButton
  42738. * @param element button element
  42739. * @param sessionMode XR initialization session mode
  42740. * @param referenceSpaceType the type of reference space to be used
  42741. */
  42742. constructor(
  42743. /** button element */
  42744. element: HTMLElement,
  42745. /** XR initialization options for the button */
  42746. sessionMode: XRSessionMode,
  42747. /** Reference space type */
  42748. referenceSpaceType: XRReferenceSpaceType);
  42749. /**
  42750. * Overwritable function which can be used to update the button's visuals when the state changes
  42751. * @param activeButton the current active button in the UI
  42752. */
  42753. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42754. }
  42755. /**
  42756. * Options to create the webXR UI
  42757. */
  42758. export class WebXREnterExitUIOptions {
  42759. /**
  42760. * Context to enter xr with
  42761. */
  42762. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42763. /**
  42764. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42765. */
  42766. customButtons?: Array<WebXREnterExitUIButton>;
  42767. }
  42768. /**
  42769. * UI to allow the user to enter/exit XR mode
  42770. */
  42771. export class WebXREnterExitUI implements IDisposable {
  42772. private scene;
  42773. private _overlay;
  42774. private _buttons;
  42775. private _activeButton;
  42776. /**
  42777. * Fired every time the active button is changed.
  42778. *
  42779. * When xr is entered via a button that launches xr that button will be the callback parameter
  42780. *
  42781. * When exiting xr the callback parameter will be null)
  42782. */
  42783. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42784. /**
  42785. * Creates UI to allow the user to enter/exit XR mode
  42786. * @param scene the scene to add the ui to
  42787. * @param helper the xr experience helper to enter/exit xr with
  42788. * @param options options to configure the UI
  42789. * @returns the created ui
  42790. */
  42791. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42792. private constructor();
  42793. private _updateButtons;
  42794. /**
  42795. * Disposes of the object
  42796. */
  42797. dispose(): void;
  42798. }
  42799. }
  42800. declare module "babylonjs/Cameras/XR/webXRController" {
  42801. import { Nullable } from "babylonjs/types";
  42802. import { Observable } from "babylonjs/Misc/observable";
  42803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42804. import { Ray } from "babylonjs/Culling/ray";
  42805. import { Scene } from "babylonjs/scene";
  42806. /**
  42807. * Represents an XR input
  42808. */
  42809. export class WebXRController {
  42810. private scene;
  42811. /** The underlying input source for the controller */
  42812. inputSource: XRInputSource;
  42813. private parentContainer;
  42814. /**
  42815. * 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
  42816. */
  42817. grip?: AbstractMesh;
  42818. /**
  42819. * Pointer which can be used to select objects or attach a visible laser to
  42820. */
  42821. pointer: AbstractMesh;
  42822. /**
  42823. * Event that fires when the controller is removed/disposed
  42824. */
  42825. onDisposeObservable: Observable<{}>;
  42826. private _tmpMatrix;
  42827. private _tmpQuaternion;
  42828. private _tmpVector;
  42829. /**
  42830. * Creates the controller
  42831. * @see https://doc.babylonjs.com/how_to/webxr
  42832. * @param scene the scene which the controller should be associated to
  42833. * @param inputSource the underlying input source for the controller
  42834. * @param parentContainer parent that the controller meshes should be children of
  42835. */
  42836. constructor(scene: Scene,
  42837. /** The underlying input source for the controller */
  42838. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42839. /**
  42840. * Updates the controller pose based on the given XRFrame
  42841. * @param xrFrame xr frame to update the pose with
  42842. * @param referenceSpace reference space to use
  42843. */
  42844. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42845. /**
  42846. * Gets a world space ray coming from the controller
  42847. * @param result the resulting ray
  42848. */
  42849. getWorldPointerRayToRef(result: Ray): void;
  42850. /**
  42851. * Disposes of the object
  42852. */
  42853. dispose(): void;
  42854. }
  42855. }
  42856. declare module "babylonjs/Cameras/XR/webXRInput" {
  42857. import { Observable } from "babylonjs/Misc/observable";
  42858. import { IDisposable } from "babylonjs/scene";
  42859. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42860. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42861. /**
  42862. * XR input used to track XR inputs such as controllers/rays
  42863. */
  42864. export class WebXRInput implements IDisposable {
  42865. /**
  42866. * Base experience the input listens to
  42867. */
  42868. baseExperience: WebXRExperienceHelper;
  42869. /**
  42870. * XR controllers being tracked
  42871. */
  42872. controllers: Array<WebXRController>;
  42873. private _frameObserver;
  42874. private _stateObserver;
  42875. /**
  42876. * Event when a controller has been connected/added
  42877. */
  42878. onControllerAddedObservable: Observable<WebXRController>;
  42879. /**
  42880. * Event when a controller has been removed/disconnected
  42881. */
  42882. onControllerRemovedObservable: Observable<WebXRController>;
  42883. /**
  42884. * Initializes the WebXRInput
  42885. * @param baseExperience experience helper which the input should be created for
  42886. */
  42887. constructor(
  42888. /**
  42889. * Base experience the input listens to
  42890. */
  42891. baseExperience: WebXRExperienceHelper);
  42892. private _onInputSourcesChange;
  42893. private _addAndRemoveControllers;
  42894. /**
  42895. * Disposes of the object
  42896. */
  42897. dispose(): void;
  42898. }
  42899. }
  42900. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42902. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42903. /**
  42904. * Enables teleportation
  42905. */
  42906. export class WebXRControllerTeleportation {
  42907. private _teleportationFillColor;
  42908. private _teleportationBorderColor;
  42909. private _tmpRay;
  42910. private _tmpVector;
  42911. /**
  42912. * Creates a WebXRControllerTeleportation
  42913. * @param input input manager to add teleportation to
  42914. * @param floorMeshes floormeshes which can be teleported to
  42915. */
  42916. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42917. }
  42918. }
  42919. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42920. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42921. /**
  42922. * Handles pointer input automatically for the pointer of XR controllers
  42923. */
  42924. export class WebXRControllerPointerSelection {
  42925. private static _idCounter;
  42926. private _tmpRay;
  42927. /**
  42928. * Creates a WebXRControllerPointerSelection
  42929. * @param input input manager to setup pointer selection
  42930. */
  42931. constructor(input: WebXRInput);
  42932. private _convertNormalToDirectionOfRay;
  42933. private _updatePointerDistance;
  42934. }
  42935. }
  42936. declare module "babylonjs/Loading/sceneLoader" {
  42937. import { Observable } from "babylonjs/Misc/observable";
  42938. import { Nullable } from "babylonjs/types";
  42939. import { Scene } from "babylonjs/scene";
  42940. import { Engine } from "babylonjs/Engines/engine";
  42941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42942. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42943. import { AssetContainer } from "babylonjs/assetContainer";
  42944. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42945. import { Skeleton } from "babylonjs/Bones/skeleton";
  42946. /**
  42947. * Class used to represent data loading progression
  42948. */
  42949. export class SceneLoaderProgressEvent {
  42950. /** defines if data length to load can be evaluated */
  42951. readonly lengthComputable: boolean;
  42952. /** defines the loaded data length */
  42953. readonly loaded: number;
  42954. /** defines the data length to load */
  42955. readonly total: number;
  42956. /**
  42957. * Create a new progress event
  42958. * @param lengthComputable defines if data length to load can be evaluated
  42959. * @param loaded defines the loaded data length
  42960. * @param total defines the data length to load
  42961. */
  42962. constructor(
  42963. /** defines if data length to load can be evaluated */
  42964. lengthComputable: boolean,
  42965. /** defines the loaded data length */
  42966. loaded: number,
  42967. /** defines the data length to load */
  42968. total: number);
  42969. /**
  42970. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42971. * @param event defines the source event
  42972. * @returns a new SceneLoaderProgressEvent
  42973. */
  42974. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42975. }
  42976. /**
  42977. * Interface used by SceneLoader plugins to define supported file extensions
  42978. */
  42979. export interface ISceneLoaderPluginExtensions {
  42980. /**
  42981. * Defines the list of supported extensions
  42982. */
  42983. [extension: string]: {
  42984. isBinary: boolean;
  42985. };
  42986. }
  42987. /**
  42988. * Interface used by SceneLoader plugin factory
  42989. */
  42990. export interface ISceneLoaderPluginFactory {
  42991. /**
  42992. * Defines the name of the factory
  42993. */
  42994. name: string;
  42995. /**
  42996. * Function called to create a new plugin
  42997. * @return the new plugin
  42998. */
  42999. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43000. /**
  43001. * Boolean indicating if the plugin can direct load specific data
  43002. */
  43003. canDirectLoad?: (data: string) => boolean;
  43004. }
  43005. /**
  43006. * Interface used to define a SceneLoader plugin
  43007. */
  43008. export interface ISceneLoaderPlugin {
  43009. /**
  43010. * The friendly name of this plugin.
  43011. */
  43012. name: string;
  43013. /**
  43014. * The file extensions supported by this plugin.
  43015. */
  43016. extensions: string | ISceneLoaderPluginExtensions;
  43017. /**
  43018. * Import meshes into a scene.
  43019. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43020. * @param scene The scene to import into
  43021. * @param data The data to import
  43022. * @param rootUrl The root url for scene and resources
  43023. * @param meshes The meshes array to import into
  43024. * @param particleSystems The particle systems array to import into
  43025. * @param skeletons The skeletons array to import into
  43026. * @param onError The callback when import fails
  43027. * @returns True if successful or false otherwise
  43028. */
  43029. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43030. /**
  43031. * Load into a scene.
  43032. * @param scene The scene to load into
  43033. * @param data The data to import
  43034. * @param rootUrl The root url for scene and resources
  43035. * @param onError The callback when import fails
  43036. * @returns true if successful or false otherwise
  43037. */
  43038. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43039. /**
  43040. * The callback that returns true if the data can be directly loaded.
  43041. */
  43042. canDirectLoad?: (data: string) => boolean;
  43043. /**
  43044. * The callback that allows custom handling of the root url based on the response url.
  43045. */
  43046. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43047. /**
  43048. * Load into an asset container.
  43049. * @param scene The scene to load into
  43050. * @param data The data to import
  43051. * @param rootUrl The root url for scene and resources
  43052. * @param onError The callback when import fails
  43053. * @returns The loaded asset container
  43054. */
  43055. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43056. }
  43057. /**
  43058. * Interface used to define an async SceneLoader plugin
  43059. */
  43060. export interface ISceneLoaderPluginAsync {
  43061. /**
  43062. * The friendly name of this plugin.
  43063. */
  43064. name: string;
  43065. /**
  43066. * The file extensions supported by this plugin.
  43067. */
  43068. extensions: string | ISceneLoaderPluginExtensions;
  43069. /**
  43070. * Import meshes into a scene.
  43071. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43072. * @param scene The scene to import into
  43073. * @param data The data to import
  43074. * @param rootUrl The root url for scene and resources
  43075. * @param onProgress The callback when the load progresses
  43076. * @param fileName Defines the name of the file to load
  43077. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43078. */
  43079. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43080. meshes: AbstractMesh[];
  43081. particleSystems: IParticleSystem[];
  43082. skeletons: Skeleton[];
  43083. animationGroups: AnimationGroup[];
  43084. }>;
  43085. /**
  43086. * Load into a scene.
  43087. * @param scene The scene to load into
  43088. * @param data The data to import
  43089. * @param rootUrl The root url for scene and resources
  43090. * @param onProgress The callback when the load progresses
  43091. * @param fileName Defines the name of the file to load
  43092. * @returns Nothing
  43093. */
  43094. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43095. /**
  43096. * The callback that returns true if the data can be directly loaded.
  43097. */
  43098. canDirectLoad?: (data: string) => boolean;
  43099. /**
  43100. * The callback that allows custom handling of the root url based on the response url.
  43101. */
  43102. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43103. /**
  43104. * Load into an asset container.
  43105. * @param scene The scene to load into
  43106. * @param data The data to import
  43107. * @param rootUrl The root url for scene and resources
  43108. * @param onProgress The callback when the load progresses
  43109. * @param fileName Defines the name of the file to load
  43110. * @returns The loaded asset container
  43111. */
  43112. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43113. }
  43114. /**
  43115. * Class used to load scene from various file formats using registered plugins
  43116. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43117. */
  43118. export class SceneLoader {
  43119. /**
  43120. * No logging while loading
  43121. */
  43122. static readonly NO_LOGGING: number;
  43123. /**
  43124. * Minimal logging while loading
  43125. */
  43126. static readonly MINIMAL_LOGGING: number;
  43127. /**
  43128. * Summary logging while loading
  43129. */
  43130. static readonly SUMMARY_LOGGING: number;
  43131. /**
  43132. * Detailled logging while loading
  43133. */
  43134. static readonly DETAILED_LOGGING: number;
  43135. /**
  43136. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43137. */
  43138. static ForceFullSceneLoadingForIncremental: boolean;
  43139. /**
  43140. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43141. */
  43142. static ShowLoadingScreen: boolean;
  43143. /**
  43144. * Defines the current logging level (while loading the scene)
  43145. * @ignorenaming
  43146. */
  43147. static loggingLevel: number;
  43148. /**
  43149. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43150. */
  43151. static CleanBoneMatrixWeights: boolean;
  43152. /**
  43153. * Event raised when a plugin is used to load a scene
  43154. */
  43155. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43156. private static _registeredPlugins;
  43157. private static _getDefaultPlugin;
  43158. private static _getPluginForExtension;
  43159. private static _getPluginForDirectLoad;
  43160. private static _getPluginForFilename;
  43161. private static _getDirectLoad;
  43162. private static _loadData;
  43163. private static _getFileInfo;
  43164. /**
  43165. * Gets a plugin that can load the given extension
  43166. * @param extension defines the extension to load
  43167. * @returns a plugin or null if none works
  43168. */
  43169. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43170. /**
  43171. * Gets a boolean indicating that the given extension can be loaded
  43172. * @param extension defines the extension to load
  43173. * @returns true if the extension is supported
  43174. */
  43175. static IsPluginForExtensionAvailable(extension: string): boolean;
  43176. /**
  43177. * Adds a new plugin to the list of registered plugins
  43178. * @param plugin defines the plugin to add
  43179. */
  43180. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43181. /**
  43182. * Import meshes into a scene
  43183. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43184. * @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)
  43185. * @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)
  43186. * @param scene the instance of BABYLON.Scene to append to
  43187. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43188. * @param onProgress a callback with a progress event for each file being loaded
  43189. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43190. * @param pluginExtension the extension used to determine the plugin
  43191. * @returns The loaded plugin
  43192. */
  43193. 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>;
  43194. /**
  43195. * Import meshes into a scene
  43196. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43197. * @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)
  43198. * @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)
  43199. * @param scene the instance of BABYLON.Scene to append to
  43200. * @param onProgress a callback with a progress event for each file being loaded
  43201. * @param pluginExtension the extension used to determine the plugin
  43202. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43203. */
  43204. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43205. meshes: AbstractMesh[];
  43206. particleSystems: IParticleSystem[];
  43207. skeletons: Skeleton[];
  43208. animationGroups: AnimationGroup[];
  43209. }>;
  43210. /**
  43211. * Load a scene
  43212. * @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)
  43213. * @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)
  43214. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43215. * @param onSuccess a callback with the scene when import succeeds
  43216. * @param onProgress a callback with a progress event for each file being loaded
  43217. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43218. * @param pluginExtension the extension used to determine the plugin
  43219. * @returns The loaded plugin
  43220. */
  43221. 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>;
  43222. /**
  43223. * Load a scene
  43224. * @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)
  43225. * @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)
  43226. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43227. * @param onProgress a callback with a progress event for each file being loaded
  43228. * @param pluginExtension the extension used to determine the plugin
  43229. * @returns The loaded scene
  43230. */
  43231. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43232. /**
  43233. * Append a scene
  43234. * @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)
  43235. * @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)
  43236. * @param scene is the instance of BABYLON.Scene to append to
  43237. * @param onSuccess a callback with the scene when import succeeds
  43238. * @param onProgress a callback with a progress event for each file being loaded
  43239. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43240. * @param pluginExtension the extension used to determine the plugin
  43241. * @returns The loaded plugin
  43242. */
  43243. 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>;
  43244. /**
  43245. * Append a scene
  43246. * @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)
  43247. * @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)
  43248. * @param scene is the instance of BABYLON.Scene to append to
  43249. * @param onProgress a callback with a progress event for each file being loaded
  43250. * @param pluginExtension the extension used to determine the plugin
  43251. * @returns The given scene
  43252. */
  43253. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43254. /**
  43255. * Load a scene into an asset container
  43256. * @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)
  43257. * @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)
  43258. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43259. * @param onSuccess a callback with the scene when import succeeds
  43260. * @param onProgress a callback with a progress event for each file being loaded
  43261. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43262. * @param pluginExtension the extension used to determine the plugin
  43263. * @returns The loaded plugin
  43264. */
  43265. 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>;
  43266. /**
  43267. * Load a scene into an asset container
  43268. * @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)
  43269. * @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)
  43270. * @param scene is the instance of Scene to append to
  43271. * @param onProgress a callback with a progress event for each file being loaded
  43272. * @param pluginExtension the extension used to determine the plugin
  43273. * @returns The loaded asset container
  43274. */
  43275. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43276. }
  43277. }
  43278. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43279. import { Scene } from "babylonjs/scene";
  43280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43281. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43282. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43283. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43284. /**
  43285. * Generic Controller
  43286. */
  43287. export class GenericController extends WebVRController {
  43288. /**
  43289. * Base Url for the controller model.
  43290. */
  43291. static readonly MODEL_BASE_URL: string;
  43292. /**
  43293. * File name for the controller model.
  43294. */
  43295. static readonly MODEL_FILENAME: string;
  43296. /**
  43297. * Creates a new GenericController from a gamepad
  43298. * @param vrGamepad the gamepad that the controller should be created from
  43299. */
  43300. constructor(vrGamepad: any);
  43301. /**
  43302. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43303. * @param scene scene in which to add meshes
  43304. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43305. */
  43306. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43307. /**
  43308. * Called once for each button that changed state since the last frame
  43309. * @param buttonIdx Which button index changed
  43310. * @param state New state of the button
  43311. * @param changes Which properties on the state changed since last frame
  43312. */
  43313. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43314. }
  43315. }
  43316. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43317. import { Observable } from "babylonjs/Misc/observable";
  43318. import { Scene } from "babylonjs/scene";
  43319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43320. import { Ray } from "babylonjs/Culling/ray";
  43321. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43322. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43323. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43324. /**
  43325. * Defines the WindowsMotionController object that the state of the windows motion controller
  43326. */
  43327. export class WindowsMotionController extends WebVRController {
  43328. /**
  43329. * The base url used to load the left and right controller models
  43330. */
  43331. static MODEL_BASE_URL: string;
  43332. /**
  43333. * The name of the left controller model file
  43334. */
  43335. static MODEL_LEFT_FILENAME: string;
  43336. /**
  43337. * The name of the right controller model file
  43338. */
  43339. static MODEL_RIGHT_FILENAME: string;
  43340. /**
  43341. * The controller name prefix for this controller type
  43342. */
  43343. static readonly GAMEPAD_ID_PREFIX: string;
  43344. /**
  43345. * The controller id pattern for this controller type
  43346. */
  43347. private static readonly GAMEPAD_ID_PATTERN;
  43348. private _loadedMeshInfo;
  43349. private readonly _mapping;
  43350. /**
  43351. * Fired when the trackpad on this controller is clicked
  43352. */
  43353. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43354. /**
  43355. * Fired when the trackpad on this controller is modified
  43356. */
  43357. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43358. /**
  43359. * The current x and y values of this controller's trackpad
  43360. */
  43361. trackpad: StickValues;
  43362. /**
  43363. * Creates a new WindowsMotionController from a gamepad
  43364. * @param vrGamepad the gamepad that the controller should be created from
  43365. */
  43366. constructor(vrGamepad: any);
  43367. /**
  43368. * Fired when the trigger on this controller is modified
  43369. */
  43370. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43371. /**
  43372. * Fired when the menu button on this controller is modified
  43373. */
  43374. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43375. /**
  43376. * Fired when the grip button on this controller is modified
  43377. */
  43378. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43379. /**
  43380. * Fired when the thumbstick button on this controller is modified
  43381. */
  43382. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43383. /**
  43384. * Fired when the touchpad button on this controller is modified
  43385. */
  43386. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43387. /**
  43388. * Fired when the touchpad values on this controller are modified
  43389. */
  43390. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43391. private _updateTrackpad;
  43392. /**
  43393. * Called once per frame by the engine.
  43394. */
  43395. update(): void;
  43396. /**
  43397. * Called once for each button that changed state since the last frame
  43398. * @param buttonIdx Which button index changed
  43399. * @param state New state of the button
  43400. * @param changes Which properties on the state changed since last frame
  43401. */
  43402. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43403. /**
  43404. * Moves the buttons on the controller mesh based on their current state
  43405. * @param buttonName the name of the button to move
  43406. * @param buttonValue the value of the button which determines the buttons new position
  43407. */
  43408. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43409. /**
  43410. * Moves the axis on the controller mesh based on its current state
  43411. * @param axis the index of the axis
  43412. * @param axisValue the value of the axis which determines the meshes new position
  43413. * @hidden
  43414. */
  43415. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43416. /**
  43417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43418. * @param scene scene in which to add meshes
  43419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43420. */
  43421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43422. /**
  43423. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43424. * can be transformed by button presses and axes values, based on this._mapping.
  43425. *
  43426. * @param scene scene in which the meshes exist
  43427. * @param meshes list of meshes that make up the controller model to process
  43428. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43429. */
  43430. private processModel;
  43431. private createMeshInfo;
  43432. /**
  43433. * Gets the ray of the controller in the direction the controller is pointing
  43434. * @param length the length the resulting ray should be
  43435. * @returns a ray in the direction the controller is pointing
  43436. */
  43437. getForwardRay(length?: number): Ray;
  43438. /**
  43439. * Disposes of the controller
  43440. */
  43441. dispose(): void;
  43442. }
  43443. }
  43444. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43445. import { Observable } from "babylonjs/Misc/observable";
  43446. import { Scene } from "babylonjs/scene";
  43447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43448. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43449. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43450. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43451. /**
  43452. * Oculus Touch Controller
  43453. */
  43454. export class OculusTouchController extends WebVRController {
  43455. /**
  43456. * Base Url for the controller model.
  43457. */
  43458. static MODEL_BASE_URL: string;
  43459. /**
  43460. * File name for the left controller model.
  43461. */
  43462. static MODEL_LEFT_FILENAME: string;
  43463. /**
  43464. * File name for the right controller model.
  43465. */
  43466. static MODEL_RIGHT_FILENAME: string;
  43467. /**
  43468. * Base Url for the Quest controller model.
  43469. */
  43470. static QUEST_MODEL_BASE_URL: string;
  43471. /**
  43472. * @hidden
  43473. * If the controllers are running on a device that needs the updated Quest controller models
  43474. */
  43475. static _IsQuest: boolean;
  43476. /**
  43477. * Fired when the secondary trigger on this controller is modified
  43478. */
  43479. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43480. /**
  43481. * Fired when the thumb rest on this controller is modified
  43482. */
  43483. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43484. /**
  43485. * Creates a new OculusTouchController from a gamepad
  43486. * @param vrGamepad the gamepad that the controller should be created from
  43487. */
  43488. constructor(vrGamepad: any);
  43489. /**
  43490. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43491. * @param scene scene in which to add meshes
  43492. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43493. */
  43494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43495. /**
  43496. * Fired when the A button on this controller is modified
  43497. */
  43498. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43499. /**
  43500. * Fired when the B button on this controller is modified
  43501. */
  43502. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43503. /**
  43504. * Fired when the X button on this controller is modified
  43505. */
  43506. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43507. /**
  43508. * Fired when the Y button on this controller is modified
  43509. */
  43510. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43511. /**
  43512. * Called once for each button that changed state since the last frame
  43513. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43514. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43515. * 2) secondary trigger (same)
  43516. * 3) A (right) X (left), touch, pressed = value
  43517. * 4) B / Y
  43518. * 5) thumb rest
  43519. * @param buttonIdx Which button index changed
  43520. * @param state New state of the button
  43521. * @param changes Which properties on the state changed since last frame
  43522. */
  43523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43524. }
  43525. }
  43526. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43527. import { Scene } from "babylonjs/scene";
  43528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43529. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43530. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43531. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43532. import { Observable } from "babylonjs/Misc/observable";
  43533. /**
  43534. * Vive Controller
  43535. */
  43536. export class ViveController extends WebVRController {
  43537. /**
  43538. * Base Url for the controller model.
  43539. */
  43540. static MODEL_BASE_URL: string;
  43541. /**
  43542. * File name for the controller model.
  43543. */
  43544. static MODEL_FILENAME: string;
  43545. /**
  43546. * Creates a new ViveController from a gamepad
  43547. * @param vrGamepad the gamepad that the controller should be created from
  43548. */
  43549. constructor(vrGamepad: any);
  43550. /**
  43551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43552. * @param scene scene in which to add meshes
  43553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43554. */
  43555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43556. /**
  43557. * Fired when the left button on this controller is modified
  43558. */
  43559. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43560. /**
  43561. * Fired when the right button on this controller is modified
  43562. */
  43563. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43564. /**
  43565. * Fired when the menu button on this controller is modified
  43566. */
  43567. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43568. /**
  43569. * Called once for each button that changed state since the last frame
  43570. * Vive mapping:
  43571. * 0: touchpad
  43572. * 1: trigger
  43573. * 2: left AND right buttons
  43574. * 3: menu button
  43575. * @param buttonIdx Which button index changed
  43576. * @param state New state of the button
  43577. * @param changes Which properties on the state changed since last frame
  43578. */
  43579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43580. }
  43581. }
  43582. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43583. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43584. /**
  43585. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43586. */
  43587. export class WebXRControllerModelLoader {
  43588. /**
  43589. * Creates the WebXRControllerModelLoader
  43590. * @param input xr input that creates the controllers
  43591. */
  43592. constructor(input: WebXRInput);
  43593. }
  43594. }
  43595. declare module "babylonjs/Cameras/XR/index" {
  43596. export * from "babylonjs/Cameras/XR/webXRCamera";
  43597. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43598. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43599. export * from "babylonjs/Cameras/XR/webXRInput";
  43600. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43601. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43602. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43603. export * from "babylonjs/Cameras/XR/webXRController";
  43604. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43605. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43606. }
  43607. declare module "babylonjs/Cameras/RigModes/index" {
  43608. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43609. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43610. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43611. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43612. }
  43613. declare module "babylonjs/Cameras/index" {
  43614. export * from "babylonjs/Cameras/Inputs/index";
  43615. export * from "babylonjs/Cameras/cameraInputsManager";
  43616. export * from "babylonjs/Cameras/camera";
  43617. export * from "babylonjs/Cameras/targetCamera";
  43618. export * from "babylonjs/Cameras/freeCamera";
  43619. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43620. export * from "babylonjs/Cameras/touchCamera";
  43621. export * from "babylonjs/Cameras/arcRotateCamera";
  43622. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43623. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43624. export * from "babylonjs/Cameras/flyCamera";
  43625. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43626. export * from "babylonjs/Cameras/followCamera";
  43627. export * from "babylonjs/Cameras/gamepadCamera";
  43628. export * from "babylonjs/Cameras/Stereoscopic/index";
  43629. export * from "babylonjs/Cameras/universalCamera";
  43630. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43631. export * from "babylonjs/Cameras/VR/index";
  43632. export * from "babylonjs/Cameras/XR/index";
  43633. export * from "babylonjs/Cameras/RigModes/index";
  43634. }
  43635. declare module "babylonjs/Collisions/index" {
  43636. export * from "babylonjs/Collisions/collider";
  43637. export * from "babylonjs/Collisions/collisionCoordinator";
  43638. export * from "babylonjs/Collisions/pickingInfo";
  43639. export * from "babylonjs/Collisions/intersectionInfo";
  43640. export * from "babylonjs/Collisions/meshCollisionData";
  43641. }
  43642. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43643. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43644. import { Vector3 } from "babylonjs/Maths/math.vector";
  43645. import { Ray } from "babylonjs/Culling/ray";
  43646. import { Plane } from "babylonjs/Maths/math.plane";
  43647. /**
  43648. * Contains an array of blocks representing the octree
  43649. */
  43650. export interface IOctreeContainer<T> {
  43651. /**
  43652. * Blocks within the octree
  43653. */
  43654. blocks: Array<OctreeBlock<T>>;
  43655. }
  43656. /**
  43657. * Class used to store a cell in an octree
  43658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43659. */
  43660. export class OctreeBlock<T> {
  43661. /**
  43662. * Gets the content of the current block
  43663. */
  43664. entries: T[];
  43665. /**
  43666. * Gets the list of block children
  43667. */
  43668. blocks: Array<OctreeBlock<T>>;
  43669. private _depth;
  43670. private _maxDepth;
  43671. private _capacity;
  43672. private _minPoint;
  43673. private _maxPoint;
  43674. private _boundingVectors;
  43675. private _creationFunc;
  43676. /**
  43677. * Creates a new block
  43678. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43679. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43680. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43681. * @param depth defines the current depth of this block in the octree
  43682. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43683. * @param creationFunc defines a callback to call when an element is added to the block
  43684. */
  43685. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43686. /**
  43687. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43688. */
  43689. readonly capacity: number;
  43690. /**
  43691. * Gets the minimum vector (in world space) of the block's bounding box
  43692. */
  43693. readonly minPoint: Vector3;
  43694. /**
  43695. * Gets the maximum vector (in world space) of the block's bounding box
  43696. */
  43697. readonly maxPoint: Vector3;
  43698. /**
  43699. * Add a new element to this block
  43700. * @param entry defines the element to add
  43701. */
  43702. addEntry(entry: T): void;
  43703. /**
  43704. * Remove an element from this block
  43705. * @param entry defines the element to remove
  43706. */
  43707. removeEntry(entry: T): void;
  43708. /**
  43709. * Add an array of elements to this block
  43710. * @param entries defines the array of elements to add
  43711. */
  43712. addEntries(entries: T[]): void;
  43713. /**
  43714. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43715. * @param frustumPlanes defines the frustum planes to test
  43716. * @param selection defines the array to store current content if selection is positive
  43717. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43718. */
  43719. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43720. /**
  43721. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43722. * @param sphereCenter defines the bounding sphere center
  43723. * @param sphereRadius defines the bounding sphere radius
  43724. * @param selection defines the array to store current content if selection is positive
  43725. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43726. */
  43727. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43728. /**
  43729. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43730. * @param ray defines the ray to test with
  43731. * @param selection defines the array to store current content if selection is positive
  43732. */
  43733. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43734. /**
  43735. * Subdivide the content into child blocks (this block will then be empty)
  43736. */
  43737. createInnerBlocks(): void;
  43738. /**
  43739. * @hidden
  43740. */
  43741. 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;
  43742. }
  43743. }
  43744. declare module "babylonjs/Culling/Octrees/octree" {
  43745. import { SmartArray } from "babylonjs/Misc/smartArray";
  43746. import { Vector3 } from "babylonjs/Maths/math.vector";
  43747. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43749. import { Ray } from "babylonjs/Culling/ray";
  43750. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43751. import { Plane } from "babylonjs/Maths/math.plane";
  43752. /**
  43753. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43755. */
  43756. export class Octree<T> {
  43757. /** 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.) */
  43758. maxDepth: number;
  43759. /**
  43760. * Blocks within the octree containing objects
  43761. */
  43762. blocks: Array<OctreeBlock<T>>;
  43763. /**
  43764. * Content stored in the octree
  43765. */
  43766. dynamicContent: T[];
  43767. private _maxBlockCapacity;
  43768. private _selectionContent;
  43769. private _creationFunc;
  43770. /**
  43771. * Creates a octree
  43772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43773. * @param creationFunc function to be used to instatiate the octree
  43774. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43775. * @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.)
  43776. */
  43777. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43778. /** 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.) */
  43779. maxDepth?: number);
  43780. /**
  43781. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43782. * @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);
  43783. * @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);
  43784. * @param entries meshes to be added to the octree blocks
  43785. */
  43786. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43787. /**
  43788. * Adds a mesh to the octree
  43789. * @param entry Mesh to add to the octree
  43790. */
  43791. addMesh(entry: T): void;
  43792. /**
  43793. * Remove an element from the octree
  43794. * @param entry defines the element to remove
  43795. */
  43796. removeMesh(entry: T): void;
  43797. /**
  43798. * Selects an array of meshes within the frustum
  43799. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43800. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43801. * @returns array of meshes within the frustum
  43802. */
  43803. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43804. /**
  43805. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43806. * @param sphereCenter defines the bounding sphere center
  43807. * @param sphereRadius defines the bounding sphere radius
  43808. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43809. * @returns an array of objects that intersect the sphere
  43810. */
  43811. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43812. /**
  43813. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43814. * @param ray defines the ray to test with
  43815. * @returns array of intersected objects
  43816. */
  43817. intersectsRay(ray: Ray): SmartArray<T>;
  43818. /**
  43819. * Adds a mesh into the octree block if it intersects the block
  43820. */
  43821. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43822. /**
  43823. * Adds a submesh into the octree block if it intersects the block
  43824. */
  43825. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43826. }
  43827. }
  43828. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43829. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43830. import { Scene } from "babylonjs/scene";
  43831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43833. import { Ray } from "babylonjs/Culling/ray";
  43834. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43835. import { Collider } from "babylonjs/Collisions/collider";
  43836. module "babylonjs/scene" {
  43837. interface Scene {
  43838. /**
  43839. * @hidden
  43840. * Backing Filed
  43841. */
  43842. _selectionOctree: Octree<AbstractMesh>;
  43843. /**
  43844. * Gets the octree used to boost mesh selection (picking)
  43845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43846. */
  43847. selectionOctree: Octree<AbstractMesh>;
  43848. /**
  43849. * Creates or updates the octree used to boost selection (picking)
  43850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43851. * @param maxCapacity defines the maximum capacity per leaf
  43852. * @param maxDepth defines the maximum depth of the octree
  43853. * @returns an octree of AbstractMesh
  43854. */
  43855. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43856. }
  43857. }
  43858. module "babylonjs/Meshes/abstractMesh" {
  43859. interface AbstractMesh {
  43860. /**
  43861. * @hidden
  43862. * Backing Field
  43863. */
  43864. _submeshesOctree: Octree<SubMesh>;
  43865. /**
  43866. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43867. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43868. * @param maxCapacity defines the maximum size of each block (64 by default)
  43869. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43870. * @returns the new octree
  43871. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43873. */
  43874. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43875. }
  43876. }
  43877. /**
  43878. * Defines the octree scene component responsible to manage any octrees
  43879. * in a given scene.
  43880. */
  43881. export class OctreeSceneComponent {
  43882. /**
  43883. * The component name help to identify the component in the list of scene components.
  43884. */
  43885. readonly name: string;
  43886. /**
  43887. * The scene the component belongs to.
  43888. */
  43889. scene: Scene;
  43890. /**
  43891. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43892. */
  43893. readonly checksIsEnabled: boolean;
  43894. /**
  43895. * Creates a new instance of the component for the given scene
  43896. * @param scene Defines the scene to register the component in
  43897. */
  43898. constructor(scene: Scene);
  43899. /**
  43900. * Registers the component in a given scene
  43901. */
  43902. register(): void;
  43903. /**
  43904. * Return the list of active meshes
  43905. * @returns the list of active meshes
  43906. */
  43907. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43908. /**
  43909. * Return the list of active sub meshes
  43910. * @param mesh The mesh to get the candidates sub meshes from
  43911. * @returns the list of active sub meshes
  43912. */
  43913. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43914. private _tempRay;
  43915. /**
  43916. * Return the list of sub meshes intersecting with a given local ray
  43917. * @param mesh defines the mesh to find the submesh for
  43918. * @param localRay defines the ray in local space
  43919. * @returns the list of intersecting sub meshes
  43920. */
  43921. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43922. /**
  43923. * Return the list of sub meshes colliding with a collider
  43924. * @param mesh defines the mesh to find the submesh for
  43925. * @param collider defines the collider to evaluate the collision against
  43926. * @returns the list of colliding sub meshes
  43927. */
  43928. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43929. /**
  43930. * Rebuilds the elements related to this component in case of
  43931. * context lost for instance.
  43932. */
  43933. rebuild(): void;
  43934. /**
  43935. * Disposes the component and the associated ressources.
  43936. */
  43937. dispose(): void;
  43938. }
  43939. }
  43940. declare module "babylonjs/Culling/Octrees/index" {
  43941. export * from "babylonjs/Culling/Octrees/octree";
  43942. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43943. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43944. }
  43945. declare module "babylonjs/Culling/index" {
  43946. export * from "babylonjs/Culling/boundingBox";
  43947. export * from "babylonjs/Culling/boundingInfo";
  43948. export * from "babylonjs/Culling/boundingSphere";
  43949. export * from "babylonjs/Culling/Octrees/index";
  43950. export * from "babylonjs/Culling/ray";
  43951. }
  43952. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43953. import { IDisposable, Scene } from "babylonjs/scene";
  43954. import { Nullable } from "babylonjs/types";
  43955. import { Observable } from "babylonjs/Misc/observable";
  43956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43957. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43958. import { Camera } from "babylonjs/Cameras/camera";
  43959. /**
  43960. * Renders a layer on top of an existing scene
  43961. */
  43962. export class UtilityLayerRenderer implements IDisposable {
  43963. /** the original scene that will be rendered on top of */
  43964. originalScene: Scene;
  43965. private _pointerCaptures;
  43966. private _lastPointerEvents;
  43967. private static _DefaultUtilityLayer;
  43968. private static _DefaultKeepDepthUtilityLayer;
  43969. private _sharedGizmoLight;
  43970. private _renderCamera;
  43971. /**
  43972. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43973. * @returns the camera that is used when rendering the utility layer
  43974. */
  43975. getRenderCamera(): Nullable<Camera>;
  43976. /**
  43977. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43978. * @param cam the camera that should be used when rendering the utility layer
  43979. */
  43980. setRenderCamera(cam: Nullable<Camera>): void;
  43981. /**
  43982. * @hidden
  43983. * Light which used by gizmos to get light shading
  43984. */
  43985. _getSharedGizmoLight(): HemisphericLight;
  43986. /**
  43987. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43988. */
  43989. pickUtilitySceneFirst: boolean;
  43990. /**
  43991. * 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)
  43992. */
  43993. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43994. /**
  43995. * 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)
  43996. */
  43997. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43998. /**
  43999. * The scene that is rendered on top of the original scene
  44000. */
  44001. utilityLayerScene: Scene;
  44002. /**
  44003. * If the utility layer should automatically be rendered on top of existing scene
  44004. */
  44005. shouldRender: boolean;
  44006. /**
  44007. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44008. */
  44009. onlyCheckPointerDownEvents: boolean;
  44010. /**
  44011. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44012. */
  44013. processAllEvents: boolean;
  44014. /**
  44015. * Observable raised when the pointer move from the utility layer scene to the main scene
  44016. */
  44017. onPointerOutObservable: Observable<number>;
  44018. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44019. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44020. private _afterRenderObserver;
  44021. private _sceneDisposeObserver;
  44022. private _originalPointerObserver;
  44023. /**
  44024. * Instantiates a UtilityLayerRenderer
  44025. * @param originalScene the original scene that will be rendered on top of
  44026. * @param handleEvents boolean indicating if the utility layer should handle events
  44027. */
  44028. constructor(
  44029. /** the original scene that will be rendered on top of */
  44030. originalScene: Scene, handleEvents?: boolean);
  44031. private _notifyObservers;
  44032. /**
  44033. * Renders the utility layers scene on top of the original scene
  44034. */
  44035. render(): void;
  44036. /**
  44037. * Disposes of the renderer
  44038. */
  44039. dispose(): void;
  44040. private _updateCamera;
  44041. }
  44042. }
  44043. declare module "babylonjs/Gizmos/gizmo" {
  44044. import { Nullable } from "babylonjs/types";
  44045. import { IDisposable } from "babylonjs/scene";
  44046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44047. import { Mesh } from "babylonjs/Meshes/mesh";
  44048. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44049. /**
  44050. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44051. */
  44052. export class Gizmo implements IDisposable {
  44053. /** The utility layer the gizmo will be added to */
  44054. gizmoLayer: UtilityLayerRenderer;
  44055. /**
  44056. * The root mesh of the gizmo
  44057. */
  44058. _rootMesh: Mesh;
  44059. private _attachedMesh;
  44060. /**
  44061. * Ratio for the scale of the gizmo (Default: 1)
  44062. */
  44063. scaleRatio: number;
  44064. /**
  44065. * If a custom mesh has been set (Default: false)
  44066. */
  44067. protected _customMeshSet: boolean;
  44068. /**
  44069. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44070. * * When set, interactions will be enabled
  44071. */
  44072. attachedMesh: Nullable<AbstractMesh>;
  44073. /**
  44074. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44075. * @param mesh The mesh to replace the default mesh of the gizmo
  44076. */
  44077. setCustomMesh(mesh: Mesh): void;
  44078. /**
  44079. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44080. */
  44081. updateGizmoRotationToMatchAttachedMesh: boolean;
  44082. /**
  44083. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44084. */
  44085. updateGizmoPositionToMatchAttachedMesh: boolean;
  44086. /**
  44087. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44088. */
  44089. updateScale: boolean;
  44090. protected _interactionsEnabled: boolean;
  44091. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44092. private _beforeRenderObserver;
  44093. private _tempVector;
  44094. /**
  44095. * Creates a gizmo
  44096. * @param gizmoLayer The utility layer the gizmo will be added to
  44097. */
  44098. constructor(
  44099. /** The utility layer the gizmo will be added to */
  44100. gizmoLayer?: UtilityLayerRenderer);
  44101. /**
  44102. * Updates the gizmo to match the attached mesh's position/rotation
  44103. */
  44104. protected _update(): void;
  44105. /**
  44106. * Disposes of the gizmo
  44107. */
  44108. dispose(): void;
  44109. }
  44110. }
  44111. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44112. import { Observable } from "babylonjs/Misc/observable";
  44113. import { Nullable } from "babylonjs/types";
  44114. import { Vector3 } from "babylonjs/Maths/math.vector";
  44115. import { Color3 } from "babylonjs/Maths/math.color";
  44116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44118. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44119. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44120. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44121. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44122. import { Scene } from "babylonjs/scene";
  44123. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44124. /**
  44125. * Single plane drag gizmo
  44126. */
  44127. export class PlaneDragGizmo extends Gizmo {
  44128. /**
  44129. * Drag behavior responsible for the gizmos dragging interactions
  44130. */
  44131. dragBehavior: PointerDragBehavior;
  44132. private _pointerObserver;
  44133. /**
  44134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44135. */
  44136. snapDistance: number;
  44137. /**
  44138. * Event that fires each time the gizmo snaps to a new location.
  44139. * * snapDistance is the the change in distance
  44140. */
  44141. onSnapObservable: Observable<{
  44142. snapDistance: number;
  44143. }>;
  44144. private _plane;
  44145. private _coloredMaterial;
  44146. private _hoverMaterial;
  44147. private _isEnabled;
  44148. private _parent;
  44149. /** @hidden */
  44150. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44151. /** @hidden */
  44152. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44153. /**
  44154. * Creates a PlaneDragGizmo
  44155. * @param gizmoLayer The utility layer the gizmo will be added to
  44156. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44157. * @param color The color of the gizmo
  44158. */
  44159. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44160. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44161. /**
  44162. * If the gizmo is enabled
  44163. */
  44164. isEnabled: boolean;
  44165. /**
  44166. * Disposes of the gizmo
  44167. */
  44168. dispose(): void;
  44169. }
  44170. }
  44171. declare module "babylonjs/Gizmos/positionGizmo" {
  44172. import { Observable } from "babylonjs/Misc/observable";
  44173. import { Nullable } from "babylonjs/types";
  44174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44175. import { Mesh } from "babylonjs/Meshes/mesh";
  44176. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44177. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44178. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44179. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44180. /**
  44181. * Gizmo that enables dragging a mesh along 3 axis
  44182. */
  44183. export class PositionGizmo extends Gizmo {
  44184. /**
  44185. * Internal gizmo used for interactions on the x axis
  44186. */
  44187. xGizmo: AxisDragGizmo;
  44188. /**
  44189. * Internal gizmo used for interactions on the y axis
  44190. */
  44191. yGizmo: AxisDragGizmo;
  44192. /**
  44193. * Internal gizmo used for interactions on the z axis
  44194. */
  44195. zGizmo: AxisDragGizmo;
  44196. /**
  44197. * Internal gizmo used for interactions on the yz plane
  44198. */
  44199. xPlaneGizmo: PlaneDragGizmo;
  44200. /**
  44201. * Internal gizmo used for interactions on the xz plane
  44202. */
  44203. yPlaneGizmo: PlaneDragGizmo;
  44204. /**
  44205. * Internal gizmo used for interactions on the xy plane
  44206. */
  44207. zPlaneGizmo: PlaneDragGizmo;
  44208. /**
  44209. * private variables
  44210. */
  44211. private _meshAttached;
  44212. private _updateGizmoRotationToMatchAttachedMesh;
  44213. private _snapDistance;
  44214. private _scaleRatio;
  44215. /** Fires an event when any of it's sub gizmos are dragged */
  44216. onDragStartObservable: Observable<unknown>;
  44217. /** Fires an event when any of it's sub gizmos are released from dragging */
  44218. onDragEndObservable: Observable<unknown>;
  44219. /**
  44220. * If set to true, planar drag is enabled
  44221. */
  44222. private _planarGizmoEnabled;
  44223. attachedMesh: Nullable<AbstractMesh>;
  44224. /**
  44225. * Creates a PositionGizmo
  44226. * @param gizmoLayer The utility layer the gizmo will be added to
  44227. */
  44228. constructor(gizmoLayer?: UtilityLayerRenderer);
  44229. /**
  44230. * If the planar drag gizmo is enabled
  44231. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44232. */
  44233. planarGizmoEnabled: boolean;
  44234. updateGizmoRotationToMatchAttachedMesh: boolean;
  44235. /**
  44236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44237. */
  44238. snapDistance: number;
  44239. /**
  44240. * Ratio for the scale of the gizmo (Default: 1)
  44241. */
  44242. scaleRatio: number;
  44243. /**
  44244. * Disposes of the gizmo
  44245. */
  44246. dispose(): void;
  44247. /**
  44248. * CustomMeshes are not supported by this gizmo
  44249. * @param mesh The mesh to replace the default mesh of the gizmo
  44250. */
  44251. setCustomMesh(mesh: Mesh): void;
  44252. }
  44253. }
  44254. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44255. import { Observable } from "babylonjs/Misc/observable";
  44256. import { Nullable } from "babylonjs/types";
  44257. import { Vector3 } from "babylonjs/Maths/math.vector";
  44258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44260. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44261. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44262. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44263. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44264. import { Scene } from "babylonjs/scene";
  44265. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44266. import { Color3 } from "babylonjs/Maths/math.color";
  44267. /**
  44268. * Single axis drag gizmo
  44269. */
  44270. export class AxisDragGizmo extends Gizmo {
  44271. /**
  44272. * Drag behavior responsible for the gizmos dragging interactions
  44273. */
  44274. dragBehavior: PointerDragBehavior;
  44275. private _pointerObserver;
  44276. /**
  44277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44278. */
  44279. snapDistance: number;
  44280. /**
  44281. * Event that fires each time the gizmo snaps to a new location.
  44282. * * snapDistance is the the change in distance
  44283. */
  44284. onSnapObservable: Observable<{
  44285. snapDistance: number;
  44286. }>;
  44287. private _isEnabled;
  44288. private _parent;
  44289. private _arrow;
  44290. private _coloredMaterial;
  44291. private _hoverMaterial;
  44292. /** @hidden */
  44293. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44294. /** @hidden */
  44295. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44296. /**
  44297. * Creates an AxisDragGizmo
  44298. * @param gizmoLayer The utility layer the gizmo will be added to
  44299. * @param dragAxis The axis which the gizmo will be able to drag on
  44300. * @param color The color of the gizmo
  44301. */
  44302. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44303. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44304. /**
  44305. * If the gizmo is enabled
  44306. */
  44307. isEnabled: boolean;
  44308. /**
  44309. * Disposes of the gizmo
  44310. */
  44311. dispose(): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Debug/axesViewer" {
  44315. import { Vector3 } from "babylonjs/Maths/math.vector";
  44316. import { Nullable } from "babylonjs/types";
  44317. import { Scene } from "babylonjs/scene";
  44318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44319. /**
  44320. * The Axes viewer will show 3 axes in a specific point in space
  44321. */
  44322. export class AxesViewer {
  44323. private _xAxis;
  44324. private _yAxis;
  44325. private _zAxis;
  44326. private _scaleLinesFactor;
  44327. private _instanced;
  44328. /**
  44329. * Gets the hosting scene
  44330. */
  44331. scene: Scene;
  44332. /**
  44333. * Gets or sets a number used to scale line length
  44334. */
  44335. scaleLines: number;
  44336. /** Gets the node hierarchy used to render x-axis */
  44337. readonly xAxis: TransformNode;
  44338. /** Gets the node hierarchy used to render y-axis */
  44339. readonly yAxis: TransformNode;
  44340. /** Gets the node hierarchy used to render z-axis */
  44341. readonly zAxis: TransformNode;
  44342. /**
  44343. * Creates a new AxesViewer
  44344. * @param scene defines the hosting scene
  44345. * @param scaleLines defines a number used to scale line length (1 by default)
  44346. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44347. * @param xAxis defines the node hierarchy used to render the x-axis
  44348. * @param yAxis defines the node hierarchy used to render the y-axis
  44349. * @param zAxis defines the node hierarchy used to render the z-axis
  44350. */
  44351. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44352. /**
  44353. * Force the viewer to update
  44354. * @param position defines the position of the viewer
  44355. * @param xaxis defines the x axis of the viewer
  44356. * @param yaxis defines the y axis of the viewer
  44357. * @param zaxis defines the z axis of the viewer
  44358. */
  44359. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44360. /**
  44361. * Creates an instance of this axes viewer.
  44362. * @returns a new axes viewer with instanced meshes
  44363. */
  44364. createInstance(): AxesViewer;
  44365. /** Releases resources */
  44366. dispose(): void;
  44367. private static _SetRenderingGroupId;
  44368. }
  44369. }
  44370. declare module "babylonjs/Debug/boneAxesViewer" {
  44371. import { Nullable } from "babylonjs/types";
  44372. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44373. import { Vector3 } from "babylonjs/Maths/math.vector";
  44374. import { Mesh } from "babylonjs/Meshes/mesh";
  44375. import { Bone } from "babylonjs/Bones/bone";
  44376. import { Scene } from "babylonjs/scene";
  44377. /**
  44378. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44379. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44380. */
  44381. export class BoneAxesViewer extends AxesViewer {
  44382. /**
  44383. * Gets or sets the target mesh where to display the axes viewer
  44384. */
  44385. mesh: Nullable<Mesh>;
  44386. /**
  44387. * Gets or sets the target bone where to display the axes viewer
  44388. */
  44389. bone: Nullable<Bone>;
  44390. /** Gets current position */
  44391. pos: Vector3;
  44392. /** Gets direction of X axis */
  44393. xaxis: Vector3;
  44394. /** Gets direction of Y axis */
  44395. yaxis: Vector3;
  44396. /** Gets direction of Z axis */
  44397. zaxis: Vector3;
  44398. /**
  44399. * Creates a new BoneAxesViewer
  44400. * @param scene defines the hosting scene
  44401. * @param bone defines the target bone
  44402. * @param mesh defines the target mesh
  44403. * @param scaleLines defines a scaling factor for line length (1 by default)
  44404. */
  44405. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44406. /**
  44407. * Force the viewer to update
  44408. */
  44409. update(): void;
  44410. /** Releases resources */
  44411. dispose(): void;
  44412. }
  44413. }
  44414. declare module "babylonjs/Debug/debugLayer" {
  44415. import { Scene } from "babylonjs/scene";
  44416. /**
  44417. * Interface used to define scene explorer extensibility option
  44418. */
  44419. export interface IExplorerExtensibilityOption {
  44420. /**
  44421. * Define the option label
  44422. */
  44423. label: string;
  44424. /**
  44425. * Defines the action to execute on click
  44426. */
  44427. action: (entity: any) => void;
  44428. }
  44429. /**
  44430. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44431. */
  44432. export interface IExplorerExtensibilityGroup {
  44433. /**
  44434. * Defines a predicate to test if a given type mut be extended
  44435. */
  44436. predicate: (entity: any) => boolean;
  44437. /**
  44438. * Gets the list of options added to a type
  44439. */
  44440. entries: IExplorerExtensibilityOption[];
  44441. }
  44442. /**
  44443. * Interface used to define the options to use to create the Inspector
  44444. */
  44445. export interface IInspectorOptions {
  44446. /**
  44447. * Display in overlay mode (default: false)
  44448. */
  44449. overlay?: boolean;
  44450. /**
  44451. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44452. */
  44453. globalRoot?: HTMLElement;
  44454. /**
  44455. * Display the Scene explorer
  44456. */
  44457. showExplorer?: boolean;
  44458. /**
  44459. * Display the property inspector
  44460. */
  44461. showInspector?: boolean;
  44462. /**
  44463. * Display in embed mode (both panes on the right)
  44464. */
  44465. embedMode?: boolean;
  44466. /**
  44467. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44468. */
  44469. handleResize?: boolean;
  44470. /**
  44471. * Allow the panes to popup (default: true)
  44472. */
  44473. enablePopup?: boolean;
  44474. /**
  44475. * Allow the panes to be closed by users (default: true)
  44476. */
  44477. enableClose?: boolean;
  44478. /**
  44479. * Optional list of extensibility entries
  44480. */
  44481. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44482. /**
  44483. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44484. */
  44485. inspectorURL?: string;
  44486. }
  44487. module "babylonjs/scene" {
  44488. interface Scene {
  44489. /**
  44490. * @hidden
  44491. * Backing field
  44492. */
  44493. _debugLayer: DebugLayer;
  44494. /**
  44495. * Gets the debug layer (aka Inspector) associated with the scene
  44496. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44497. */
  44498. debugLayer: DebugLayer;
  44499. }
  44500. }
  44501. /**
  44502. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44503. * what is happening in your scene
  44504. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44505. */
  44506. export class DebugLayer {
  44507. /**
  44508. * Define the url to get the inspector script from.
  44509. * By default it uses the babylonjs CDN.
  44510. * @ignoreNaming
  44511. */
  44512. static InspectorURL: string;
  44513. private _scene;
  44514. private BJSINSPECTOR;
  44515. private _onPropertyChangedObservable?;
  44516. /**
  44517. * Observable triggered when a property is changed through the inspector.
  44518. */
  44519. readonly onPropertyChangedObservable: any;
  44520. /**
  44521. * Instantiates a new debug layer.
  44522. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44523. * what is happening in your scene
  44524. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44525. * @param scene Defines the scene to inspect
  44526. */
  44527. constructor(scene: Scene);
  44528. /** Creates the inspector window. */
  44529. private _createInspector;
  44530. /**
  44531. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44532. * @param entity defines the entity to select
  44533. * @param lineContainerTitle defines the specific block to highlight
  44534. */
  44535. select(entity: any, lineContainerTitle?: string): void;
  44536. /** Get the inspector from bundle or global */
  44537. private _getGlobalInspector;
  44538. /**
  44539. * Get if the inspector is visible or not.
  44540. * @returns true if visible otherwise, false
  44541. */
  44542. isVisible(): boolean;
  44543. /**
  44544. * Hide the inspector and close its window.
  44545. */
  44546. hide(): void;
  44547. /**
  44548. * Launch the debugLayer.
  44549. * @param config Define the configuration of the inspector
  44550. * @return a promise fulfilled when the debug layer is visible
  44551. */
  44552. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44553. }
  44554. }
  44555. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44556. import { Nullable } from "babylonjs/types";
  44557. import { Scene } from "babylonjs/scene";
  44558. import { Vector4 } from "babylonjs/Maths/math.vector";
  44559. import { Color4 } from "babylonjs/Maths/math.color";
  44560. import { Mesh } from "babylonjs/Meshes/mesh";
  44561. /**
  44562. * Class containing static functions to help procedurally build meshes
  44563. */
  44564. export class BoxBuilder {
  44565. /**
  44566. * Creates a box mesh
  44567. * * The parameter `size` sets the size (float) of each box side (default 1)
  44568. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44569. * * 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)
  44570. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44574. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44575. * @param name defines the name of the mesh
  44576. * @param options defines the options used to create the mesh
  44577. * @param scene defines the hosting scene
  44578. * @returns the box mesh
  44579. */
  44580. static CreateBox(name: string, options: {
  44581. size?: number;
  44582. width?: number;
  44583. height?: number;
  44584. depth?: number;
  44585. faceUV?: Vector4[];
  44586. faceColors?: Color4[];
  44587. sideOrientation?: number;
  44588. frontUVs?: Vector4;
  44589. backUVs?: Vector4;
  44590. wrap?: boolean;
  44591. topBaseAt?: number;
  44592. bottomBaseAt?: number;
  44593. updatable?: boolean;
  44594. }, scene?: Nullable<Scene>): Mesh;
  44595. }
  44596. }
  44597. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44598. import { Vector4 } from "babylonjs/Maths/math.vector";
  44599. import { Mesh } from "babylonjs/Meshes/mesh";
  44600. /**
  44601. * Class containing static functions to help procedurally build meshes
  44602. */
  44603. export class SphereBuilder {
  44604. /**
  44605. * Creates a sphere mesh
  44606. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44607. * * 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`)
  44608. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44609. * * 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
  44610. * * 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)
  44611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44614. * @param name defines the name of the mesh
  44615. * @param options defines the options used to create the mesh
  44616. * @param scene defines the hosting scene
  44617. * @returns the sphere mesh
  44618. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44619. */
  44620. static CreateSphere(name: string, options: {
  44621. segments?: number;
  44622. diameter?: number;
  44623. diameterX?: number;
  44624. diameterY?: number;
  44625. diameterZ?: number;
  44626. arc?: number;
  44627. slice?: number;
  44628. sideOrientation?: number;
  44629. frontUVs?: Vector4;
  44630. backUVs?: Vector4;
  44631. updatable?: boolean;
  44632. }, scene: any): Mesh;
  44633. }
  44634. }
  44635. declare module "babylonjs/Debug/physicsViewer" {
  44636. import { Nullable } from "babylonjs/types";
  44637. import { Scene } from "babylonjs/scene";
  44638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44639. import { Mesh } from "babylonjs/Meshes/mesh";
  44640. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44641. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44642. /**
  44643. * Used to show the physics impostor around the specific mesh
  44644. */
  44645. export class PhysicsViewer {
  44646. /** @hidden */
  44647. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44648. /** @hidden */
  44649. protected _meshes: Array<Nullable<AbstractMesh>>;
  44650. /** @hidden */
  44651. protected _scene: Nullable<Scene>;
  44652. /** @hidden */
  44653. protected _numMeshes: number;
  44654. /** @hidden */
  44655. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44656. private _renderFunction;
  44657. private _utilityLayer;
  44658. private _debugBoxMesh;
  44659. private _debugSphereMesh;
  44660. private _debugCylinderMesh;
  44661. private _debugMaterial;
  44662. private _debugMeshMeshes;
  44663. /**
  44664. * Creates a new PhysicsViewer
  44665. * @param scene defines the hosting scene
  44666. */
  44667. constructor(scene: Scene);
  44668. /** @hidden */
  44669. protected _updateDebugMeshes(): void;
  44670. /**
  44671. * Renders a specified physic impostor
  44672. * @param impostor defines the impostor to render
  44673. * @param targetMesh defines the mesh represented by the impostor
  44674. * @returns the new debug mesh used to render the impostor
  44675. */
  44676. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44677. /**
  44678. * Hides a specified physic impostor
  44679. * @param impostor defines the impostor to hide
  44680. */
  44681. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44682. private _getDebugMaterial;
  44683. private _getDebugBoxMesh;
  44684. private _getDebugSphereMesh;
  44685. private _getDebugCylinderMesh;
  44686. private _getDebugMeshMesh;
  44687. private _getDebugMesh;
  44688. /** Releases all resources */
  44689. dispose(): void;
  44690. }
  44691. }
  44692. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44693. import { Vector3 } from "babylonjs/Maths/math.vector";
  44694. import { Color4 } from "babylonjs/Maths/math.color";
  44695. import { Nullable } from "babylonjs/types";
  44696. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44697. import { Scene } from "babylonjs/scene";
  44698. /**
  44699. * Class containing static functions to help procedurally build meshes
  44700. */
  44701. export class LinesBuilder {
  44702. /**
  44703. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44704. * * 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
  44705. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44706. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44707. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44708. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44710. * * 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
  44711. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44714. * @param name defines the name of the new line system
  44715. * @param options defines the options used to create the line system
  44716. * @param scene defines the hosting scene
  44717. * @returns a new line system mesh
  44718. */
  44719. static CreateLineSystem(name: string, options: {
  44720. lines: Vector3[][];
  44721. updatable?: boolean;
  44722. instance?: Nullable<LinesMesh>;
  44723. colors?: Nullable<Color4[][]>;
  44724. useVertexAlpha?: boolean;
  44725. }, scene: Nullable<Scene>): LinesMesh;
  44726. /**
  44727. * Creates a line mesh
  44728. * 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
  44729. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44730. * * The parameter `points` is an array successive Vector3
  44731. * * 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
  44732. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44733. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44734. * * When updating an instance, remember that only point positions can change, not the number of points
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44737. * @param name defines the name of the new line system
  44738. * @param options defines the options used to create the line system
  44739. * @param scene defines the hosting scene
  44740. * @returns a new line mesh
  44741. */
  44742. static CreateLines(name: string, options: {
  44743. points: Vector3[];
  44744. updatable?: boolean;
  44745. instance?: Nullable<LinesMesh>;
  44746. colors?: Color4[];
  44747. useVertexAlpha?: boolean;
  44748. }, scene?: Nullable<Scene>): LinesMesh;
  44749. /**
  44750. * Creates a dashed line mesh
  44751. * * 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
  44752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44753. * * The parameter `points` is an array successive Vector3
  44754. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44755. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44756. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44757. * * 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
  44758. * * When updating an instance, remember that only point positions can change, not the number of points
  44759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44760. * @param name defines the name of the mesh
  44761. * @param options defines the options used to create the mesh
  44762. * @param scene defines the hosting scene
  44763. * @returns the dashed line mesh
  44764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44765. */
  44766. static CreateDashedLines(name: string, options: {
  44767. points: Vector3[];
  44768. dashSize?: number;
  44769. gapSize?: number;
  44770. dashNb?: number;
  44771. updatable?: boolean;
  44772. instance?: LinesMesh;
  44773. }, scene?: Nullable<Scene>): LinesMesh;
  44774. }
  44775. }
  44776. declare module "babylonjs/Debug/rayHelper" {
  44777. import { Nullable } from "babylonjs/types";
  44778. import { Ray } from "babylonjs/Culling/ray";
  44779. import { Vector3 } from "babylonjs/Maths/math.vector";
  44780. import { Color3 } from "babylonjs/Maths/math.color";
  44781. import { Scene } from "babylonjs/scene";
  44782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44783. import "babylonjs/Meshes/Builders/linesBuilder";
  44784. /**
  44785. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44786. * in order to better appreciate the issue one might have.
  44787. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44788. */
  44789. export class RayHelper {
  44790. /**
  44791. * Defines the ray we are currently tryin to visualize.
  44792. */
  44793. ray: Nullable<Ray>;
  44794. private _renderPoints;
  44795. private _renderLine;
  44796. private _renderFunction;
  44797. private _scene;
  44798. private _updateToMeshFunction;
  44799. private _attachedToMesh;
  44800. private _meshSpaceDirection;
  44801. private _meshSpaceOrigin;
  44802. /**
  44803. * Helper function to create a colored helper in a scene in one line.
  44804. * @param ray Defines the ray we are currently tryin to visualize
  44805. * @param scene Defines the scene the ray is used in
  44806. * @param color Defines the color we want to see the ray in
  44807. * @returns The newly created ray helper.
  44808. */
  44809. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44810. /**
  44811. * Instantiate a new ray helper.
  44812. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44813. * in order to better appreciate the issue one might have.
  44814. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44815. * @param ray Defines the ray we are currently tryin to visualize
  44816. */
  44817. constructor(ray: Ray);
  44818. /**
  44819. * Shows the ray we are willing to debug.
  44820. * @param scene Defines the scene the ray needs to be rendered in
  44821. * @param color Defines the color the ray needs to be rendered in
  44822. */
  44823. show(scene: Scene, color?: Color3): void;
  44824. /**
  44825. * Hides the ray we are debugging.
  44826. */
  44827. hide(): void;
  44828. private _render;
  44829. /**
  44830. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44831. * @param mesh Defines the mesh we want the helper attached to
  44832. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44833. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44834. * @param length Defines the length of the ray
  44835. */
  44836. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44837. /**
  44838. * Detach the ray helper from the mesh it has previously been attached to.
  44839. */
  44840. detachFromMesh(): void;
  44841. private _updateToMesh;
  44842. /**
  44843. * Dispose the helper and release its associated resources.
  44844. */
  44845. dispose(): void;
  44846. }
  44847. }
  44848. declare module "babylonjs/Debug/skeletonViewer" {
  44849. import { Color3 } from "babylonjs/Maths/math.color";
  44850. import { Scene } from "babylonjs/scene";
  44851. import { Nullable } from "babylonjs/types";
  44852. import { Skeleton } from "babylonjs/Bones/skeleton";
  44853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44854. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44855. /**
  44856. * Class used to render a debug view of a given skeleton
  44857. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44858. */
  44859. export class SkeletonViewer {
  44860. /** defines the skeleton to render */
  44861. skeleton: Skeleton;
  44862. /** defines the mesh attached to the skeleton */
  44863. mesh: AbstractMesh;
  44864. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44865. autoUpdateBonesMatrices: boolean;
  44866. /** defines the rendering group id to use with the viewer */
  44867. renderingGroupId: number;
  44868. /** Gets or sets the color used to render the skeleton */
  44869. color: Color3;
  44870. private _scene;
  44871. private _debugLines;
  44872. private _debugMesh;
  44873. private _isEnabled;
  44874. private _renderFunction;
  44875. private _utilityLayer;
  44876. /**
  44877. * Returns the mesh used to render the bones
  44878. */
  44879. readonly debugMesh: Nullable<LinesMesh>;
  44880. /**
  44881. * Creates a new SkeletonViewer
  44882. * @param skeleton defines the skeleton to render
  44883. * @param mesh defines the mesh attached to the skeleton
  44884. * @param scene defines the hosting scene
  44885. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44886. * @param renderingGroupId defines the rendering group id to use with the viewer
  44887. */
  44888. constructor(
  44889. /** defines the skeleton to render */
  44890. skeleton: Skeleton,
  44891. /** defines the mesh attached to the skeleton */
  44892. mesh: AbstractMesh, scene: Scene,
  44893. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44894. autoUpdateBonesMatrices?: boolean,
  44895. /** defines the rendering group id to use with the viewer */
  44896. renderingGroupId?: number);
  44897. /** Gets or sets a boolean indicating if the viewer is enabled */
  44898. isEnabled: boolean;
  44899. private _getBonePosition;
  44900. private _getLinesForBonesWithLength;
  44901. private _getLinesForBonesNoLength;
  44902. /** Update the viewer to sync with current skeleton state */
  44903. update(): void;
  44904. /** Release associated resources */
  44905. dispose(): void;
  44906. }
  44907. }
  44908. declare module "babylonjs/Debug/index" {
  44909. export * from "babylonjs/Debug/axesViewer";
  44910. export * from "babylonjs/Debug/boneAxesViewer";
  44911. export * from "babylonjs/Debug/debugLayer";
  44912. export * from "babylonjs/Debug/physicsViewer";
  44913. export * from "babylonjs/Debug/rayHelper";
  44914. export * from "babylonjs/Debug/skeletonViewer";
  44915. }
  44916. declare module "babylonjs/Engines/nullEngine" {
  44917. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44918. import { Scene } from "babylonjs/scene";
  44919. import { Engine } from "babylonjs/Engines/engine";
  44920. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44923. import { Effect } from "babylonjs/Materials/effect";
  44924. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44925. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44926. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44927. /**
  44928. * Options to create the null engine
  44929. */
  44930. export class NullEngineOptions {
  44931. /**
  44932. * Render width (Default: 512)
  44933. */
  44934. renderWidth: number;
  44935. /**
  44936. * Render height (Default: 256)
  44937. */
  44938. renderHeight: number;
  44939. /**
  44940. * Texture size (Default: 512)
  44941. */
  44942. textureSize: number;
  44943. /**
  44944. * If delta time between frames should be constant
  44945. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44946. */
  44947. deterministicLockstep: boolean;
  44948. /**
  44949. * Maximum about of steps between frames (Default: 4)
  44950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44951. */
  44952. lockstepMaxSteps: number;
  44953. }
  44954. /**
  44955. * The null engine class provides support for headless version of babylon.js.
  44956. * This can be used in server side scenario or for testing purposes
  44957. */
  44958. export class NullEngine extends Engine {
  44959. private _options;
  44960. /**
  44961. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44962. */
  44963. isDeterministicLockStep(): boolean;
  44964. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44965. getLockstepMaxSteps(): number;
  44966. /**
  44967. * Sets hardware scaling, used to save performance if needed
  44968. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44969. */
  44970. getHardwareScalingLevel(): number;
  44971. constructor(options?: NullEngineOptions);
  44972. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44973. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44974. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44975. getRenderWidth(useScreen?: boolean): number;
  44976. getRenderHeight(useScreen?: boolean): number;
  44977. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44978. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44979. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44980. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44981. bindSamplers(effect: Effect): void;
  44982. enableEffect(effect: Effect): void;
  44983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44984. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44985. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44986. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44987. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44988. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44989. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44990. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44991. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44992. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44993. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44994. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44995. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44996. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44997. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44998. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44999. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45000. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45002. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45003. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45004. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45005. bindBuffers(vertexBuffers: {
  45006. [key: string]: VertexBuffer;
  45007. }, indexBuffer: DataBuffer, effect: Effect): void;
  45008. wipeCaches(bruteForce?: boolean): void;
  45009. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45010. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45011. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45012. /** @hidden */
  45013. _createTexture(): WebGLTexture;
  45014. /** @hidden */
  45015. _releaseTexture(texture: InternalTexture): void;
  45016. 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;
  45017. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45018. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45019. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45020. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45021. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45022. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45023. areAllEffectsReady(): boolean;
  45024. /**
  45025. * @hidden
  45026. * Get the current error code of the webGL context
  45027. * @returns the error code
  45028. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45029. */
  45030. getError(): number;
  45031. /** @hidden */
  45032. _getUnpackAlignement(): number;
  45033. /** @hidden */
  45034. _unpackFlipY(value: boolean): void;
  45035. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45036. /**
  45037. * Updates a dynamic vertex buffer.
  45038. * @param vertexBuffer the vertex buffer to update
  45039. * @param data the data used to update the vertex buffer
  45040. * @param byteOffset the byte offset of the data (optional)
  45041. * @param byteLength the byte length of the data (optional)
  45042. */
  45043. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45044. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45045. /** @hidden */
  45046. _bindTexture(channel: number, texture: InternalTexture): void;
  45047. /** @hidden */
  45048. _releaseBuffer(buffer: DataBuffer): boolean;
  45049. releaseEffects(): void;
  45050. displayLoadingUI(): void;
  45051. hideLoadingUI(): void;
  45052. /** @hidden */
  45053. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45054. /** @hidden */
  45055. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45056. /** @hidden */
  45057. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45058. /** @hidden */
  45059. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45060. }
  45061. }
  45062. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45063. import { Nullable, int } from "babylonjs/types";
  45064. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45065. /** @hidden */
  45066. export class _OcclusionDataStorage {
  45067. /** @hidden */
  45068. occlusionInternalRetryCounter: number;
  45069. /** @hidden */
  45070. isOcclusionQueryInProgress: boolean;
  45071. /** @hidden */
  45072. isOccluded: boolean;
  45073. /** @hidden */
  45074. occlusionRetryCount: number;
  45075. /** @hidden */
  45076. occlusionType: number;
  45077. /** @hidden */
  45078. occlusionQueryAlgorithmType: number;
  45079. }
  45080. module "babylonjs/Engines/engine" {
  45081. interface Engine {
  45082. /**
  45083. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45084. * @return the new query
  45085. */
  45086. createQuery(): WebGLQuery;
  45087. /**
  45088. * Delete and release a webGL query
  45089. * @param query defines the query to delete
  45090. * @return the current engine
  45091. */
  45092. deleteQuery(query: WebGLQuery): Engine;
  45093. /**
  45094. * Check if a given query has resolved and got its value
  45095. * @param query defines the query to check
  45096. * @returns true if the query got its value
  45097. */
  45098. isQueryResultAvailable(query: WebGLQuery): boolean;
  45099. /**
  45100. * Gets the value of a given query
  45101. * @param query defines the query to check
  45102. * @returns the value of the query
  45103. */
  45104. getQueryResult(query: WebGLQuery): number;
  45105. /**
  45106. * Initiates an occlusion query
  45107. * @param algorithmType defines the algorithm to use
  45108. * @param query defines the query to use
  45109. * @returns the current engine
  45110. * @see http://doc.babylonjs.com/features/occlusionquery
  45111. */
  45112. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45113. /**
  45114. * Ends an occlusion query
  45115. * @see http://doc.babylonjs.com/features/occlusionquery
  45116. * @param algorithmType defines the algorithm to use
  45117. * @returns the current engine
  45118. */
  45119. endOcclusionQuery(algorithmType: number): Engine;
  45120. /**
  45121. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45122. * Please note that only one query can be issued at a time
  45123. * @returns a time token used to track the time span
  45124. */
  45125. startTimeQuery(): Nullable<_TimeToken>;
  45126. /**
  45127. * Ends a time query
  45128. * @param token defines the token used to measure the time span
  45129. * @returns the time spent (in ns)
  45130. */
  45131. endTimeQuery(token: _TimeToken): int;
  45132. /** @hidden */
  45133. _currentNonTimestampToken: Nullable<_TimeToken>;
  45134. /** @hidden */
  45135. _createTimeQuery(): WebGLQuery;
  45136. /** @hidden */
  45137. _deleteTimeQuery(query: WebGLQuery): void;
  45138. /** @hidden */
  45139. _getGlAlgorithmType(algorithmType: number): number;
  45140. /** @hidden */
  45141. _getTimeQueryResult(query: WebGLQuery): any;
  45142. /** @hidden */
  45143. _getTimeQueryAvailability(query: WebGLQuery): any;
  45144. }
  45145. }
  45146. module "babylonjs/Meshes/abstractMesh" {
  45147. interface AbstractMesh {
  45148. /**
  45149. * Backing filed
  45150. * @hidden
  45151. */
  45152. __occlusionDataStorage: _OcclusionDataStorage;
  45153. /**
  45154. * Access property
  45155. * @hidden
  45156. */
  45157. _occlusionDataStorage: _OcclusionDataStorage;
  45158. /**
  45159. * 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.
  45160. * The default value is -1 which means don't break the query and wait till the result
  45161. * @see http://doc.babylonjs.com/features/occlusionquery
  45162. */
  45163. occlusionRetryCount: number;
  45164. /**
  45165. * 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:
  45166. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45167. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45168. * * 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.
  45169. * @see http://doc.babylonjs.com/features/occlusionquery
  45170. */
  45171. occlusionType: number;
  45172. /**
  45173. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45174. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45175. * * 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.
  45176. * @see http://doc.babylonjs.com/features/occlusionquery
  45177. */
  45178. occlusionQueryAlgorithmType: number;
  45179. /**
  45180. * 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
  45181. * @see http://doc.babylonjs.com/features/occlusionquery
  45182. */
  45183. isOccluded: boolean;
  45184. /**
  45185. * Flag to check the progress status of the query
  45186. * @see http://doc.babylonjs.com/features/occlusionquery
  45187. */
  45188. isOcclusionQueryInProgress: boolean;
  45189. }
  45190. }
  45191. }
  45192. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45193. import { Nullable } from "babylonjs/types";
  45194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45195. /** @hidden */
  45196. export var _forceTransformFeedbackToBundle: boolean;
  45197. module "babylonjs/Engines/engine" {
  45198. interface Engine {
  45199. /**
  45200. * Creates a webGL transform feedback object
  45201. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45202. * @returns the webGL transform feedback object
  45203. */
  45204. createTransformFeedback(): WebGLTransformFeedback;
  45205. /**
  45206. * Delete a webGL transform feedback object
  45207. * @param value defines the webGL transform feedback object to delete
  45208. */
  45209. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45210. /**
  45211. * Bind a webGL transform feedback object to the webgl context
  45212. * @param value defines the webGL transform feedback object to bind
  45213. */
  45214. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45215. /**
  45216. * Begins a transform feedback operation
  45217. * @param usePoints defines if points or triangles must be used
  45218. */
  45219. beginTransformFeedback(usePoints: boolean): void;
  45220. /**
  45221. * Ends a transform feedback operation
  45222. */
  45223. endTransformFeedback(): void;
  45224. /**
  45225. * Specify the varyings to use with transform feedback
  45226. * @param program defines the associated webGL program
  45227. * @param value defines the list of strings representing the varying names
  45228. */
  45229. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45230. /**
  45231. * Bind a webGL buffer for a transform feedback operation
  45232. * @param value defines the webGL buffer to bind
  45233. */
  45234. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45235. }
  45236. }
  45237. }
  45238. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45239. import { Scene } from "babylonjs/scene";
  45240. import { Engine } from "babylonjs/Engines/engine";
  45241. import { Texture } from "babylonjs/Materials/Textures/texture";
  45242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45243. import "babylonjs/Engines/Extensions/engine.multiRender";
  45244. /**
  45245. * Creation options of the multi render target texture.
  45246. */
  45247. export interface IMultiRenderTargetOptions {
  45248. /**
  45249. * Define if the texture needs to create mip maps after render.
  45250. */
  45251. generateMipMaps?: boolean;
  45252. /**
  45253. * Define the types of all the draw buffers we want to create
  45254. */
  45255. types?: number[];
  45256. /**
  45257. * Define the sampling modes of all the draw buffers we want to create
  45258. */
  45259. samplingModes?: number[];
  45260. /**
  45261. * Define if a depth buffer is required
  45262. */
  45263. generateDepthBuffer?: boolean;
  45264. /**
  45265. * Define if a stencil buffer is required
  45266. */
  45267. generateStencilBuffer?: boolean;
  45268. /**
  45269. * Define if a depth texture is required instead of a depth buffer
  45270. */
  45271. generateDepthTexture?: boolean;
  45272. /**
  45273. * Define the number of desired draw buffers
  45274. */
  45275. textureCount?: number;
  45276. /**
  45277. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45278. */
  45279. doNotChangeAspectRatio?: boolean;
  45280. /**
  45281. * Define the default type of the buffers we are creating
  45282. */
  45283. defaultType?: number;
  45284. }
  45285. /**
  45286. * A multi render target, like a render target provides the ability to render to a texture.
  45287. * Unlike the render target, it can render to several draw buffers in one draw.
  45288. * This is specially interesting in deferred rendering or for any effects requiring more than
  45289. * just one color from a single pass.
  45290. */
  45291. export class MultiRenderTarget extends RenderTargetTexture {
  45292. private _internalTextures;
  45293. private _textures;
  45294. private _multiRenderTargetOptions;
  45295. /**
  45296. * Get if draw buffers are currently supported by the used hardware and browser.
  45297. */
  45298. readonly isSupported: boolean;
  45299. /**
  45300. * Get the list of textures generated by the multi render target.
  45301. */
  45302. readonly textures: Texture[];
  45303. /**
  45304. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45305. */
  45306. readonly depthTexture: Texture;
  45307. /**
  45308. * Set the wrapping mode on U of all the textures we are rendering to.
  45309. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45310. */
  45311. wrapU: number;
  45312. /**
  45313. * Set the wrapping mode on V of all the textures we are rendering to.
  45314. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45315. */
  45316. wrapV: number;
  45317. /**
  45318. * Instantiate a new multi render target texture.
  45319. * A multi render target, like a render target provides the ability to render to a texture.
  45320. * Unlike the render target, it can render to several draw buffers in one draw.
  45321. * This is specially interesting in deferred rendering or for any effects requiring more than
  45322. * just one color from a single pass.
  45323. * @param name Define the name of the texture
  45324. * @param size Define the size of the buffers to render to
  45325. * @param count Define the number of target we are rendering into
  45326. * @param scene Define the scene the texture belongs to
  45327. * @param options Define the options used to create the multi render target
  45328. */
  45329. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45330. /** @hidden */
  45331. _rebuild(): void;
  45332. private _createInternalTextures;
  45333. private _createTextures;
  45334. /**
  45335. * Define the number of samples used if MSAA is enabled.
  45336. */
  45337. samples: number;
  45338. /**
  45339. * Resize all the textures in the multi render target.
  45340. * Be carrefull as it will recreate all the data in the new texture.
  45341. * @param size Define the new size
  45342. */
  45343. resize(size: any): void;
  45344. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45345. /**
  45346. * Dispose the render targets and their associated resources
  45347. */
  45348. dispose(): void;
  45349. /**
  45350. * Release all the underlying texture used as draw buffers.
  45351. */
  45352. releaseInternalTextures(): void;
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45356. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45357. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45358. import { Nullable } from "babylonjs/types";
  45359. module "babylonjs/Engines/engine" {
  45360. interface Engine {
  45361. /**
  45362. * Unbind a list of render target textures from the webGL context
  45363. * This is used only when drawBuffer extension or webGL2 are active
  45364. * @param textures defines the render target textures to unbind
  45365. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45366. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45367. */
  45368. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45369. /**
  45370. * Create a multi render target texture
  45371. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45372. * @param size defines the size of the texture
  45373. * @param options defines the creation options
  45374. * @returns the cube texture as an InternalTexture
  45375. */
  45376. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45377. /**
  45378. * Update the sample count for a given multiple render target texture
  45379. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45380. * @param textures defines the textures to update
  45381. * @param samples defines the sample count to set
  45382. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45383. */
  45384. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45385. }
  45386. }
  45387. }
  45388. declare module "babylonjs/Engines/Extensions/index" {
  45389. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45390. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45391. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45392. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45393. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45394. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45395. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45396. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45397. }
  45398. declare module "babylonjs/Engines/index" {
  45399. export * from "babylonjs/Engines/constants";
  45400. export * from "babylonjs/Engines/engine";
  45401. export * from "babylonjs/Engines/engineStore";
  45402. export * from "babylonjs/Engines/nullEngine";
  45403. export * from "babylonjs/Engines/Extensions/index";
  45404. export * from "babylonjs/Engines/IPipelineContext";
  45405. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45406. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45407. }
  45408. declare module "babylonjs/Events/clipboardEvents" {
  45409. /**
  45410. * Gather the list of clipboard event types as constants.
  45411. */
  45412. export class ClipboardEventTypes {
  45413. /**
  45414. * The clipboard event is fired when a copy command is active (pressed).
  45415. */
  45416. static readonly COPY: number;
  45417. /**
  45418. * The clipboard event is fired when a cut command is active (pressed).
  45419. */
  45420. static readonly CUT: number;
  45421. /**
  45422. * The clipboard event is fired when a paste command is active (pressed).
  45423. */
  45424. static readonly PASTE: number;
  45425. }
  45426. /**
  45427. * This class is used to store clipboard related info for the onClipboardObservable event.
  45428. */
  45429. export class ClipboardInfo {
  45430. /**
  45431. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45432. */
  45433. type: number;
  45434. /**
  45435. * Defines the related dom event
  45436. */
  45437. event: ClipboardEvent;
  45438. /**
  45439. *Creates an instance of ClipboardInfo.
  45440. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45441. * @param event Defines the related dom event
  45442. */
  45443. constructor(
  45444. /**
  45445. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45446. */
  45447. type: number,
  45448. /**
  45449. * Defines the related dom event
  45450. */
  45451. event: ClipboardEvent);
  45452. /**
  45453. * Get the clipboard event's type from the keycode.
  45454. * @param keyCode Defines the keyCode for the current keyboard event.
  45455. * @return {number}
  45456. */
  45457. static GetTypeFromCharacter(keyCode: number): number;
  45458. }
  45459. }
  45460. declare module "babylonjs/Events/index" {
  45461. export * from "babylonjs/Events/keyboardEvents";
  45462. export * from "babylonjs/Events/pointerEvents";
  45463. export * from "babylonjs/Events/clipboardEvents";
  45464. }
  45465. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45466. import { Scene } from "babylonjs/scene";
  45467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45468. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45469. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45470. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45471. /**
  45472. * Google Daydream controller
  45473. */
  45474. export class DaydreamController extends WebVRController {
  45475. /**
  45476. * Base Url for the controller model.
  45477. */
  45478. static MODEL_BASE_URL: string;
  45479. /**
  45480. * File name for the controller model.
  45481. */
  45482. static MODEL_FILENAME: string;
  45483. /**
  45484. * Gamepad Id prefix used to identify Daydream Controller.
  45485. */
  45486. static readonly GAMEPAD_ID_PREFIX: string;
  45487. /**
  45488. * Creates a new DaydreamController from a gamepad
  45489. * @param vrGamepad the gamepad that the controller should be created from
  45490. */
  45491. constructor(vrGamepad: any);
  45492. /**
  45493. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45494. * @param scene scene in which to add meshes
  45495. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45496. */
  45497. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45498. /**
  45499. * Called once for each button that changed state since the last frame
  45500. * @param buttonIdx Which button index changed
  45501. * @param state New state of the button
  45502. * @param changes Which properties on the state changed since last frame
  45503. */
  45504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45505. }
  45506. }
  45507. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45508. import { Scene } from "babylonjs/scene";
  45509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45510. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45511. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45512. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45513. /**
  45514. * Gear VR Controller
  45515. */
  45516. export class GearVRController extends WebVRController {
  45517. /**
  45518. * Base Url for the controller model.
  45519. */
  45520. static MODEL_BASE_URL: string;
  45521. /**
  45522. * File name for the controller model.
  45523. */
  45524. static MODEL_FILENAME: string;
  45525. /**
  45526. * Gamepad Id prefix used to identify this controller.
  45527. */
  45528. static readonly GAMEPAD_ID_PREFIX: string;
  45529. private readonly _buttonIndexToObservableNameMap;
  45530. /**
  45531. * Creates a new GearVRController from a gamepad
  45532. * @param vrGamepad the gamepad that the controller should be created from
  45533. */
  45534. constructor(vrGamepad: any);
  45535. /**
  45536. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45537. * @param scene scene in which to add meshes
  45538. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45539. */
  45540. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45541. /**
  45542. * Called once for each button that changed state since the last frame
  45543. * @param buttonIdx Which button index changed
  45544. * @param state New state of the button
  45545. * @param changes Which properties on the state changed since last frame
  45546. */
  45547. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45548. }
  45549. }
  45550. declare module "babylonjs/Gamepads/Controllers/index" {
  45551. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45552. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45553. export * from "babylonjs/Gamepads/Controllers/genericController";
  45554. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45555. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45556. export * from "babylonjs/Gamepads/Controllers/viveController";
  45557. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45558. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45559. }
  45560. declare module "babylonjs/Gamepads/index" {
  45561. export * from "babylonjs/Gamepads/Controllers/index";
  45562. export * from "babylonjs/Gamepads/gamepad";
  45563. export * from "babylonjs/Gamepads/gamepadManager";
  45564. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45565. export * from "babylonjs/Gamepads/xboxGamepad";
  45566. export * from "babylonjs/Gamepads/dualShockGamepad";
  45567. }
  45568. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45569. import { Scene } from "babylonjs/scene";
  45570. import { Vector4 } from "babylonjs/Maths/math.vector";
  45571. import { Color4 } from "babylonjs/Maths/math.color";
  45572. import { Mesh } from "babylonjs/Meshes/mesh";
  45573. import { Nullable } from "babylonjs/types";
  45574. /**
  45575. * Class containing static functions to help procedurally build meshes
  45576. */
  45577. export class PolyhedronBuilder {
  45578. /**
  45579. * Creates a polyhedron mesh
  45580. * * 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
  45581. * * The parameter `size` (positive float, default 1) sets the polygon size
  45582. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45583. * * 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`
  45584. * * 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
  45585. * * 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)`)
  45586. * * 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
  45587. * * 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
  45588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45591. * @param name defines the name of the mesh
  45592. * @param options defines the options used to create the mesh
  45593. * @param scene defines the hosting scene
  45594. * @returns the polyhedron mesh
  45595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45596. */
  45597. static CreatePolyhedron(name: string, options: {
  45598. type?: number;
  45599. size?: number;
  45600. sizeX?: number;
  45601. sizeY?: number;
  45602. sizeZ?: number;
  45603. custom?: any;
  45604. faceUV?: Vector4[];
  45605. faceColors?: Color4[];
  45606. flat?: boolean;
  45607. updatable?: boolean;
  45608. sideOrientation?: number;
  45609. frontUVs?: Vector4;
  45610. backUVs?: Vector4;
  45611. }, scene?: Nullable<Scene>): Mesh;
  45612. }
  45613. }
  45614. declare module "babylonjs/Gizmos/scaleGizmo" {
  45615. import { Observable } from "babylonjs/Misc/observable";
  45616. import { Nullable } from "babylonjs/types";
  45617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45618. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45619. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45620. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45621. /**
  45622. * Gizmo that enables scaling a mesh along 3 axis
  45623. */
  45624. export class ScaleGizmo extends Gizmo {
  45625. /**
  45626. * Internal gizmo used for interactions on the x axis
  45627. */
  45628. xGizmo: AxisScaleGizmo;
  45629. /**
  45630. * Internal gizmo used for interactions on the y axis
  45631. */
  45632. yGizmo: AxisScaleGizmo;
  45633. /**
  45634. * Internal gizmo used for interactions on the z axis
  45635. */
  45636. zGizmo: AxisScaleGizmo;
  45637. /**
  45638. * Internal gizmo used to scale all axis equally
  45639. */
  45640. uniformScaleGizmo: AxisScaleGizmo;
  45641. private _meshAttached;
  45642. private _updateGizmoRotationToMatchAttachedMesh;
  45643. private _snapDistance;
  45644. private _scaleRatio;
  45645. private _uniformScalingMesh;
  45646. private _octahedron;
  45647. /** Fires an event when any of it's sub gizmos are dragged */
  45648. onDragStartObservable: Observable<unknown>;
  45649. /** Fires an event when any of it's sub gizmos are released from dragging */
  45650. onDragEndObservable: Observable<unknown>;
  45651. attachedMesh: Nullable<AbstractMesh>;
  45652. /**
  45653. * Creates a ScaleGizmo
  45654. * @param gizmoLayer The utility layer the gizmo will be added to
  45655. */
  45656. constructor(gizmoLayer?: UtilityLayerRenderer);
  45657. updateGizmoRotationToMatchAttachedMesh: boolean;
  45658. /**
  45659. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45660. */
  45661. snapDistance: number;
  45662. /**
  45663. * Ratio for the scale of the gizmo (Default: 1)
  45664. */
  45665. scaleRatio: number;
  45666. /**
  45667. * Disposes of the gizmo
  45668. */
  45669. dispose(): void;
  45670. }
  45671. }
  45672. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45673. import { Observable } from "babylonjs/Misc/observable";
  45674. import { Nullable } from "babylonjs/types";
  45675. import { Vector3 } from "babylonjs/Maths/math.vector";
  45676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45677. import { Mesh } from "babylonjs/Meshes/mesh";
  45678. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45679. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45680. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45681. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45682. import { Color3 } from "babylonjs/Maths/math.color";
  45683. /**
  45684. * Single axis scale gizmo
  45685. */
  45686. export class AxisScaleGizmo extends Gizmo {
  45687. /**
  45688. * Drag behavior responsible for the gizmos dragging interactions
  45689. */
  45690. dragBehavior: PointerDragBehavior;
  45691. private _pointerObserver;
  45692. /**
  45693. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45694. */
  45695. snapDistance: number;
  45696. /**
  45697. * Event that fires each time the gizmo snaps to a new location.
  45698. * * snapDistance is the the change in distance
  45699. */
  45700. onSnapObservable: Observable<{
  45701. snapDistance: number;
  45702. }>;
  45703. /**
  45704. * If the scaling operation should be done on all axis (default: false)
  45705. */
  45706. uniformScaling: boolean;
  45707. private _isEnabled;
  45708. private _parent;
  45709. private _arrow;
  45710. private _coloredMaterial;
  45711. private _hoverMaterial;
  45712. /**
  45713. * Creates an AxisScaleGizmo
  45714. * @param gizmoLayer The utility layer the gizmo will be added to
  45715. * @param dragAxis The axis which the gizmo will be able to scale on
  45716. * @param color The color of the gizmo
  45717. */
  45718. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45720. /**
  45721. * If the gizmo is enabled
  45722. */
  45723. isEnabled: boolean;
  45724. /**
  45725. * Disposes of the gizmo
  45726. */
  45727. dispose(): void;
  45728. /**
  45729. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45730. * @param mesh The mesh to replace the default mesh of the gizmo
  45731. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45732. */
  45733. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45734. }
  45735. }
  45736. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45737. import { Observable } from "babylonjs/Misc/observable";
  45738. import { Nullable } from "babylonjs/types";
  45739. import { Vector3 } from "babylonjs/Maths/math.vector";
  45740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45741. import { Mesh } from "babylonjs/Meshes/mesh";
  45742. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45744. import { Color3 } from "babylonjs/Maths/math.color";
  45745. import "babylonjs/Meshes/Builders/boxBuilder";
  45746. /**
  45747. * Bounding box gizmo
  45748. */
  45749. export class BoundingBoxGizmo extends Gizmo {
  45750. private _lineBoundingBox;
  45751. private _rotateSpheresParent;
  45752. private _scaleBoxesParent;
  45753. private _boundingDimensions;
  45754. private _renderObserver;
  45755. private _pointerObserver;
  45756. private _scaleDragSpeed;
  45757. private _tmpQuaternion;
  45758. private _tmpVector;
  45759. private _tmpRotationMatrix;
  45760. /**
  45761. * 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)
  45762. */
  45763. ignoreChildren: boolean;
  45764. /**
  45765. * 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)
  45766. */
  45767. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45768. /**
  45769. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45770. */
  45771. rotationSphereSize: number;
  45772. /**
  45773. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45774. */
  45775. scaleBoxSize: number;
  45776. /**
  45777. * 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)
  45778. */
  45779. fixedDragMeshScreenSize: boolean;
  45780. /**
  45781. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45782. */
  45783. fixedDragMeshScreenSizeDistanceFactor: number;
  45784. /**
  45785. * Fired when a rotation sphere or scale box is dragged
  45786. */
  45787. onDragStartObservable: Observable<{}>;
  45788. /**
  45789. * Fired when a scale box is dragged
  45790. */
  45791. onScaleBoxDragObservable: Observable<{}>;
  45792. /**
  45793. * Fired when a scale box drag is ended
  45794. */
  45795. onScaleBoxDragEndObservable: Observable<{}>;
  45796. /**
  45797. * Fired when a rotation sphere is dragged
  45798. */
  45799. onRotationSphereDragObservable: Observable<{}>;
  45800. /**
  45801. * Fired when a rotation sphere drag is ended
  45802. */
  45803. onRotationSphereDragEndObservable: Observable<{}>;
  45804. /**
  45805. * 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)
  45806. */
  45807. scalePivot: Nullable<Vector3>;
  45808. /**
  45809. * Mesh used as a pivot to rotate the attached mesh
  45810. */
  45811. private _anchorMesh;
  45812. private _existingMeshScale;
  45813. private _dragMesh;
  45814. private pointerDragBehavior;
  45815. private coloredMaterial;
  45816. private hoverColoredMaterial;
  45817. /**
  45818. * Sets the color of the bounding box gizmo
  45819. * @param color the color to set
  45820. */
  45821. setColor(color: Color3): void;
  45822. /**
  45823. * Creates an BoundingBoxGizmo
  45824. * @param gizmoLayer The utility layer the gizmo will be added to
  45825. * @param color The color of the gizmo
  45826. */
  45827. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45829. private _selectNode;
  45830. /**
  45831. * Updates the bounding box information for the Gizmo
  45832. */
  45833. updateBoundingBox(): void;
  45834. private _updateRotationSpheres;
  45835. private _updateScaleBoxes;
  45836. /**
  45837. * Enables rotation on the specified axis and disables rotation on the others
  45838. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45839. */
  45840. setEnabledRotationAxis(axis: string): void;
  45841. /**
  45842. * Enables/disables scaling
  45843. * @param enable if scaling should be enabled
  45844. */
  45845. setEnabledScaling(enable: boolean): void;
  45846. private _updateDummy;
  45847. /**
  45848. * Enables a pointer drag behavior on the bounding box of the gizmo
  45849. */
  45850. enableDragBehavior(): void;
  45851. /**
  45852. * Disposes of the gizmo
  45853. */
  45854. dispose(): void;
  45855. /**
  45856. * 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)
  45857. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45858. * @returns the bounding box mesh with the passed in mesh as a child
  45859. */
  45860. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45861. /**
  45862. * CustomMeshes are not supported by this gizmo
  45863. * @param mesh The mesh to replace the default mesh of the gizmo
  45864. */
  45865. setCustomMesh(mesh: Mesh): void;
  45866. }
  45867. }
  45868. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45869. import { Observable } from "babylonjs/Misc/observable";
  45870. import { Nullable } from "babylonjs/types";
  45871. import { Vector3 } from "babylonjs/Maths/math.vector";
  45872. import { Color3 } from "babylonjs/Maths/math.color";
  45873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45874. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45875. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45876. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45877. import "babylonjs/Meshes/Builders/linesBuilder";
  45878. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45879. /**
  45880. * Single plane rotation gizmo
  45881. */
  45882. export class PlaneRotationGizmo extends Gizmo {
  45883. /**
  45884. * Drag behavior responsible for the gizmos dragging interactions
  45885. */
  45886. dragBehavior: PointerDragBehavior;
  45887. private _pointerObserver;
  45888. /**
  45889. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45890. */
  45891. snapDistance: number;
  45892. /**
  45893. * Event that fires each time the gizmo snaps to a new location.
  45894. * * snapDistance is the the change in distance
  45895. */
  45896. onSnapObservable: Observable<{
  45897. snapDistance: number;
  45898. }>;
  45899. private _isEnabled;
  45900. private _parent;
  45901. /**
  45902. * Creates a PlaneRotationGizmo
  45903. * @param gizmoLayer The utility layer the gizmo will be added to
  45904. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45905. * @param color The color of the gizmo
  45906. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45907. */
  45908. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45909. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45910. /**
  45911. * If the gizmo is enabled
  45912. */
  45913. isEnabled: boolean;
  45914. /**
  45915. * Disposes of the gizmo
  45916. */
  45917. dispose(): void;
  45918. }
  45919. }
  45920. declare module "babylonjs/Gizmos/rotationGizmo" {
  45921. import { Observable } from "babylonjs/Misc/observable";
  45922. import { Nullable } from "babylonjs/types";
  45923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45924. import { Mesh } from "babylonjs/Meshes/mesh";
  45925. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45926. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45927. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45928. /**
  45929. * Gizmo that enables rotating a mesh along 3 axis
  45930. */
  45931. export class RotationGizmo extends Gizmo {
  45932. /**
  45933. * Internal gizmo used for interactions on the x axis
  45934. */
  45935. xGizmo: PlaneRotationGizmo;
  45936. /**
  45937. * Internal gizmo used for interactions on the y axis
  45938. */
  45939. yGizmo: PlaneRotationGizmo;
  45940. /**
  45941. * Internal gizmo used for interactions on the z axis
  45942. */
  45943. zGizmo: PlaneRotationGizmo;
  45944. /** Fires an event when any of it's sub gizmos are dragged */
  45945. onDragStartObservable: Observable<unknown>;
  45946. /** Fires an event when any of it's sub gizmos are released from dragging */
  45947. onDragEndObservable: Observable<unknown>;
  45948. private _meshAttached;
  45949. attachedMesh: Nullable<AbstractMesh>;
  45950. /**
  45951. * Creates a RotationGizmo
  45952. * @param gizmoLayer The utility layer the gizmo will be added to
  45953. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45954. */
  45955. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45956. updateGizmoRotationToMatchAttachedMesh: boolean;
  45957. /**
  45958. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45959. */
  45960. snapDistance: number;
  45961. /**
  45962. * Ratio for the scale of the gizmo (Default: 1)
  45963. */
  45964. scaleRatio: number;
  45965. /**
  45966. * Disposes of the gizmo
  45967. */
  45968. dispose(): void;
  45969. /**
  45970. * CustomMeshes are not supported by this gizmo
  45971. * @param mesh The mesh to replace the default mesh of the gizmo
  45972. */
  45973. setCustomMesh(mesh: Mesh): void;
  45974. }
  45975. }
  45976. declare module "babylonjs/Gizmos/gizmoManager" {
  45977. import { Observable } from "babylonjs/Misc/observable";
  45978. import { Nullable } from "babylonjs/types";
  45979. import { Scene, IDisposable } from "babylonjs/scene";
  45980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45981. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45982. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45983. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45984. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45985. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45986. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45987. /**
  45988. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45989. */
  45990. export class GizmoManager implements IDisposable {
  45991. private scene;
  45992. /**
  45993. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45994. */
  45995. gizmos: {
  45996. positionGizmo: Nullable<PositionGizmo>;
  45997. rotationGizmo: Nullable<RotationGizmo>;
  45998. scaleGizmo: Nullable<ScaleGizmo>;
  45999. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46000. };
  46001. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46002. clearGizmoOnEmptyPointerEvent: boolean;
  46003. /** Fires an event when the manager is attached to a mesh */
  46004. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46005. private _gizmosEnabled;
  46006. private _pointerObserver;
  46007. private _attachedMesh;
  46008. private _boundingBoxColor;
  46009. private _defaultUtilityLayer;
  46010. private _defaultKeepDepthUtilityLayer;
  46011. /**
  46012. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46013. */
  46014. boundingBoxDragBehavior: SixDofDragBehavior;
  46015. /**
  46016. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46017. */
  46018. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46019. /**
  46020. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46021. */
  46022. usePointerToAttachGizmos: boolean;
  46023. /**
  46024. * Utility layer that the bounding box gizmo belongs to
  46025. */
  46026. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46027. /**
  46028. * Utility layer that all gizmos besides bounding box belong to
  46029. */
  46030. readonly utilityLayer: UtilityLayerRenderer;
  46031. /**
  46032. * Instatiates a gizmo manager
  46033. * @param scene the scene to overlay the gizmos on top of
  46034. */
  46035. constructor(scene: Scene);
  46036. /**
  46037. * Attaches a set of gizmos to the specified mesh
  46038. * @param mesh The mesh the gizmo's should be attached to
  46039. */
  46040. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46041. /**
  46042. * If the position gizmo is enabled
  46043. */
  46044. positionGizmoEnabled: boolean;
  46045. /**
  46046. * If the rotation gizmo is enabled
  46047. */
  46048. rotationGizmoEnabled: boolean;
  46049. /**
  46050. * If the scale gizmo is enabled
  46051. */
  46052. scaleGizmoEnabled: boolean;
  46053. /**
  46054. * If the boundingBox gizmo is enabled
  46055. */
  46056. boundingBoxGizmoEnabled: boolean;
  46057. /**
  46058. * Disposes of the gizmo manager
  46059. */
  46060. dispose(): void;
  46061. }
  46062. }
  46063. declare module "babylonjs/Lights/directionalLight" {
  46064. import { Camera } from "babylonjs/Cameras/camera";
  46065. import { Scene } from "babylonjs/scene";
  46066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46068. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46069. import { Effect } from "babylonjs/Materials/effect";
  46070. /**
  46071. * A directional light is defined by a direction (what a surprise!).
  46072. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46073. * 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.
  46074. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46075. */
  46076. export class DirectionalLight extends ShadowLight {
  46077. private _shadowFrustumSize;
  46078. /**
  46079. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46080. */
  46081. /**
  46082. * Specifies a fix frustum size for the shadow generation.
  46083. */
  46084. shadowFrustumSize: number;
  46085. private _shadowOrthoScale;
  46086. /**
  46087. * Gets the shadow projection scale against the optimal computed one.
  46088. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46089. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46090. */
  46091. /**
  46092. * Sets the shadow projection scale against the optimal computed one.
  46093. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46094. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46095. */
  46096. shadowOrthoScale: number;
  46097. /**
  46098. * Automatically compute the projection matrix to best fit (including all the casters)
  46099. * on each frame.
  46100. */
  46101. autoUpdateExtends: boolean;
  46102. private _orthoLeft;
  46103. private _orthoRight;
  46104. private _orthoTop;
  46105. private _orthoBottom;
  46106. /**
  46107. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46108. * The directional light is emitted from everywhere in the given direction.
  46109. * It can cast shadows.
  46110. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46111. * @param name The friendly name of the light
  46112. * @param direction The direction of the light
  46113. * @param scene The scene the light belongs to
  46114. */
  46115. constructor(name: string, direction: Vector3, scene: Scene);
  46116. /**
  46117. * Returns the string "DirectionalLight".
  46118. * @return The class name
  46119. */
  46120. getClassName(): string;
  46121. /**
  46122. * Returns the integer 1.
  46123. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46124. */
  46125. getTypeID(): number;
  46126. /**
  46127. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46128. * Returns the DirectionalLight Shadow projection matrix.
  46129. */
  46130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46131. /**
  46132. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46133. * Returns the DirectionalLight Shadow projection matrix.
  46134. */
  46135. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46136. /**
  46137. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46138. * Returns the DirectionalLight Shadow projection matrix.
  46139. */
  46140. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46141. protected _buildUniformLayout(): void;
  46142. /**
  46143. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46144. * @param effect The effect to update
  46145. * @param lightIndex The index of the light in the effect to update
  46146. * @returns The directional light
  46147. */
  46148. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46149. /**
  46150. * Gets the minZ used for shadow according to both the scene and the light.
  46151. *
  46152. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46153. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46154. * @param activeCamera The camera we are returning the min for
  46155. * @returns the depth min z
  46156. */
  46157. getDepthMinZ(activeCamera: Camera): number;
  46158. /**
  46159. * Gets the maxZ used for shadow according to both the scene and the light.
  46160. *
  46161. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46162. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46163. * @param activeCamera The camera we are returning the max for
  46164. * @returns the depth max z
  46165. */
  46166. getDepthMaxZ(activeCamera: Camera): number;
  46167. /**
  46168. * Prepares the list of defines specific to the light type.
  46169. * @param defines the list of defines
  46170. * @param lightIndex defines the index of the light for the effect
  46171. */
  46172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46173. }
  46174. }
  46175. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46176. import { Mesh } from "babylonjs/Meshes/mesh";
  46177. /**
  46178. * Class containing static functions to help procedurally build meshes
  46179. */
  46180. export class HemisphereBuilder {
  46181. /**
  46182. * Creates a hemisphere mesh
  46183. * @param name defines the name of the mesh
  46184. * @param options defines the options used to create the mesh
  46185. * @param scene defines the hosting scene
  46186. * @returns the hemisphere mesh
  46187. */
  46188. static CreateHemisphere(name: string, options: {
  46189. segments?: number;
  46190. diameter?: number;
  46191. sideOrientation?: number;
  46192. }, scene: any): Mesh;
  46193. }
  46194. }
  46195. declare module "babylonjs/Lights/spotLight" {
  46196. import { Nullable } from "babylonjs/types";
  46197. import { Scene } from "babylonjs/scene";
  46198. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46200. import { Effect } from "babylonjs/Materials/effect";
  46201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46202. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46203. /**
  46204. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46205. * These values define a cone of light starting from the position, emitting toward the direction.
  46206. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46207. * and the exponent defines the speed of the decay of the light with distance (reach).
  46208. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46209. */
  46210. export class SpotLight extends ShadowLight {
  46211. private _angle;
  46212. private _innerAngle;
  46213. private _cosHalfAngle;
  46214. private _lightAngleScale;
  46215. private _lightAngleOffset;
  46216. /**
  46217. * Gets the cone angle of the spot light in Radians.
  46218. */
  46219. /**
  46220. * Sets the cone angle of the spot light in Radians.
  46221. */
  46222. angle: number;
  46223. /**
  46224. * Only used in gltf falloff mode, this defines the angle where
  46225. * the directional falloff will start before cutting at angle which could be seen
  46226. * as outer angle.
  46227. */
  46228. /**
  46229. * Only used in gltf falloff mode, this defines the angle where
  46230. * the directional falloff will start before cutting at angle which could be seen
  46231. * as outer angle.
  46232. */
  46233. innerAngle: number;
  46234. private _shadowAngleScale;
  46235. /**
  46236. * Allows scaling the angle of the light for shadow generation only.
  46237. */
  46238. /**
  46239. * Allows scaling the angle of the light for shadow generation only.
  46240. */
  46241. shadowAngleScale: number;
  46242. /**
  46243. * The light decay speed with the distance from the emission spot.
  46244. */
  46245. exponent: number;
  46246. private _projectionTextureMatrix;
  46247. /**
  46248. * Allows reading the projecton texture
  46249. */
  46250. readonly projectionTextureMatrix: Matrix;
  46251. protected _projectionTextureLightNear: number;
  46252. /**
  46253. * Gets the near clip of the Spotlight for texture projection.
  46254. */
  46255. /**
  46256. * Sets the near clip of the Spotlight for texture projection.
  46257. */
  46258. projectionTextureLightNear: number;
  46259. protected _projectionTextureLightFar: number;
  46260. /**
  46261. * Gets the far clip of the Spotlight for texture projection.
  46262. */
  46263. /**
  46264. * Sets the far clip of the Spotlight for texture projection.
  46265. */
  46266. projectionTextureLightFar: number;
  46267. protected _projectionTextureUpDirection: Vector3;
  46268. /**
  46269. * Gets the Up vector of the Spotlight for texture projection.
  46270. */
  46271. /**
  46272. * Sets the Up vector of the Spotlight for texture projection.
  46273. */
  46274. projectionTextureUpDirection: Vector3;
  46275. private _projectionTexture;
  46276. /**
  46277. * Gets the projection texture of the light.
  46278. */
  46279. /**
  46280. * Sets the projection texture of the light.
  46281. */
  46282. projectionTexture: Nullable<BaseTexture>;
  46283. private _projectionTextureViewLightDirty;
  46284. private _projectionTextureProjectionLightDirty;
  46285. private _projectionTextureDirty;
  46286. private _projectionTextureViewTargetVector;
  46287. private _projectionTextureViewLightMatrix;
  46288. private _projectionTextureProjectionLightMatrix;
  46289. private _projectionTextureScalingMatrix;
  46290. /**
  46291. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46292. * It can cast shadows.
  46293. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46294. * @param name The light friendly name
  46295. * @param position The position of the spot light in the scene
  46296. * @param direction The direction of the light in the scene
  46297. * @param angle The cone angle of the light in Radians
  46298. * @param exponent The light decay speed with the distance from the emission spot
  46299. * @param scene The scene the lights belongs to
  46300. */
  46301. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46302. /**
  46303. * Returns the string "SpotLight".
  46304. * @returns the class name
  46305. */
  46306. getClassName(): string;
  46307. /**
  46308. * Returns the integer 2.
  46309. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46310. */
  46311. getTypeID(): number;
  46312. /**
  46313. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46314. */
  46315. protected _setDirection(value: Vector3): void;
  46316. /**
  46317. * Overrides the position setter to recompute the projection texture view light Matrix.
  46318. */
  46319. protected _setPosition(value: Vector3): void;
  46320. /**
  46321. * 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.
  46322. * Returns the SpotLight.
  46323. */
  46324. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46325. protected _computeProjectionTextureViewLightMatrix(): void;
  46326. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46327. /**
  46328. * Main function for light texture projection matrix computing.
  46329. */
  46330. protected _computeProjectionTextureMatrix(): void;
  46331. protected _buildUniformLayout(): void;
  46332. private _computeAngleValues;
  46333. /**
  46334. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46335. * @param effect The effect to update
  46336. * @param lightIndex The index of the light in the effect to update
  46337. * @returns The spot light
  46338. */
  46339. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46340. /**
  46341. * Disposes the light and the associated resources.
  46342. */
  46343. dispose(): void;
  46344. /**
  46345. * Prepares the list of defines specific to the light type.
  46346. * @param defines the list of defines
  46347. * @param lightIndex defines the index of the light for the effect
  46348. */
  46349. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46350. }
  46351. }
  46352. declare module "babylonjs/Gizmos/lightGizmo" {
  46353. import { Nullable } from "babylonjs/types";
  46354. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46355. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46356. import { Light } from "babylonjs/Lights/light";
  46357. /**
  46358. * Gizmo that enables viewing a light
  46359. */
  46360. export class LightGizmo extends Gizmo {
  46361. private _lightMesh;
  46362. private _material;
  46363. private cachedPosition;
  46364. private cachedForward;
  46365. /**
  46366. * Creates a LightGizmo
  46367. * @param gizmoLayer The utility layer the gizmo will be added to
  46368. */
  46369. constructor(gizmoLayer?: UtilityLayerRenderer);
  46370. private _light;
  46371. /**
  46372. * The light that the gizmo is attached to
  46373. */
  46374. light: Nullable<Light>;
  46375. /**
  46376. * @hidden
  46377. * Updates the gizmo to match the attached mesh's position/rotation
  46378. */
  46379. protected _update(): void;
  46380. private static _Scale;
  46381. /**
  46382. * Creates the lines for a light mesh
  46383. */
  46384. private static _createLightLines;
  46385. /**
  46386. * Disposes of the light gizmo
  46387. */
  46388. dispose(): void;
  46389. private static _CreateHemisphericLightMesh;
  46390. private static _CreatePointLightMesh;
  46391. private static _CreateSpotLightMesh;
  46392. private static _CreateDirectionalLightMesh;
  46393. }
  46394. }
  46395. declare module "babylonjs/Gizmos/index" {
  46396. export * from "babylonjs/Gizmos/axisDragGizmo";
  46397. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46398. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46399. export * from "babylonjs/Gizmos/gizmo";
  46400. export * from "babylonjs/Gizmos/gizmoManager";
  46401. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46402. export * from "babylonjs/Gizmos/positionGizmo";
  46403. export * from "babylonjs/Gizmos/rotationGizmo";
  46404. export * from "babylonjs/Gizmos/scaleGizmo";
  46405. export * from "babylonjs/Gizmos/lightGizmo";
  46406. export * from "babylonjs/Gizmos/planeDragGizmo";
  46407. }
  46408. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46409. /** @hidden */
  46410. export var backgroundFragmentDeclaration: {
  46411. name: string;
  46412. shader: string;
  46413. };
  46414. }
  46415. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46416. /** @hidden */
  46417. export var backgroundUboDeclaration: {
  46418. name: string;
  46419. shader: string;
  46420. };
  46421. }
  46422. declare module "babylonjs/Shaders/background.fragment" {
  46423. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46424. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46425. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46426. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46427. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46428. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46429. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46430. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46431. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46432. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46433. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46434. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46435. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46436. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46437. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46438. /** @hidden */
  46439. export var backgroundPixelShader: {
  46440. name: string;
  46441. shader: string;
  46442. };
  46443. }
  46444. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46445. /** @hidden */
  46446. export var backgroundVertexDeclaration: {
  46447. name: string;
  46448. shader: string;
  46449. };
  46450. }
  46451. declare module "babylonjs/Shaders/background.vertex" {
  46452. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46453. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46457. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46458. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46459. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46460. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46461. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46462. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46463. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46464. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46465. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46466. /** @hidden */
  46467. export var backgroundVertexShader: {
  46468. name: string;
  46469. shader: string;
  46470. };
  46471. }
  46472. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46473. import { Nullable, int, float } from "babylonjs/types";
  46474. import { Scene } from "babylonjs/scene";
  46475. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46478. import { Mesh } from "babylonjs/Meshes/mesh";
  46479. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46480. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46481. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46483. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46484. import { Color3 } from "babylonjs/Maths/math.color";
  46485. import "babylonjs/Shaders/background.fragment";
  46486. import "babylonjs/Shaders/background.vertex";
  46487. /**
  46488. * Background material used to create an efficient environement around your scene.
  46489. */
  46490. export class BackgroundMaterial extends PushMaterial {
  46491. /**
  46492. * Standard reflectance value at parallel view angle.
  46493. */
  46494. static StandardReflectance0: number;
  46495. /**
  46496. * Standard reflectance value at grazing angle.
  46497. */
  46498. static StandardReflectance90: number;
  46499. protected _primaryColor: Color3;
  46500. /**
  46501. * Key light Color (multiply against the environement texture)
  46502. */
  46503. primaryColor: Color3;
  46504. protected __perceptualColor: Nullable<Color3>;
  46505. /**
  46506. * Experimental Internal Use Only.
  46507. *
  46508. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46509. * This acts as a helper to set the primary color to a more "human friendly" value.
  46510. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46511. * output color as close as possible from the chosen value.
  46512. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46513. * part of lighting setup.)
  46514. */
  46515. _perceptualColor: Nullable<Color3>;
  46516. protected _primaryColorShadowLevel: float;
  46517. /**
  46518. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46519. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46520. */
  46521. primaryColorShadowLevel: float;
  46522. protected _primaryColorHighlightLevel: float;
  46523. /**
  46524. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46525. * The primary color is used at the level chosen to define what the white area would look.
  46526. */
  46527. primaryColorHighlightLevel: float;
  46528. protected _reflectionTexture: Nullable<BaseTexture>;
  46529. /**
  46530. * Reflection Texture used in the material.
  46531. * Should be author in a specific way for the best result (refer to the documentation).
  46532. */
  46533. reflectionTexture: Nullable<BaseTexture>;
  46534. protected _reflectionBlur: float;
  46535. /**
  46536. * Reflection Texture level of blur.
  46537. *
  46538. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46539. * texture twice.
  46540. */
  46541. reflectionBlur: float;
  46542. protected _diffuseTexture: Nullable<BaseTexture>;
  46543. /**
  46544. * Diffuse Texture used in the material.
  46545. * Should be author in a specific way for the best result (refer to the documentation).
  46546. */
  46547. diffuseTexture: Nullable<BaseTexture>;
  46548. protected _shadowLights: Nullable<IShadowLight[]>;
  46549. /**
  46550. * Specify the list of lights casting shadow on the material.
  46551. * All scene shadow lights will be included if null.
  46552. */
  46553. shadowLights: Nullable<IShadowLight[]>;
  46554. protected _shadowLevel: float;
  46555. /**
  46556. * Helps adjusting the shadow to a softer level if required.
  46557. * 0 means black shadows and 1 means no shadows.
  46558. */
  46559. shadowLevel: float;
  46560. protected _sceneCenter: Vector3;
  46561. /**
  46562. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46563. * It is usually zero but might be interesting to modify according to your setup.
  46564. */
  46565. sceneCenter: Vector3;
  46566. protected _opacityFresnel: boolean;
  46567. /**
  46568. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46569. * This helps ensuring a nice transition when the camera goes under the ground.
  46570. */
  46571. opacityFresnel: boolean;
  46572. protected _reflectionFresnel: boolean;
  46573. /**
  46574. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46575. * This helps adding a mirror texture on the ground.
  46576. */
  46577. reflectionFresnel: boolean;
  46578. protected _reflectionFalloffDistance: number;
  46579. /**
  46580. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46581. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46582. */
  46583. reflectionFalloffDistance: number;
  46584. protected _reflectionAmount: number;
  46585. /**
  46586. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46587. */
  46588. reflectionAmount: number;
  46589. protected _reflectionReflectance0: number;
  46590. /**
  46591. * This specifies the weight of the reflection at grazing angle.
  46592. */
  46593. reflectionReflectance0: number;
  46594. protected _reflectionReflectance90: number;
  46595. /**
  46596. * This specifies the weight of the reflection at a perpendicular point of view.
  46597. */
  46598. reflectionReflectance90: number;
  46599. /**
  46600. * Sets the reflection reflectance fresnel values according to the default standard
  46601. * empirically know to work well :-)
  46602. */
  46603. reflectionStandardFresnelWeight: number;
  46604. protected _useRGBColor: boolean;
  46605. /**
  46606. * Helps to directly use the maps channels instead of their level.
  46607. */
  46608. useRGBColor: boolean;
  46609. protected _enableNoise: boolean;
  46610. /**
  46611. * This helps reducing the banding effect that could occur on the background.
  46612. */
  46613. enableNoise: boolean;
  46614. /**
  46615. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46616. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46617. * Recommended to be keep at 1.0 except for special cases.
  46618. */
  46619. fovMultiplier: number;
  46620. private _fovMultiplier;
  46621. /**
  46622. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46623. */
  46624. useEquirectangularFOV: boolean;
  46625. private _maxSimultaneousLights;
  46626. /**
  46627. * Number of Simultaneous lights allowed on the material.
  46628. */
  46629. maxSimultaneousLights: int;
  46630. /**
  46631. * Default configuration related to image processing available in the Background Material.
  46632. */
  46633. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46634. /**
  46635. * Keep track of the image processing observer to allow dispose and replace.
  46636. */
  46637. private _imageProcessingObserver;
  46638. /**
  46639. * Attaches a new image processing configuration to the PBR Material.
  46640. * @param configuration (if null the scene configuration will be use)
  46641. */
  46642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46643. /**
  46644. * Gets the image processing configuration used either in this material.
  46645. */
  46646. /**
  46647. * Sets the Default image processing configuration used either in the this material.
  46648. *
  46649. * If sets to null, the scene one is in use.
  46650. */
  46651. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46652. /**
  46653. * Gets wether the color curves effect is enabled.
  46654. */
  46655. /**
  46656. * Sets wether the color curves effect is enabled.
  46657. */
  46658. cameraColorCurvesEnabled: boolean;
  46659. /**
  46660. * Gets wether the color grading effect is enabled.
  46661. */
  46662. /**
  46663. * Gets wether the color grading effect is enabled.
  46664. */
  46665. cameraColorGradingEnabled: boolean;
  46666. /**
  46667. * Gets wether tonemapping is enabled or not.
  46668. */
  46669. /**
  46670. * Sets wether tonemapping is enabled or not
  46671. */
  46672. cameraToneMappingEnabled: boolean;
  46673. /**
  46674. * The camera exposure used on this material.
  46675. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46676. * This corresponds to a photographic exposure.
  46677. */
  46678. /**
  46679. * The camera exposure used on this material.
  46680. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46681. * This corresponds to a photographic exposure.
  46682. */
  46683. cameraExposure: float;
  46684. /**
  46685. * Gets The camera contrast used on this material.
  46686. */
  46687. /**
  46688. * Sets The camera contrast used on this material.
  46689. */
  46690. cameraContrast: float;
  46691. /**
  46692. * Gets the Color Grading 2D Lookup Texture.
  46693. */
  46694. /**
  46695. * Sets the Color Grading 2D Lookup Texture.
  46696. */
  46697. cameraColorGradingTexture: Nullable<BaseTexture>;
  46698. /**
  46699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46701. * 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;
  46702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46703. */
  46704. /**
  46705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46707. * 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;
  46708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46709. */
  46710. cameraColorCurves: Nullable<ColorCurves>;
  46711. /**
  46712. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46713. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46714. */
  46715. switchToBGR: boolean;
  46716. private _renderTargets;
  46717. private _reflectionControls;
  46718. private _white;
  46719. private _primaryShadowColor;
  46720. private _primaryHighlightColor;
  46721. /**
  46722. * Instantiates a Background Material in the given scene
  46723. * @param name The friendly name of the material
  46724. * @param scene The scene to add the material to
  46725. */
  46726. constructor(name: string, scene: Scene);
  46727. /**
  46728. * Gets a boolean indicating that current material needs to register RTT
  46729. */
  46730. readonly hasRenderTargetTextures: boolean;
  46731. /**
  46732. * The entire material has been created in order to prevent overdraw.
  46733. * @returns false
  46734. */
  46735. needAlphaTesting(): boolean;
  46736. /**
  46737. * The entire material has been created in order to prevent overdraw.
  46738. * @returns true if blending is enable
  46739. */
  46740. needAlphaBlending(): boolean;
  46741. /**
  46742. * Checks wether the material is ready to be rendered for a given mesh.
  46743. * @param mesh The mesh to render
  46744. * @param subMesh The submesh to check against
  46745. * @param useInstances Specify wether or not the material is used with instances
  46746. * @returns true if all the dependencies are ready (Textures, Effects...)
  46747. */
  46748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46749. /**
  46750. * Compute the primary color according to the chosen perceptual color.
  46751. */
  46752. private _computePrimaryColorFromPerceptualColor;
  46753. /**
  46754. * Compute the highlights and shadow colors according to their chosen levels.
  46755. */
  46756. private _computePrimaryColors;
  46757. /**
  46758. * Build the uniform buffer used in the material.
  46759. */
  46760. buildUniformLayout(): void;
  46761. /**
  46762. * Unbind the material.
  46763. */
  46764. unbind(): void;
  46765. /**
  46766. * Bind only the world matrix to the material.
  46767. * @param world The world matrix to bind.
  46768. */
  46769. bindOnlyWorldMatrix(world: Matrix): void;
  46770. /**
  46771. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46772. * @param world The world matrix to bind.
  46773. * @param subMesh The submesh to bind for.
  46774. */
  46775. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46776. /**
  46777. * Dispose the material.
  46778. * @param forceDisposeEffect Force disposal of the associated effect.
  46779. * @param forceDisposeTextures Force disposal of the associated textures.
  46780. */
  46781. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46782. /**
  46783. * Clones the material.
  46784. * @param name The cloned name.
  46785. * @returns The cloned material.
  46786. */
  46787. clone(name: string): BackgroundMaterial;
  46788. /**
  46789. * Serializes the current material to its JSON representation.
  46790. * @returns The JSON representation.
  46791. */
  46792. serialize(): any;
  46793. /**
  46794. * Gets the class name of the material
  46795. * @returns "BackgroundMaterial"
  46796. */
  46797. getClassName(): string;
  46798. /**
  46799. * Parse a JSON input to create back a background material.
  46800. * @param source The JSON data to parse
  46801. * @param scene The scene to create the parsed material in
  46802. * @param rootUrl The root url of the assets the material depends upon
  46803. * @returns the instantiated BackgroundMaterial.
  46804. */
  46805. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46806. }
  46807. }
  46808. declare module "babylonjs/Helpers/environmentHelper" {
  46809. import { Observable } from "babylonjs/Misc/observable";
  46810. import { Nullable } from "babylonjs/types";
  46811. import { Scene } from "babylonjs/scene";
  46812. import { Vector3 } from "babylonjs/Maths/math.vector";
  46813. import { Color3 } from "babylonjs/Maths/math.color";
  46814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46815. import { Mesh } from "babylonjs/Meshes/mesh";
  46816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46817. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46818. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46819. import "babylonjs/Meshes/Builders/planeBuilder";
  46820. import "babylonjs/Meshes/Builders/boxBuilder";
  46821. /**
  46822. * Represents the different options available during the creation of
  46823. * a Environment helper.
  46824. *
  46825. * This can control the default ground, skybox and image processing setup of your scene.
  46826. */
  46827. export interface IEnvironmentHelperOptions {
  46828. /**
  46829. * Specifies wether or not to create a ground.
  46830. * True by default.
  46831. */
  46832. createGround: boolean;
  46833. /**
  46834. * Specifies the ground size.
  46835. * 15 by default.
  46836. */
  46837. groundSize: number;
  46838. /**
  46839. * The texture used on the ground for the main color.
  46840. * Comes from the BabylonJS CDN by default.
  46841. *
  46842. * Remarks: Can be either a texture or a url.
  46843. */
  46844. groundTexture: string | BaseTexture;
  46845. /**
  46846. * The color mixed in the ground texture by default.
  46847. * BabylonJS clearColor by default.
  46848. */
  46849. groundColor: Color3;
  46850. /**
  46851. * Specifies the ground opacity.
  46852. * 1 by default.
  46853. */
  46854. groundOpacity: number;
  46855. /**
  46856. * Enables the ground to receive shadows.
  46857. * True by default.
  46858. */
  46859. enableGroundShadow: boolean;
  46860. /**
  46861. * Helps preventing the shadow to be fully black on the ground.
  46862. * 0.5 by default.
  46863. */
  46864. groundShadowLevel: number;
  46865. /**
  46866. * Creates a mirror texture attach to the ground.
  46867. * false by default.
  46868. */
  46869. enableGroundMirror: boolean;
  46870. /**
  46871. * Specifies the ground mirror size ratio.
  46872. * 0.3 by default as the default kernel is 64.
  46873. */
  46874. groundMirrorSizeRatio: number;
  46875. /**
  46876. * Specifies the ground mirror blur kernel size.
  46877. * 64 by default.
  46878. */
  46879. groundMirrorBlurKernel: number;
  46880. /**
  46881. * Specifies the ground mirror visibility amount.
  46882. * 1 by default
  46883. */
  46884. groundMirrorAmount: number;
  46885. /**
  46886. * Specifies the ground mirror reflectance weight.
  46887. * This uses the standard weight of the background material to setup the fresnel effect
  46888. * of the mirror.
  46889. * 1 by default.
  46890. */
  46891. groundMirrorFresnelWeight: number;
  46892. /**
  46893. * Specifies the ground mirror Falloff distance.
  46894. * This can helps reducing the size of the reflection.
  46895. * 0 by Default.
  46896. */
  46897. groundMirrorFallOffDistance: number;
  46898. /**
  46899. * Specifies the ground mirror texture type.
  46900. * Unsigned Int by Default.
  46901. */
  46902. groundMirrorTextureType: number;
  46903. /**
  46904. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46905. * the shown objects.
  46906. */
  46907. groundYBias: number;
  46908. /**
  46909. * Specifies wether or not to create a skybox.
  46910. * True by default.
  46911. */
  46912. createSkybox: boolean;
  46913. /**
  46914. * Specifies the skybox size.
  46915. * 20 by default.
  46916. */
  46917. skyboxSize: number;
  46918. /**
  46919. * The texture used on the skybox for the main color.
  46920. * Comes from the BabylonJS CDN by default.
  46921. *
  46922. * Remarks: Can be either a texture or a url.
  46923. */
  46924. skyboxTexture: string | BaseTexture;
  46925. /**
  46926. * The color mixed in the skybox texture by default.
  46927. * BabylonJS clearColor by default.
  46928. */
  46929. skyboxColor: Color3;
  46930. /**
  46931. * The background rotation around the Y axis of the scene.
  46932. * This helps aligning the key lights of your scene with the background.
  46933. * 0 by default.
  46934. */
  46935. backgroundYRotation: number;
  46936. /**
  46937. * Compute automatically the size of the elements to best fit with the scene.
  46938. */
  46939. sizeAuto: boolean;
  46940. /**
  46941. * Default position of the rootMesh if autoSize is not true.
  46942. */
  46943. rootPosition: Vector3;
  46944. /**
  46945. * Sets up the image processing in the scene.
  46946. * true by default.
  46947. */
  46948. setupImageProcessing: boolean;
  46949. /**
  46950. * The texture used as your environment texture in the scene.
  46951. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46952. *
  46953. * Remarks: Can be either a texture or a url.
  46954. */
  46955. environmentTexture: string | BaseTexture;
  46956. /**
  46957. * The value of the exposure to apply to the scene.
  46958. * 0.6 by default if setupImageProcessing is true.
  46959. */
  46960. cameraExposure: number;
  46961. /**
  46962. * The value of the contrast to apply to the scene.
  46963. * 1.6 by default if setupImageProcessing is true.
  46964. */
  46965. cameraContrast: number;
  46966. /**
  46967. * Specifies wether or not tonemapping should be enabled in the scene.
  46968. * true by default if setupImageProcessing is true.
  46969. */
  46970. toneMappingEnabled: boolean;
  46971. }
  46972. /**
  46973. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46974. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46975. * It also helps with the default setup of your imageProcessing configuration.
  46976. */
  46977. export class EnvironmentHelper {
  46978. /**
  46979. * Default ground texture URL.
  46980. */
  46981. private static _groundTextureCDNUrl;
  46982. /**
  46983. * Default skybox texture URL.
  46984. */
  46985. private static _skyboxTextureCDNUrl;
  46986. /**
  46987. * Default environment texture URL.
  46988. */
  46989. private static _environmentTextureCDNUrl;
  46990. /**
  46991. * Creates the default options for the helper.
  46992. */
  46993. private static _getDefaultOptions;
  46994. private _rootMesh;
  46995. /**
  46996. * Gets the root mesh created by the helper.
  46997. */
  46998. readonly rootMesh: Mesh;
  46999. private _skybox;
  47000. /**
  47001. * Gets the skybox created by the helper.
  47002. */
  47003. readonly skybox: Nullable<Mesh>;
  47004. private _skyboxTexture;
  47005. /**
  47006. * Gets the skybox texture created by the helper.
  47007. */
  47008. readonly skyboxTexture: Nullable<BaseTexture>;
  47009. private _skyboxMaterial;
  47010. /**
  47011. * Gets the skybox material created by the helper.
  47012. */
  47013. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47014. private _ground;
  47015. /**
  47016. * Gets the ground mesh created by the helper.
  47017. */
  47018. readonly ground: Nullable<Mesh>;
  47019. private _groundTexture;
  47020. /**
  47021. * Gets the ground texture created by the helper.
  47022. */
  47023. readonly groundTexture: Nullable<BaseTexture>;
  47024. private _groundMirror;
  47025. /**
  47026. * Gets the ground mirror created by the helper.
  47027. */
  47028. readonly groundMirror: Nullable<MirrorTexture>;
  47029. /**
  47030. * Gets the ground mirror render list to helps pushing the meshes
  47031. * you wish in the ground reflection.
  47032. */
  47033. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47034. private _groundMaterial;
  47035. /**
  47036. * Gets the ground material created by the helper.
  47037. */
  47038. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47039. /**
  47040. * Stores the creation options.
  47041. */
  47042. private readonly _scene;
  47043. private _options;
  47044. /**
  47045. * This observable will be notified with any error during the creation of the environment,
  47046. * mainly texture creation errors.
  47047. */
  47048. onErrorObservable: Observable<{
  47049. message?: string;
  47050. exception?: any;
  47051. }>;
  47052. /**
  47053. * constructor
  47054. * @param options Defines the options we want to customize the helper
  47055. * @param scene The scene to add the material to
  47056. */
  47057. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47058. /**
  47059. * Updates the background according to the new options
  47060. * @param options
  47061. */
  47062. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47063. /**
  47064. * Sets the primary color of all the available elements.
  47065. * @param color the main color to affect to the ground and the background
  47066. */
  47067. setMainColor(color: Color3): void;
  47068. /**
  47069. * Setup the image processing according to the specified options.
  47070. */
  47071. private _setupImageProcessing;
  47072. /**
  47073. * Setup the environment texture according to the specified options.
  47074. */
  47075. private _setupEnvironmentTexture;
  47076. /**
  47077. * Setup the background according to the specified options.
  47078. */
  47079. private _setupBackground;
  47080. /**
  47081. * Get the scene sizes according to the setup.
  47082. */
  47083. private _getSceneSize;
  47084. /**
  47085. * Setup the ground according to the specified options.
  47086. */
  47087. private _setupGround;
  47088. /**
  47089. * Setup the ground material according to the specified options.
  47090. */
  47091. private _setupGroundMaterial;
  47092. /**
  47093. * Setup the ground diffuse texture according to the specified options.
  47094. */
  47095. private _setupGroundDiffuseTexture;
  47096. /**
  47097. * Setup the ground mirror texture according to the specified options.
  47098. */
  47099. private _setupGroundMirrorTexture;
  47100. /**
  47101. * Setup the ground to receive the mirror texture.
  47102. */
  47103. private _setupMirrorInGroundMaterial;
  47104. /**
  47105. * Setup the skybox according to the specified options.
  47106. */
  47107. private _setupSkybox;
  47108. /**
  47109. * Setup the skybox material according to the specified options.
  47110. */
  47111. private _setupSkyboxMaterial;
  47112. /**
  47113. * Setup the skybox reflection texture according to the specified options.
  47114. */
  47115. private _setupSkyboxReflectionTexture;
  47116. private _errorHandler;
  47117. /**
  47118. * Dispose all the elements created by the Helper.
  47119. */
  47120. dispose(): void;
  47121. }
  47122. }
  47123. declare module "babylonjs/Helpers/photoDome" {
  47124. import { Observable } from "babylonjs/Misc/observable";
  47125. import { Nullable } from "babylonjs/types";
  47126. import { Scene } from "babylonjs/scene";
  47127. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47128. import { Mesh } from "babylonjs/Meshes/mesh";
  47129. import { Texture } from "babylonjs/Materials/Textures/texture";
  47130. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47131. import "babylonjs/Meshes/Builders/sphereBuilder";
  47132. /**
  47133. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47134. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47135. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47136. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47137. */
  47138. export class PhotoDome extends TransformNode {
  47139. /**
  47140. * Define the image as a Monoscopic panoramic 360 image.
  47141. */
  47142. static readonly MODE_MONOSCOPIC: number;
  47143. /**
  47144. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47145. */
  47146. static readonly MODE_TOPBOTTOM: number;
  47147. /**
  47148. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47149. */
  47150. static readonly MODE_SIDEBYSIDE: number;
  47151. private _useDirectMapping;
  47152. /**
  47153. * The texture being displayed on the sphere
  47154. */
  47155. protected _photoTexture: Texture;
  47156. /**
  47157. * Gets or sets the texture being displayed on the sphere
  47158. */
  47159. photoTexture: Texture;
  47160. /**
  47161. * Observable raised when an error occured while loading the 360 image
  47162. */
  47163. onLoadErrorObservable: Observable<string>;
  47164. /**
  47165. * The skybox material
  47166. */
  47167. protected _material: BackgroundMaterial;
  47168. /**
  47169. * The surface used for the skybox
  47170. */
  47171. protected _mesh: Mesh;
  47172. /**
  47173. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47174. * Also see the options.resolution property.
  47175. */
  47176. fovMultiplier: number;
  47177. private _imageMode;
  47178. /**
  47179. * Gets or set the current video mode for the video. It can be:
  47180. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47181. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47182. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47183. */
  47184. imageMode: number;
  47185. /**
  47186. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47187. * @param name Element's name, child elements will append suffixes for their own names.
  47188. * @param urlsOfPhoto defines the url of the photo to display
  47189. * @param options defines an object containing optional or exposed sub element properties
  47190. * @param onError defines a callback called when an error occured while loading the texture
  47191. */
  47192. constructor(name: string, urlOfPhoto: string, options: {
  47193. resolution?: number;
  47194. size?: number;
  47195. useDirectMapping?: boolean;
  47196. faceForward?: boolean;
  47197. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47198. private _onBeforeCameraRenderObserver;
  47199. private _changeImageMode;
  47200. /**
  47201. * Releases resources associated with this node.
  47202. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47203. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47204. */
  47205. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47206. }
  47207. }
  47208. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47209. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47210. /** @hidden */
  47211. export var rgbdDecodePixelShader: {
  47212. name: string;
  47213. shader: string;
  47214. };
  47215. }
  47216. declare module "babylonjs/Misc/brdfTextureTools" {
  47217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47218. import { Scene } from "babylonjs/scene";
  47219. import "babylonjs/Shaders/rgbdDecode.fragment";
  47220. /**
  47221. * Class used to host texture specific utilities
  47222. */
  47223. export class BRDFTextureTools {
  47224. /**
  47225. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47226. * @param texture the texture to expand.
  47227. */
  47228. private static _ExpandDefaultBRDFTexture;
  47229. /**
  47230. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47231. * @param scene defines the hosting scene
  47232. * @returns the environment BRDF texture
  47233. */
  47234. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47235. private static _environmentBRDFBase64Texture;
  47236. }
  47237. }
  47238. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47239. import { Nullable } from "babylonjs/types";
  47240. import { Color3 } from "babylonjs/Maths/math.color";
  47241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47242. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47243. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47245. import { Engine } from "babylonjs/Engines/engine";
  47246. import { Scene } from "babylonjs/scene";
  47247. /**
  47248. * @hidden
  47249. */
  47250. export interface IMaterialClearCoatDefines {
  47251. CLEARCOAT: boolean;
  47252. CLEARCOAT_DEFAULTIOR: boolean;
  47253. CLEARCOAT_TEXTURE: boolean;
  47254. CLEARCOAT_TEXTUREDIRECTUV: number;
  47255. CLEARCOAT_BUMP: boolean;
  47256. CLEARCOAT_BUMPDIRECTUV: number;
  47257. CLEARCOAT_TINT: boolean;
  47258. CLEARCOAT_TINT_TEXTURE: boolean;
  47259. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47260. /** @hidden */
  47261. _areTexturesDirty: boolean;
  47262. }
  47263. /**
  47264. * Define the code related to the clear coat parameters of the pbr material.
  47265. */
  47266. export class PBRClearCoatConfiguration {
  47267. /**
  47268. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47269. * The default fits with a polyurethane material.
  47270. */
  47271. private static readonly _DefaultIndexOfRefraction;
  47272. private _isEnabled;
  47273. /**
  47274. * Defines if the clear coat is enabled in the material.
  47275. */
  47276. isEnabled: boolean;
  47277. /**
  47278. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47279. */
  47280. intensity: number;
  47281. /**
  47282. * Defines the clear coat layer roughness.
  47283. */
  47284. roughness: number;
  47285. private _indexOfRefraction;
  47286. /**
  47287. * Defines the index of refraction of the clear coat.
  47288. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47289. * The default fits with a polyurethane material.
  47290. * Changing the default value is more performance intensive.
  47291. */
  47292. indexOfRefraction: number;
  47293. private _texture;
  47294. /**
  47295. * Stores the clear coat values in a texture.
  47296. */
  47297. texture: Nullable<BaseTexture>;
  47298. private _bumpTexture;
  47299. /**
  47300. * Define the clear coat specific bump texture.
  47301. */
  47302. bumpTexture: Nullable<BaseTexture>;
  47303. private _isTintEnabled;
  47304. /**
  47305. * Defines if the clear coat tint is enabled in the material.
  47306. */
  47307. isTintEnabled: boolean;
  47308. /**
  47309. * Defines the clear coat tint of the material.
  47310. * This is only use if tint is enabled
  47311. */
  47312. tintColor: Color3;
  47313. /**
  47314. * Defines the distance at which the tint color should be found in the
  47315. * clear coat media.
  47316. * This is only use if tint is enabled
  47317. */
  47318. tintColorAtDistance: number;
  47319. /**
  47320. * Defines the clear coat layer thickness.
  47321. * This is only use if tint is enabled
  47322. */
  47323. tintThickness: number;
  47324. private _tintTexture;
  47325. /**
  47326. * Stores the clear tint values in a texture.
  47327. * rgb is tint
  47328. * a is a thickness factor
  47329. */
  47330. tintTexture: Nullable<BaseTexture>;
  47331. /** @hidden */
  47332. private _internalMarkAllSubMeshesAsTexturesDirty;
  47333. /** @hidden */
  47334. _markAllSubMeshesAsTexturesDirty(): void;
  47335. /**
  47336. * Instantiate a new istance of clear coat configuration.
  47337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47338. */
  47339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47340. /**
  47341. * Gets wehter the submesh is ready to be used or not.
  47342. * @param defines the list of "defines" to update.
  47343. * @param scene defines the scene the material belongs to.
  47344. * @param engine defines the engine the material belongs to.
  47345. * @param disableBumpMap defines wether the material disables bump or not.
  47346. * @returns - boolean indicating that the submesh is ready or not.
  47347. */
  47348. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47349. /**
  47350. * Checks to see if a texture is used in the material.
  47351. * @param defines the list of "defines" to update.
  47352. * @param scene defines the scene to the material belongs to.
  47353. */
  47354. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47355. /**
  47356. * Binds the material data.
  47357. * @param uniformBuffer defines the Uniform buffer to fill in.
  47358. * @param scene defines the scene the material belongs to.
  47359. * @param engine defines the engine the material belongs to.
  47360. * @param disableBumpMap defines wether the material disables bump or not.
  47361. * @param isFrozen defines wether the material is frozen or not.
  47362. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47363. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47364. */
  47365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47366. /**
  47367. * Checks to see if a texture is used in the material.
  47368. * @param texture - Base texture to use.
  47369. * @returns - Boolean specifying if a texture is used in the material.
  47370. */
  47371. hasTexture(texture: BaseTexture): boolean;
  47372. /**
  47373. * Returns an array of the actively used textures.
  47374. * @param activeTextures Array of BaseTextures
  47375. */
  47376. getActiveTextures(activeTextures: BaseTexture[]): void;
  47377. /**
  47378. * Returns the animatable textures.
  47379. * @param animatables Array of animatable textures.
  47380. */
  47381. getAnimatables(animatables: IAnimatable[]): void;
  47382. /**
  47383. * Disposes the resources of the material.
  47384. * @param forceDisposeTextures - Forces the disposal of all textures.
  47385. */
  47386. dispose(forceDisposeTextures?: boolean): void;
  47387. /**
  47388. * Get the current class name of the texture useful for serialization or dynamic coding.
  47389. * @returns "PBRClearCoatConfiguration"
  47390. */
  47391. getClassName(): string;
  47392. /**
  47393. * Add fallbacks to the effect fallbacks list.
  47394. * @param defines defines the Base texture to use.
  47395. * @param fallbacks defines the current fallback list.
  47396. * @param currentRank defines the current fallback rank.
  47397. * @returns the new fallback rank.
  47398. */
  47399. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47400. /**
  47401. * Add the required uniforms to the current list.
  47402. * @param uniforms defines the current uniform list.
  47403. */
  47404. static AddUniforms(uniforms: string[]): void;
  47405. /**
  47406. * Add the required samplers to the current list.
  47407. * @param samplers defines the current sampler list.
  47408. */
  47409. static AddSamplers(samplers: string[]): void;
  47410. /**
  47411. * Add the required uniforms to the current buffer.
  47412. * @param uniformBuffer defines the current uniform buffer.
  47413. */
  47414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47415. /**
  47416. * Makes a duplicate of the current configuration into another one.
  47417. * @param clearCoatConfiguration define the config where to copy the info
  47418. */
  47419. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47420. /**
  47421. * Serializes this clear coat configuration.
  47422. * @returns - An object with the serialized config.
  47423. */
  47424. serialize(): any;
  47425. /**
  47426. * Parses a anisotropy Configuration from a serialized object.
  47427. * @param source - Serialized object.
  47428. * @param scene Defines the scene we are parsing for
  47429. * @param rootUrl Defines the rootUrl to load from
  47430. */
  47431. parse(source: any, scene: Scene, rootUrl: string): void;
  47432. }
  47433. }
  47434. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47435. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47436. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47438. import { Vector2 } from "babylonjs/Maths/math.vector";
  47439. import { Scene } from "babylonjs/scene";
  47440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47441. import { Nullable } from "babylonjs/types";
  47442. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47443. /**
  47444. * @hidden
  47445. */
  47446. export interface IMaterialAnisotropicDefines {
  47447. ANISOTROPIC: boolean;
  47448. ANISOTROPIC_TEXTURE: boolean;
  47449. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47450. MAINUV1: boolean;
  47451. _areTexturesDirty: boolean;
  47452. _needUVs: boolean;
  47453. }
  47454. /**
  47455. * Define the code related to the anisotropic parameters of the pbr material.
  47456. */
  47457. export class PBRAnisotropicConfiguration {
  47458. private _isEnabled;
  47459. /**
  47460. * Defines if the anisotropy is enabled in the material.
  47461. */
  47462. isEnabled: boolean;
  47463. /**
  47464. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47465. */
  47466. intensity: number;
  47467. /**
  47468. * Defines if the effect is along the tangents, bitangents or in between.
  47469. * By default, the effect is "strectching" the highlights along the tangents.
  47470. */
  47471. direction: Vector2;
  47472. private _texture;
  47473. /**
  47474. * Stores the anisotropy values in a texture.
  47475. * rg is direction (like normal from -1 to 1)
  47476. * b is a intensity
  47477. */
  47478. texture: Nullable<BaseTexture>;
  47479. /** @hidden */
  47480. private _internalMarkAllSubMeshesAsTexturesDirty;
  47481. /** @hidden */
  47482. _markAllSubMeshesAsTexturesDirty(): void;
  47483. /**
  47484. * Instantiate a new istance of anisotropy configuration.
  47485. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47486. */
  47487. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47488. /**
  47489. * Specifies that the submesh is ready to be used.
  47490. * @param defines the list of "defines" to update.
  47491. * @param scene defines the scene the material belongs to.
  47492. * @returns - boolean indicating that the submesh is ready or not.
  47493. */
  47494. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47495. /**
  47496. * Checks to see if a texture is used in the material.
  47497. * @param defines the list of "defines" to update.
  47498. * @param mesh the mesh we are preparing the defines for.
  47499. * @param scene defines the scene the material belongs to.
  47500. */
  47501. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47502. /**
  47503. * Binds the material data.
  47504. * @param uniformBuffer defines the Uniform buffer to fill in.
  47505. * @param scene defines the scene the material belongs to.
  47506. * @param isFrozen defines wether the material is frozen or not.
  47507. */
  47508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47509. /**
  47510. * Checks to see if a texture is used in the material.
  47511. * @param texture - Base texture to use.
  47512. * @returns - Boolean specifying if a texture is used in the material.
  47513. */
  47514. hasTexture(texture: BaseTexture): boolean;
  47515. /**
  47516. * Returns an array of the actively used textures.
  47517. * @param activeTextures Array of BaseTextures
  47518. */
  47519. getActiveTextures(activeTextures: BaseTexture[]): void;
  47520. /**
  47521. * Returns the animatable textures.
  47522. * @param animatables Array of animatable textures.
  47523. */
  47524. getAnimatables(animatables: IAnimatable[]): void;
  47525. /**
  47526. * Disposes the resources of the material.
  47527. * @param forceDisposeTextures - Forces the disposal of all textures.
  47528. */
  47529. dispose(forceDisposeTextures?: boolean): void;
  47530. /**
  47531. * Get the current class name of the texture useful for serialization or dynamic coding.
  47532. * @returns "PBRAnisotropicConfiguration"
  47533. */
  47534. getClassName(): string;
  47535. /**
  47536. * Add fallbacks to the effect fallbacks list.
  47537. * @param defines defines the Base texture to use.
  47538. * @param fallbacks defines the current fallback list.
  47539. * @param currentRank defines the current fallback rank.
  47540. * @returns the new fallback rank.
  47541. */
  47542. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47543. /**
  47544. * Add the required uniforms to the current list.
  47545. * @param uniforms defines the current uniform list.
  47546. */
  47547. static AddUniforms(uniforms: string[]): void;
  47548. /**
  47549. * Add the required uniforms to the current buffer.
  47550. * @param uniformBuffer defines the current uniform buffer.
  47551. */
  47552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47553. /**
  47554. * Add the required samplers to the current list.
  47555. * @param samplers defines the current sampler list.
  47556. */
  47557. static AddSamplers(samplers: string[]): void;
  47558. /**
  47559. * Makes a duplicate of the current configuration into another one.
  47560. * @param anisotropicConfiguration define the config where to copy the info
  47561. */
  47562. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47563. /**
  47564. * Serializes this anisotropy configuration.
  47565. * @returns - An object with the serialized config.
  47566. */
  47567. serialize(): any;
  47568. /**
  47569. * Parses a anisotropy Configuration from a serialized object.
  47570. * @param source - Serialized object.
  47571. * @param scene Defines the scene we are parsing for
  47572. * @param rootUrl Defines the rootUrl to load from
  47573. */
  47574. parse(source: any, scene: Scene, rootUrl: string): void;
  47575. }
  47576. }
  47577. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47578. import { Scene } from "babylonjs/scene";
  47579. /**
  47580. * @hidden
  47581. */
  47582. export interface IMaterialBRDFDefines {
  47583. BRDF_V_HEIGHT_CORRELATED: boolean;
  47584. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47585. SPHERICAL_HARMONICS: boolean;
  47586. /** @hidden */
  47587. _areMiscDirty: boolean;
  47588. }
  47589. /**
  47590. * Define the code related to the BRDF parameters of the pbr material.
  47591. */
  47592. export class PBRBRDFConfiguration {
  47593. /**
  47594. * Default value used for the energy conservation.
  47595. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47596. */
  47597. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47598. /**
  47599. * Default value used for the Smith Visibility Height Correlated mode.
  47600. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47601. */
  47602. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47603. /**
  47604. * Default value used for the IBL diffuse part.
  47605. * This can help switching back to the polynomials mode globally which is a tiny bit
  47606. * less GPU intensive at the drawback of a lower quality.
  47607. */
  47608. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47609. private _useEnergyConservation;
  47610. /**
  47611. * Defines if the material uses energy conservation.
  47612. */
  47613. useEnergyConservation: boolean;
  47614. private _useSmithVisibilityHeightCorrelated;
  47615. /**
  47616. * LEGACY Mode set to false
  47617. * Defines if the material uses height smith correlated visibility term.
  47618. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47619. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47620. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47621. * Not relying on height correlated will also disable energy conservation.
  47622. */
  47623. useSmithVisibilityHeightCorrelated: boolean;
  47624. private _useSphericalHarmonics;
  47625. /**
  47626. * LEGACY Mode set to false
  47627. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47628. * diffuse part of the IBL.
  47629. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47630. * to the ground truth.
  47631. */
  47632. useSphericalHarmonics: boolean;
  47633. /** @hidden */
  47634. private _internalMarkAllSubMeshesAsMiscDirty;
  47635. /** @hidden */
  47636. _markAllSubMeshesAsMiscDirty(): void;
  47637. /**
  47638. * Instantiate a new istance of clear coat configuration.
  47639. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47640. */
  47641. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47642. /**
  47643. * Checks to see if a texture is used in the material.
  47644. * @param defines the list of "defines" to update.
  47645. */
  47646. prepareDefines(defines: IMaterialBRDFDefines): void;
  47647. /**
  47648. * Get the current class name of the texture useful for serialization or dynamic coding.
  47649. * @returns "PBRClearCoatConfiguration"
  47650. */
  47651. getClassName(): string;
  47652. /**
  47653. * Makes a duplicate of the current configuration into another one.
  47654. * @param brdfConfiguration define the config where to copy the info
  47655. */
  47656. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47657. /**
  47658. * Serializes this BRDF configuration.
  47659. * @returns - An object with the serialized config.
  47660. */
  47661. serialize(): any;
  47662. /**
  47663. * Parses a anisotropy Configuration from a serialized object.
  47664. * @param source - Serialized object.
  47665. * @param scene Defines the scene we are parsing for
  47666. * @param rootUrl Defines the rootUrl to load from
  47667. */
  47668. parse(source: any, scene: Scene, rootUrl: string): void;
  47669. }
  47670. }
  47671. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47672. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47673. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47674. import { Color3 } from "babylonjs/Maths/math.color";
  47675. import { Scene } from "babylonjs/scene";
  47676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47677. import { Nullable } from "babylonjs/types";
  47678. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47679. /**
  47680. * @hidden
  47681. */
  47682. export interface IMaterialSheenDefines {
  47683. SHEEN: boolean;
  47684. SHEEN_TEXTURE: boolean;
  47685. SHEEN_TEXTUREDIRECTUV: number;
  47686. SHEEN_LINKWITHALBEDO: boolean;
  47687. /** @hidden */
  47688. _areTexturesDirty: boolean;
  47689. }
  47690. /**
  47691. * Define the code related to the Sheen parameters of the pbr material.
  47692. */
  47693. export class PBRSheenConfiguration {
  47694. private _isEnabled;
  47695. /**
  47696. * Defines if the material uses sheen.
  47697. */
  47698. isEnabled: boolean;
  47699. private _linkSheenWithAlbedo;
  47700. /**
  47701. * Defines if the sheen is linked to the sheen color.
  47702. */
  47703. linkSheenWithAlbedo: boolean;
  47704. /**
  47705. * Defines the sheen intensity.
  47706. */
  47707. intensity: number;
  47708. /**
  47709. * Defines the sheen color.
  47710. */
  47711. color: Color3;
  47712. private _texture;
  47713. /**
  47714. * Stores the sheen tint values in a texture.
  47715. * rgb is tint
  47716. * a is a intensity
  47717. */
  47718. texture: Nullable<BaseTexture>;
  47719. /** @hidden */
  47720. private _internalMarkAllSubMeshesAsTexturesDirty;
  47721. /** @hidden */
  47722. _markAllSubMeshesAsTexturesDirty(): void;
  47723. /**
  47724. * Instantiate a new istance of clear coat configuration.
  47725. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47726. */
  47727. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47728. /**
  47729. * Specifies that the submesh is ready to be used.
  47730. * @param defines the list of "defines" to update.
  47731. * @param scene defines the scene the material belongs to.
  47732. * @returns - boolean indicating that the submesh is ready or not.
  47733. */
  47734. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47735. /**
  47736. * Checks to see if a texture is used in the material.
  47737. * @param defines the list of "defines" to update.
  47738. * @param scene defines the scene the material belongs to.
  47739. */
  47740. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47741. /**
  47742. * Binds the material data.
  47743. * @param uniformBuffer defines the Uniform buffer to fill in.
  47744. * @param scene defines the scene the material belongs to.
  47745. * @param isFrozen defines wether the material is frozen or not.
  47746. */
  47747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47748. /**
  47749. * Checks to see if a texture is used in the material.
  47750. * @param texture - Base texture to use.
  47751. * @returns - Boolean specifying if a texture is used in the material.
  47752. */
  47753. hasTexture(texture: BaseTexture): boolean;
  47754. /**
  47755. * Returns an array of the actively used textures.
  47756. * @param activeTextures Array of BaseTextures
  47757. */
  47758. getActiveTextures(activeTextures: BaseTexture[]): void;
  47759. /**
  47760. * Returns the animatable textures.
  47761. * @param animatables Array of animatable textures.
  47762. */
  47763. getAnimatables(animatables: IAnimatable[]): void;
  47764. /**
  47765. * Disposes the resources of the material.
  47766. * @param forceDisposeTextures - Forces the disposal of all textures.
  47767. */
  47768. dispose(forceDisposeTextures?: boolean): void;
  47769. /**
  47770. * Get the current class name of the texture useful for serialization or dynamic coding.
  47771. * @returns "PBRSheenConfiguration"
  47772. */
  47773. getClassName(): string;
  47774. /**
  47775. * Add fallbacks to the effect fallbacks list.
  47776. * @param defines defines the Base texture to use.
  47777. * @param fallbacks defines the current fallback list.
  47778. * @param currentRank defines the current fallback rank.
  47779. * @returns the new fallback rank.
  47780. */
  47781. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47782. /**
  47783. * Add the required uniforms to the current list.
  47784. * @param uniforms defines the current uniform list.
  47785. */
  47786. static AddUniforms(uniforms: string[]): void;
  47787. /**
  47788. * Add the required uniforms to the current buffer.
  47789. * @param uniformBuffer defines the current uniform buffer.
  47790. */
  47791. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47792. /**
  47793. * Add the required samplers to the current list.
  47794. * @param samplers defines the current sampler list.
  47795. */
  47796. static AddSamplers(samplers: string[]): void;
  47797. /**
  47798. * Makes a duplicate of the current configuration into another one.
  47799. * @param sheenConfiguration define the config where to copy the info
  47800. */
  47801. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47802. /**
  47803. * Serializes this BRDF configuration.
  47804. * @returns - An object with the serialized config.
  47805. */
  47806. serialize(): any;
  47807. /**
  47808. * Parses a anisotropy Configuration from a serialized object.
  47809. * @param source - Serialized object.
  47810. * @param scene Defines the scene we are parsing for
  47811. * @param rootUrl Defines the rootUrl to load from
  47812. */
  47813. parse(source: any, scene: Scene, rootUrl: string): void;
  47814. }
  47815. }
  47816. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47817. import { Nullable } from "babylonjs/types";
  47818. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47819. import { Color3 } from "babylonjs/Maths/math.color";
  47820. import { SmartArray } from "babylonjs/Misc/smartArray";
  47821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47822. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47823. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47824. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47825. import { Engine } from "babylonjs/Engines/engine";
  47826. import { Scene } from "babylonjs/scene";
  47827. /**
  47828. * @hidden
  47829. */
  47830. export interface IMaterialSubSurfaceDefines {
  47831. SUBSURFACE: boolean;
  47832. SS_REFRACTION: boolean;
  47833. SS_TRANSLUCENCY: boolean;
  47834. SS_SCATERRING: boolean;
  47835. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47836. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47837. SS_REFRACTIONMAP_3D: boolean;
  47838. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47839. SS_LODINREFRACTIONALPHA: boolean;
  47840. SS_GAMMAREFRACTION: boolean;
  47841. SS_RGBDREFRACTION: boolean;
  47842. SS_LINEARSPECULARREFRACTION: boolean;
  47843. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47844. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47845. /** @hidden */
  47846. _areTexturesDirty: boolean;
  47847. }
  47848. /**
  47849. * Define the code related to the sub surface parameters of the pbr material.
  47850. */
  47851. export class PBRSubSurfaceConfiguration {
  47852. private _isRefractionEnabled;
  47853. /**
  47854. * Defines if the refraction is enabled in the material.
  47855. */
  47856. isRefractionEnabled: boolean;
  47857. private _isTranslucencyEnabled;
  47858. /**
  47859. * Defines if the translucency is enabled in the material.
  47860. */
  47861. isTranslucencyEnabled: boolean;
  47862. private _isScatteringEnabled;
  47863. /**
  47864. * Defines the refraction intensity of the material.
  47865. * The refraction when enabled replaces the Diffuse part of the material.
  47866. * The intensity helps transitionning between diffuse and refraction.
  47867. */
  47868. refractionIntensity: number;
  47869. /**
  47870. * Defines the translucency intensity of the material.
  47871. * When translucency has been enabled, this defines how much of the "translucency"
  47872. * is addded to the diffuse part of the material.
  47873. */
  47874. translucencyIntensity: number;
  47875. /**
  47876. * Defines the scattering intensity of the material.
  47877. * When scattering has been enabled, this defines how much of the "scattered light"
  47878. * is addded to the diffuse part of the material.
  47879. */
  47880. scatteringIntensity: number;
  47881. private _thicknessTexture;
  47882. /**
  47883. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47884. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47885. * 0 would mean minimumThickness
  47886. * 1 would mean maximumThickness
  47887. * The other channels might be use as a mask to vary the different effects intensity.
  47888. */
  47889. thicknessTexture: Nullable<BaseTexture>;
  47890. private _refractionTexture;
  47891. /**
  47892. * Defines the texture to use for refraction.
  47893. */
  47894. refractionTexture: Nullable<BaseTexture>;
  47895. private _indexOfRefraction;
  47896. /**
  47897. * Defines the index of refraction used in the material.
  47898. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47899. */
  47900. indexOfRefraction: number;
  47901. private _invertRefractionY;
  47902. /**
  47903. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47904. */
  47905. invertRefractionY: boolean;
  47906. private _linkRefractionWithTransparency;
  47907. /**
  47908. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47909. * Materials half opaque for instance using refraction could benefit from this control.
  47910. */
  47911. linkRefractionWithTransparency: boolean;
  47912. /**
  47913. * Defines the minimum thickness stored in the thickness map.
  47914. * If no thickness map is defined, this value will be used to simulate thickness.
  47915. */
  47916. minimumThickness: number;
  47917. /**
  47918. * Defines the maximum thickness stored in the thickness map.
  47919. */
  47920. maximumThickness: number;
  47921. /**
  47922. * Defines the volume tint of the material.
  47923. * This is used for both translucency and scattering.
  47924. */
  47925. tintColor: Color3;
  47926. /**
  47927. * Defines the distance at which the tint color should be found in the media.
  47928. * This is used for refraction only.
  47929. */
  47930. tintColorAtDistance: number;
  47931. /**
  47932. * Defines how far each channel transmit through the media.
  47933. * It is defined as a color to simplify it selection.
  47934. */
  47935. diffusionDistance: Color3;
  47936. private _useMaskFromThicknessTexture;
  47937. /**
  47938. * Stores the intensity of the different subsurface effects in the thickness texture.
  47939. * * the green channel is the translucency intensity.
  47940. * * the blue channel is the scattering intensity.
  47941. * * the alpha channel is the refraction intensity.
  47942. */
  47943. useMaskFromThicknessTexture: boolean;
  47944. /** @hidden */
  47945. private _internalMarkAllSubMeshesAsTexturesDirty;
  47946. /** @hidden */
  47947. _markAllSubMeshesAsTexturesDirty(): void;
  47948. /**
  47949. * Instantiate a new istance of sub surface configuration.
  47950. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47951. */
  47952. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47953. /**
  47954. * Gets wehter the submesh is ready to be used or not.
  47955. * @param defines the list of "defines" to update.
  47956. * @param scene defines the scene the material belongs to.
  47957. * @returns - boolean indicating that the submesh is ready or not.
  47958. */
  47959. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47960. /**
  47961. * Checks to see if a texture is used in the material.
  47962. * @param defines the list of "defines" to update.
  47963. * @param scene defines the scene to the material belongs to.
  47964. */
  47965. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47966. /**
  47967. * Binds the material data.
  47968. * @param uniformBuffer defines the Uniform buffer to fill in.
  47969. * @param scene defines the scene the material belongs to.
  47970. * @param engine defines the engine the material belongs to.
  47971. * @param isFrozen defines wether the material is frozen or not.
  47972. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47973. */
  47974. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47975. /**
  47976. * Unbinds the material from the mesh.
  47977. * @param activeEffect defines the effect that should be unbound from.
  47978. * @returns true if unbound, otherwise false
  47979. */
  47980. unbind(activeEffect: Effect): boolean;
  47981. /**
  47982. * Returns the texture used for refraction or null if none is used.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @returns - Refraction texture if present. If no refraction texture and refraction
  47985. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47986. */
  47987. private _getRefractionTexture;
  47988. /**
  47989. * Returns true if alpha blending should be disabled.
  47990. */
  47991. readonly disableAlphaBlending: boolean;
  47992. /**
  47993. * Fills the list of render target textures.
  47994. * @param renderTargets the list of render targets to update
  47995. */
  47996. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47997. /**
  47998. * Checks to see if a texture is used in the material.
  47999. * @param texture - Base texture to use.
  48000. * @returns - Boolean specifying if a texture is used in the material.
  48001. */
  48002. hasTexture(texture: BaseTexture): boolean;
  48003. /**
  48004. * Gets a boolean indicating that current material needs to register RTT
  48005. * @returns true if this uses a render target otherwise false.
  48006. */
  48007. hasRenderTargetTextures(): boolean;
  48008. /**
  48009. * Returns an array of the actively used textures.
  48010. * @param activeTextures Array of BaseTextures
  48011. */
  48012. getActiveTextures(activeTextures: BaseTexture[]): void;
  48013. /**
  48014. * Returns the animatable textures.
  48015. * @param animatables Array of animatable textures.
  48016. */
  48017. getAnimatables(animatables: IAnimatable[]): void;
  48018. /**
  48019. * Disposes the resources of the material.
  48020. * @param forceDisposeTextures - Forces the disposal of all textures.
  48021. */
  48022. dispose(forceDisposeTextures?: boolean): void;
  48023. /**
  48024. * Get the current class name of the texture useful for serialization or dynamic coding.
  48025. * @returns "PBRSubSurfaceConfiguration"
  48026. */
  48027. getClassName(): string;
  48028. /**
  48029. * Add fallbacks to the effect fallbacks list.
  48030. * @param defines defines the Base texture to use.
  48031. * @param fallbacks defines the current fallback list.
  48032. * @param currentRank defines the current fallback rank.
  48033. * @returns the new fallback rank.
  48034. */
  48035. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48036. /**
  48037. * Add the required uniforms to the current list.
  48038. * @param uniforms defines the current uniform list.
  48039. */
  48040. static AddUniforms(uniforms: string[]): void;
  48041. /**
  48042. * Add the required samplers to the current list.
  48043. * @param samplers defines the current sampler list.
  48044. */
  48045. static AddSamplers(samplers: string[]): void;
  48046. /**
  48047. * Add the required uniforms to the current buffer.
  48048. * @param uniformBuffer defines the current uniform buffer.
  48049. */
  48050. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48051. /**
  48052. * Makes a duplicate of the current configuration into another one.
  48053. * @param configuration define the config where to copy the info
  48054. */
  48055. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48056. /**
  48057. * Serializes this Sub Surface configuration.
  48058. * @returns - An object with the serialized config.
  48059. */
  48060. serialize(): any;
  48061. /**
  48062. * Parses a anisotropy Configuration from a serialized object.
  48063. * @param source - Serialized object.
  48064. * @param scene Defines the scene we are parsing for
  48065. * @param rootUrl Defines the rootUrl to load from
  48066. */
  48067. parse(source: any, scene: Scene, rootUrl: string): void;
  48068. }
  48069. }
  48070. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48071. /** @hidden */
  48072. export var pbrFragmentDeclaration: {
  48073. name: string;
  48074. shader: string;
  48075. };
  48076. }
  48077. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48078. /** @hidden */
  48079. export var pbrUboDeclaration: {
  48080. name: string;
  48081. shader: string;
  48082. };
  48083. }
  48084. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48085. /** @hidden */
  48086. export var pbrFragmentExtraDeclaration: {
  48087. name: string;
  48088. shader: string;
  48089. };
  48090. }
  48091. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48092. /** @hidden */
  48093. export var pbrFragmentSamplersDeclaration: {
  48094. name: string;
  48095. shader: string;
  48096. };
  48097. }
  48098. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48099. /** @hidden */
  48100. export var pbrHelperFunctions: {
  48101. name: string;
  48102. shader: string;
  48103. };
  48104. }
  48105. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48106. /** @hidden */
  48107. export var harmonicsFunctions: {
  48108. name: string;
  48109. shader: string;
  48110. };
  48111. }
  48112. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48113. /** @hidden */
  48114. export var pbrDirectLightingSetupFunctions: {
  48115. name: string;
  48116. shader: string;
  48117. };
  48118. }
  48119. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48120. /** @hidden */
  48121. export var pbrDirectLightingFalloffFunctions: {
  48122. name: string;
  48123. shader: string;
  48124. };
  48125. }
  48126. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48127. /** @hidden */
  48128. export var pbrBRDFFunctions: {
  48129. name: string;
  48130. shader: string;
  48131. };
  48132. }
  48133. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48134. /** @hidden */
  48135. export var pbrDirectLightingFunctions: {
  48136. name: string;
  48137. shader: string;
  48138. };
  48139. }
  48140. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48141. /** @hidden */
  48142. export var pbrIBLFunctions: {
  48143. name: string;
  48144. shader: string;
  48145. };
  48146. }
  48147. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48148. /** @hidden */
  48149. export var pbrDebug: {
  48150. name: string;
  48151. shader: string;
  48152. };
  48153. }
  48154. declare module "babylonjs/Shaders/pbr.fragment" {
  48155. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48156. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48157. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48158. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48159. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48160. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48161. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48162. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48163. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48164. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48165. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48166. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48167. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48168. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48169. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48170. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48171. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48172. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48173. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48174. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48175. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48176. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48177. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48178. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48179. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48180. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48181. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48182. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48183. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48184. /** @hidden */
  48185. export var pbrPixelShader: {
  48186. name: string;
  48187. shader: string;
  48188. };
  48189. }
  48190. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48191. /** @hidden */
  48192. export var pbrVertexDeclaration: {
  48193. name: string;
  48194. shader: string;
  48195. };
  48196. }
  48197. declare module "babylonjs/Shaders/pbr.vertex" {
  48198. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48199. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48201. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48202. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48203. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48204. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48206. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48207. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48208. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48209. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48210. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48211. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48212. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48213. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48214. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48215. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48216. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48217. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48218. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48219. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48220. /** @hidden */
  48221. export var pbrVertexShader: {
  48222. name: string;
  48223. shader: string;
  48224. };
  48225. }
  48226. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48227. import { Nullable } from "babylonjs/types";
  48228. import { Scene } from "babylonjs/scene";
  48229. import { Matrix } from "babylonjs/Maths/math.vector";
  48230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48232. import { Mesh } from "babylonjs/Meshes/mesh";
  48233. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48234. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48235. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48236. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48237. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48238. import { Color3 } from "babylonjs/Maths/math.color";
  48239. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48240. import { Material } from "babylonjs/Materials/material";
  48241. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48242. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48245. import "babylonjs/Shaders/pbr.fragment";
  48246. import "babylonjs/Shaders/pbr.vertex";
  48247. /**
  48248. * Manages the defines for the PBR Material.
  48249. * @hidden
  48250. */
  48251. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48252. PBR: boolean;
  48253. MAINUV1: boolean;
  48254. MAINUV2: boolean;
  48255. UV1: boolean;
  48256. UV2: boolean;
  48257. ALBEDO: boolean;
  48258. ALBEDODIRECTUV: number;
  48259. VERTEXCOLOR: boolean;
  48260. AMBIENT: boolean;
  48261. AMBIENTDIRECTUV: number;
  48262. AMBIENTINGRAYSCALE: boolean;
  48263. OPACITY: boolean;
  48264. VERTEXALPHA: boolean;
  48265. OPACITYDIRECTUV: number;
  48266. OPACITYRGB: boolean;
  48267. ALPHATEST: boolean;
  48268. DEPTHPREPASS: boolean;
  48269. ALPHABLEND: boolean;
  48270. ALPHAFROMALBEDO: boolean;
  48271. ALPHATESTVALUE: string;
  48272. SPECULAROVERALPHA: boolean;
  48273. RADIANCEOVERALPHA: boolean;
  48274. ALPHAFRESNEL: boolean;
  48275. LINEARALPHAFRESNEL: boolean;
  48276. PREMULTIPLYALPHA: boolean;
  48277. EMISSIVE: boolean;
  48278. EMISSIVEDIRECTUV: number;
  48279. REFLECTIVITY: boolean;
  48280. REFLECTIVITYDIRECTUV: number;
  48281. SPECULARTERM: boolean;
  48282. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48283. MICROSURFACEAUTOMATIC: boolean;
  48284. LODBASEDMICROSFURACE: boolean;
  48285. MICROSURFACEMAP: boolean;
  48286. MICROSURFACEMAPDIRECTUV: number;
  48287. METALLICWORKFLOW: boolean;
  48288. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48289. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48290. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48291. AOSTOREINMETALMAPRED: boolean;
  48292. ENVIRONMENTBRDF: boolean;
  48293. ENVIRONMENTBRDF_RGBD: boolean;
  48294. NORMAL: boolean;
  48295. TANGENT: boolean;
  48296. BUMP: boolean;
  48297. BUMPDIRECTUV: number;
  48298. OBJECTSPACE_NORMALMAP: boolean;
  48299. PARALLAX: boolean;
  48300. PARALLAXOCCLUSION: boolean;
  48301. NORMALXYSCALE: boolean;
  48302. LIGHTMAP: boolean;
  48303. LIGHTMAPDIRECTUV: number;
  48304. USELIGHTMAPASSHADOWMAP: boolean;
  48305. GAMMALIGHTMAP: boolean;
  48306. REFLECTION: boolean;
  48307. REFLECTIONMAP_3D: boolean;
  48308. REFLECTIONMAP_SPHERICAL: boolean;
  48309. REFLECTIONMAP_PLANAR: boolean;
  48310. REFLECTIONMAP_CUBIC: boolean;
  48311. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48312. REFLECTIONMAP_PROJECTION: boolean;
  48313. REFLECTIONMAP_SKYBOX: boolean;
  48314. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48315. REFLECTIONMAP_EXPLICIT: boolean;
  48316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48319. INVERTCUBICMAP: boolean;
  48320. USESPHERICALFROMREFLECTIONMAP: boolean;
  48321. USEIRRADIANCEMAP: boolean;
  48322. SPHERICAL_HARMONICS: boolean;
  48323. USESPHERICALINVERTEX: boolean;
  48324. REFLECTIONMAP_OPPOSITEZ: boolean;
  48325. LODINREFLECTIONALPHA: boolean;
  48326. GAMMAREFLECTION: boolean;
  48327. RGBDREFLECTION: boolean;
  48328. LINEARSPECULARREFLECTION: boolean;
  48329. RADIANCEOCCLUSION: boolean;
  48330. HORIZONOCCLUSION: boolean;
  48331. INSTANCES: boolean;
  48332. NUM_BONE_INFLUENCERS: number;
  48333. BonesPerMesh: number;
  48334. BONETEXTURE: boolean;
  48335. NONUNIFORMSCALING: boolean;
  48336. MORPHTARGETS: boolean;
  48337. MORPHTARGETS_NORMAL: boolean;
  48338. MORPHTARGETS_TANGENT: boolean;
  48339. MORPHTARGETS_UV: boolean;
  48340. NUM_MORPH_INFLUENCERS: number;
  48341. IMAGEPROCESSING: boolean;
  48342. VIGNETTE: boolean;
  48343. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48344. VIGNETTEBLENDMODEOPAQUE: boolean;
  48345. TONEMAPPING: boolean;
  48346. TONEMAPPING_ACES: boolean;
  48347. CONTRAST: boolean;
  48348. COLORCURVES: boolean;
  48349. COLORGRADING: boolean;
  48350. COLORGRADING3D: boolean;
  48351. SAMPLER3DGREENDEPTH: boolean;
  48352. SAMPLER3DBGRMAP: boolean;
  48353. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48354. EXPOSURE: boolean;
  48355. MULTIVIEW: boolean;
  48356. USEPHYSICALLIGHTFALLOFF: boolean;
  48357. USEGLTFLIGHTFALLOFF: boolean;
  48358. TWOSIDEDLIGHTING: boolean;
  48359. SHADOWFLOAT: boolean;
  48360. CLIPPLANE: boolean;
  48361. CLIPPLANE2: boolean;
  48362. CLIPPLANE3: boolean;
  48363. CLIPPLANE4: boolean;
  48364. POINTSIZE: boolean;
  48365. FOG: boolean;
  48366. LOGARITHMICDEPTH: boolean;
  48367. FORCENORMALFORWARD: boolean;
  48368. SPECULARAA: boolean;
  48369. CLEARCOAT: boolean;
  48370. CLEARCOAT_DEFAULTIOR: boolean;
  48371. CLEARCOAT_TEXTURE: boolean;
  48372. CLEARCOAT_TEXTUREDIRECTUV: number;
  48373. CLEARCOAT_BUMP: boolean;
  48374. CLEARCOAT_BUMPDIRECTUV: number;
  48375. CLEARCOAT_TINT: boolean;
  48376. CLEARCOAT_TINT_TEXTURE: boolean;
  48377. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48378. ANISOTROPIC: boolean;
  48379. ANISOTROPIC_TEXTURE: boolean;
  48380. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48381. BRDF_V_HEIGHT_CORRELATED: boolean;
  48382. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48383. SHEEN: boolean;
  48384. SHEEN_TEXTURE: boolean;
  48385. SHEEN_TEXTUREDIRECTUV: number;
  48386. SHEEN_LINKWITHALBEDO: boolean;
  48387. SUBSURFACE: boolean;
  48388. SS_REFRACTION: boolean;
  48389. SS_TRANSLUCENCY: boolean;
  48390. SS_SCATERRING: boolean;
  48391. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48392. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48393. SS_REFRACTIONMAP_3D: boolean;
  48394. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48395. SS_LODINREFRACTIONALPHA: boolean;
  48396. SS_GAMMAREFRACTION: boolean;
  48397. SS_RGBDREFRACTION: boolean;
  48398. SS_LINEARSPECULARREFRACTION: boolean;
  48399. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48400. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48401. UNLIT: boolean;
  48402. DEBUGMODE: number;
  48403. /**
  48404. * Initializes the PBR Material defines.
  48405. */
  48406. constructor();
  48407. /**
  48408. * Resets the PBR Material defines.
  48409. */
  48410. reset(): void;
  48411. }
  48412. /**
  48413. * The Physically based material base class of BJS.
  48414. *
  48415. * This offers the main features of a standard PBR material.
  48416. * For more information, please refer to the documentation :
  48417. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48418. */
  48419. export abstract class PBRBaseMaterial extends PushMaterial {
  48420. /**
  48421. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48422. */
  48423. static readonly PBRMATERIAL_OPAQUE: number;
  48424. /**
  48425. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48426. */
  48427. static readonly PBRMATERIAL_ALPHATEST: number;
  48428. /**
  48429. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48430. */
  48431. static readonly PBRMATERIAL_ALPHABLEND: number;
  48432. /**
  48433. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48434. * They are also discarded below the alpha cutoff threshold to improve performances.
  48435. */
  48436. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48437. /**
  48438. * Defines the default value of how much AO map is occluding the analytical lights
  48439. * (point spot...).
  48440. */
  48441. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48442. /**
  48443. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48444. */
  48445. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48446. /**
  48447. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48448. * to enhance interoperability with other engines.
  48449. */
  48450. static readonly LIGHTFALLOFF_GLTF: number;
  48451. /**
  48452. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48453. * to enhance interoperability with other materials.
  48454. */
  48455. static readonly LIGHTFALLOFF_STANDARD: number;
  48456. /**
  48457. * Intensity of the direct lights e.g. the four lights available in your scene.
  48458. * This impacts both the direct diffuse and specular highlights.
  48459. */
  48460. protected _directIntensity: number;
  48461. /**
  48462. * Intensity of the emissive part of the material.
  48463. * This helps controlling the emissive effect without modifying the emissive color.
  48464. */
  48465. protected _emissiveIntensity: number;
  48466. /**
  48467. * Intensity of the environment e.g. how much the environment will light the object
  48468. * either through harmonics for rough material or through the refelction for shiny ones.
  48469. */
  48470. protected _environmentIntensity: number;
  48471. /**
  48472. * This is a special control allowing the reduction of the specular highlights coming from the
  48473. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48474. */
  48475. protected _specularIntensity: number;
  48476. /**
  48477. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48478. */
  48479. private _lightingInfos;
  48480. /**
  48481. * Debug Control allowing disabling the bump map on this material.
  48482. */
  48483. protected _disableBumpMap: boolean;
  48484. /**
  48485. * AKA Diffuse Texture in standard nomenclature.
  48486. */
  48487. protected _albedoTexture: Nullable<BaseTexture>;
  48488. /**
  48489. * AKA Occlusion Texture in other nomenclature.
  48490. */
  48491. protected _ambientTexture: Nullable<BaseTexture>;
  48492. /**
  48493. * AKA Occlusion Texture Intensity in other nomenclature.
  48494. */
  48495. protected _ambientTextureStrength: number;
  48496. /**
  48497. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48498. * 1 means it completely occludes it
  48499. * 0 mean it has no impact
  48500. */
  48501. protected _ambientTextureImpactOnAnalyticalLights: number;
  48502. /**
  48503. * Stores the alpha values in a texture.
  48504. */
  48505. protected _opacityTexture: Nullable<BaseTexture>;
  48506. /**
  48507. * Stores the reflection values in a texture.
  48508. */
  48509. protected _reflectionTexture: Nullable<BaseTexture>;
  48510. /**
  48511. * Stores the emissive values in a texture.
  48512. */
  48513. protected _emissiveTexture: Nullable<BaseTexture>;
  48514. /**
  48515. * AKA Specular texture in other nomenclature.
  48516. */
  48517. protected _reflectivityTexture: Nullable<BaseTexture>;
  48518. /**
  48519. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48520. */
  48521. protected _metallicTexture: Nullable<BaseTexture>;
  48522. /**
  48523. * Specifies the metallic scalar of the metallic/roughness workflow.
  48524. * Can also be used to scale the metalness values of the metallic texture.
  48525. */
  48526. protected _metallic: Nullable<number>;
  48527. /**
  48528. * Specifies the roughness scalar of the metallic/roughness workflow.
  48529. * Can also be used to scale the roughness values of the metallic texture.
  48530. */
  48531. protected _roughness: Nullable<number>;
  48532. /**
  48533. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48534. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48535. */
  48536. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48537. /**
  48538. * Stores surface normal data used to displace a mesh in a texture.
  48539. */
  48540. protected _bumpTexture: Nullable<BaseTexture>;
  48541. /**
  48542. * Stores the pre-calculated light information of a mesh in a texture.
  48543. */
  48544. protected _lightmapTexture: Nullable<BaseTexture>;
  48545. /**
  48546. * The color of a material in ambient lighting.
  48547. */
  48548. protected _ambientColor: Color3;
  48549. /**
  48550. * AKA Diffuse Color in other nomenclature.
  48551. */
  48552. protected _albedoColor: Color3;
  48553. /**
  48554. * AKA Specular Color in other nomenclature.
  48555. */
  48556. protected _reflectivityColor: Color3;
  48557. /**
  48558. * The color applied when light is reflected from a material.
  48559. */
  48560. protected _reflectionColor: Color3;
  48561. /**
  48562. * The color applied when light is emitted from a material.
  48563. */
  48564. protected _emissiveColor: Color3;
  48565. /**
  48566. * AKA Glossiness in other nomenclature.
  48567. */
  48568. protected _microSurface: number;
  48569. /**
  48570. * Specifies that the material will use the light map as a show map.
  48571. */
  48572. protected _useLightmapAsShadowmap: boolean;
  48573. /**
  48574. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48575. * makes the reflect vector face the model (under horizon).
  48576. */
  48577. protected _useHorizonOcclusion: boolean;
  48578. /**
  48579. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48580. * too much the area relying on ambient texture to define their ambient occlusion.
  48581. */
  48582. protected _useRadianceOcclusion: boolean;
  48583. /**
  48584. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48585. */
  48586. protected _useAlphaFromAlbedoTexture: boolean;
  48587. /**
  48588. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48589. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48590. */
  48591. protected _useSpecularOverAlpha: boolean;
  48592. /**
  48593. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48594. */
  48595. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48596. /**
  48597. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48598. */
  48599. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48600. /**
  48601. * Specifies if the metallic texture contains the roughness information in its green channel.
  48602. */
  48603. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48604. /**
  48605. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48606. */
  48607. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48608. /**
  48609. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48610. */
  48611. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48612. /**
  48613. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48614. */
  48615. protected _useAmbientInGrayScale: boolean;
  48616. /**
  48617. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48618. * The material will try to infer what glossiness each pixel should be.
  48619. */
  48620. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48621. /**
  48622. * Defines the falloff type used in this material.
  48623. * It by default is Physical.
  48624. */
  48625. protected _lightFalloff: number;
  48626. /**
  48627. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48628. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48629. */
  48630. protected _useRadianceOverAlpha: boolean;
  48631. /**
  48632. * Allows using an object space normal map (instead of tangent space).
  48633. */
  48634. protected _useObjectSpaceNormalMap: boolean;
  48635. /**
  48636. * Allows using the bump map in parallax mode.
  48637. */
  48638. protected _useParallax: boolean;
  48639. /**
  48640. * Allows using the bump map in parallax occlusion mode.
  48641. */
  48642. protected _useParallaxOcclusion: boolean;
  48643. /**
  48644. * Controls the scale bias of the parallax mode.
  48645. */
  48646. protected _parallaxScaleBias: number;
  48647. /**
  48648. * If sets to true, disables all the lights affecting the material.
  48649. */
  48650. protected _disableLighting: boolean;
  48651. /**
  48652. * Number of Simultaneous lights allowed on the material.
  48653. */
  48654. protected _maxSimultaneousLights: number;
  48655. /**
  48656. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48657. */
  48658. protected _invertNormalMapX: boolean;
  48659. /**
  48660. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48661. */
  48662. protected _invertNormalMapY: boolean;
  48663. /**
  48664. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48665. */
  48666. protected _twoSidedLighting: boolean;
  48667. /**
  48668. * Defines the alpha limits in alpha test mode.
  48669. */
  48670. protected _alphaCutOff: number;
  48671. /**
  48672. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48673. */
  48674. protected _forceAlphaTest: boolean;
  48675. /**
  48676. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48677. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48678. */
  48679. protected _useAlphaFresnel: boolean;
  48680. /**
  48681. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48682. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48683. */
  48684. protected _useLinearAlphaFresnel: boolean;
  48685. /**
  48686. * The transparency mode of the material.
  48687. */
  48688. protected _transparencyMode: Nullable<number>;
  48689. /**
  48690. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48691. * from cos thetav and roughness:
  48692. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48693. */
  48694. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48695. /**
  48696. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48697. */
  48698. protected _forceIrradianceInFragment: boolean;
  48699. /**
  48700. * Force normal to face away from face.
  48701. */
  48702. protected _forceNormalForward: boolean;
  48703. /**
  48704. * Enables specular anti aliasing in the PBR shader.
  48705. * It will both interacts on the Geometry for analytical and IBL lighting.
  48706. * It also prefilter the roughness map based on the bump values.
  48707. */
  48708. protected _enableSpecularAntiAliasing: boolean;
  48709. /**
  48710. * Default configuration related to image processing available in the PBR Material.
  48711. */
  48712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48713. /**
  48714. * Keep track of the image processing observer to allow dispose and replace.
  48715. */
  48716. private _imageProcessingObserver;
  48717. /**
  48718. * Attaches a new image processing configuration to the PBR Material.
  48719. * @param configuration
  48720. */
  48721. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48722. /**
  48723. * Stores the available render targets.
  48724. */
  48725. private _renderTargets;
  48726. /**
  48727. * Sets the global ambient color for the material used in lighting calculations.
  48728. */
  48729. private _globalAmbientColor;
  48730. /**
  48731. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48732. */
  48733. private _useLogarithmicDepth;
  48734. /**
  48735. * If set to true, no lighting calculations will be applied.
  48736. */
  48737. private _unlit;
  48738. private _debugMode;
  48739. /**
  48740. * @hidden
  48741. * This is reserved for the inspector.
  48742. * Defines the material debug mode.
  48743. * It helps seeing only some components of the material while troubleshooting.
  48744. */
  48745. debugMode: number;
  48746. /**
  48747. * @hidden
  48748. * This is reserved for the inspector.
  48749. * Specify from where on screen the debug mode should start.
  48750. * The value goes from -1 (full screen) to 1 (not visible)
  48751. * It helps with side by side comparison against the final render
  48752. * This defaults to -1
  48753. */
  48754. private debugLimit;
  48755. /**
  48756. * @hidden
  48757. * This is reserved for the inspector.
  48758. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48759. * You can use the factor to better multiply the final value.
  48760. */
  48761. private debugFactor;
  48762. /**
  48763. * Defines the clear coat layer parameters for the material.
  48764. */
  48765. readonly clearCoat: PBRClearCoatConfiguration;
  48766. /**
  48767. * Defines the anisotropic parameters for the material.
  48768. */
  48769. readonly anisotropy: PBRAnisotropicConfiguration;
  48770. /**
  48771. * Defines the BRDF parameters for the material.
  48772. */
  48773. readonly brdf: PBRBRDFConfiguration;
  48774. /**
  48775. * Defines the Sheen parameters for the material.
  48776. */
  48777. readonly sheen: PBRSheenConfiguration;
  48778. /**
  48779. * Defines the SubSurface parameters for the material.
  48780. */
  48781. readonly subSurface: PBRSubSurfaceConfiguration;
  48782. /**
  48783. * Custom callback helping to override the default shader used in the material.
  48784. */
  48785. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48786. /**
  48787. * Instantiates a new PBRMaterial instance.
  48788. *
  48789. * @param name The material name
  48790. * @param scene The scene the material will be use in.
  48791. */
  48792. constructor(name: string, scene: Scene);
  48793. /**
  48794. * Gets a boolean indicating that current material needs to register RTT
  48795. */
  48796. readonly hasRenderTargetTextures: boolean;
  48797. /**
  48798. * Gets the name of the material class.
  48799. */
  48800. getClassName(): string;
  48801. /**
  48802. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48803. */
  48804. /**
  48805. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48806. */
  48807. useLogarithmicDepth: boolean;
  48808. /**
  48809. * Gets the current transparency mode.
  48810. */
  48811. /**
  48812. * Sets the transparency mode of the material.
  48813. *
  48814. * | Value | Type | Description |
  48815. * | ----- | ----------------------------------- | ----------- |
  48816. * | 0 | OPAQUE | |
  48817. * | 1 | ALPHATEST | |
  48818. * | 2 | ALPHABLEND | |
  48819. * | 3 | ALPHATESTANDBLEND | |
  48820. *
  48821. */
  48822. transparencyMode: Nullable<number>;
  48823. /**
  48824. * Returns true if alpha blending should be disabled.
  48825. */
  48826. private readonly _disableAlphaBlending;
  48827. /**
  48828. * Specifies whether or not this material should be rendered in alpha blend mode.
  48829. */
  48830. needAlphaBlending(): boolean;
  48831. /**
  48832. * Specifies if the mesh will require alpha blending.
  48833. * @param mesh - BJS mesh.
  48834. */
  48835. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48836. /**
  48837. * Specifies whether or not this material should be rendered in alpha test mode.
  48838. */
  48839. needAlphaTesting(): boolean;
  48840. /**
  48841. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48842. */
  48843. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48844. /**
  48845. * Gets the texture used for the alpha test.
  48846. */
  48847. getAlphaTestTexture(): Nullable<BaseTexture>;
  48848. /**
  48849. * Specifies that the submesh is ready to be used.
  48850. * @param mesh - BJS mesh.
  48851. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48852. * @param useInstances - Specifies that instances should be used.
  48853. * @returns - boolean indicating that the submesh is ready or not.
  48854. */
  48855. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48856. /**
  48857. * Specifies if the material uses metallic roughness workflow.
  48858. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48859. */
  48860. isMetallicWorkflow(): boolean;
  48861. private _prepareEffect;
  48862. private _prepareDefines;
  48863. /**
  48864. * Force shader compilation
  48865. */
  48866. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48867. clipPlane: boolean;
  48868. }>): void;
  48869. /**
  48870. * Initializes the uniform buffer layout for the shader.
  48871. */
  48872. buildUniformLayout(): void;
  48873. /**
  48874. * Unbinds the material from the mesh
  48875. */
  48876. unbind(): void;
  48877. /**
  48878. * Binds the submesh data.
  48879. * @param world - The world matrix.
  48880. * @param mesh - The BJS mesh.
  48881. * @param subMesh - A submesh of the BJS mesh.
  48882. */
  48883. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48884. /**
  48885. * Returns the animatable textures.
  48886. * @returns - Array of animatable textures.
  48887. */
  48888. getAnimatables(): IAnimatable[];
  48889. /**
  48890. * Returns the texture used for reflections.
  48891. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48892. */
  48893. private _getReflectionTexture;
  48894. /**
  48895. * Returns an array of the actively used textures.
  48896. * @returns - Array of BaseTextures
  48897. */
  48898. getActiveTextures(): BaseTexture[];
  48899. /**
  48900. * Checks to see if a texture is used in the material.
  48901. * @param texture - Base texture to use.
  48902. * @returns - Boolean specifying if a texture is used in the material.
  48903. */
  48904. hasTexture(texture: BaseTexture): boolean;
  48905. /**
  48906. * Disposes the resources of the material.
  48907. * @param forceDisposeEffect - Forces the disposal of effects.
  48908. * @param forceDisposeTextures - Forces the disposal of all textures.
  48909. */
  48910. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48911. }
  48912. }
  48913. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48914. import { Nullable } from "babylonjs/types";
  48915. import { Scene } from "babylonjs/scene";
  48916. import { Color3 } from "babylonjs/Maths/math.color";
  48917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48918. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48920. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48921. /**
  48922. * The Physically based material of BJS.
  48923. *
  48924. * This offers the main features of a standard PBR material.
  48925. * For more information, please refer to the documentation :
  48926. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48927. */
  48928. export class PBRMaterial extends PBRBaseMaterial {
  48929. /**
  48930. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48931. */
  48932. static readonly PBRMATERIAL_OPAQUE: number;
  48933. /**
  48934. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48935. */
  48936. static readonly PBRMATERIAL_ALPHATEST: number;
  48937. /**
  48938. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48939. */
  48940. static readonly PBRMATERIAL_ALPHABLEND: number;
  48941. /**
  48942. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48943. * They are also discarded below the alpha cutoff threshold to improve performances.
  48944. */
  48945. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48946. /**
  48947. * Defines the default value of how much AO map is occluding the analytical lights
  48948. * (point spot...).
  48949. */
  48950. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48951. /**
  48952. * Intensity of the direct lights e.g. the four lights available in your scene.
  48953. * This impacts both the direct diffuse and specular highlights.
  48954. */
  48955. directIntensity: number;
  48956. /**
  48957. * Intensity of the emissive part of the material.
  48958. * This helps controlling the emissive effect without modifying the emissive color.
  48959. */
  48960. emissiveIntensity: number;
  48961. /**
  48962. * Intensity of the environment e.g. how much the environment will light the object
  48963. * either through harmonics for rough material or through the refelction for shiny ones.
  48964. */
  48965. environmentIntensity: number;
  48966. /**
  48967. * This is a special control allowing the reduction of the specular highlights coming from the
  48968. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48969. */
  48970. specularIntensity: number;
  48971. /**
  48972. * Debug Control allowing disabling the bump map on this material.
  48973. */
  48974. disableBumpMap: boolean;
  48975. /**
  48976. * AKA Diffuse Texture in standard nomenclature.
  48977. */
  48978. albedoTexture: BaseTexture;
  48979. /**
  48980. * AKA Occlusion Texture in other nomenclature.
  48981. */
  48982. ambientTexture: BaseTexture;
  48983. /**
  48984. * AKA Occlusion Texture Intensity in other nomenclature.
  48985. */
  48986. ambientTextureStrength: number;
  48987. /**
  48988. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48989. * 1 means it completely occludes it
  48990. * 0 mean it has no impact
  48991. */
  48992. ambientTextureImpactOnAnalyticalLights: number;
  48993. /**
  48994. * Stores the alpha values in a texture.
  48995. */
  48996. opacityTexture: BaseTexture;
  48997. /**
  48998. * Stores the reflection values in a texture.
  48999. */
  49000. reflectionTexture: Nullable<BaseTexture>;
  49001. /**
  49002. * Stores the emissive values in a texture.
  49003. */
  49004. emissiveTexture: BaseTexture;
  49005. /**
  49006. * AKA Specular texture in other nomenclature.
  49007. */
  49008. reflectivityTexture: BaseTexture;
  49009. /**
  49010. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49011. */
  49012. metallicTexture: BaseTexture;
  49013. /**
  49014. * Specifies the metallic scalar of the metallic/roughness workflow.
  49015. * Can also be used to scale the metalness values of the metallic texture.
  49016. */
  49017. metallic: Nullable<number>;
  49018. /**
  49019. * Specifies the roughness scalar of the metallic/roughness workflow.
  49020. * Can also be used to scale the roughness values of the metallic texture.
  49021. */
  49022. roughness: Nullable<number>;
  49023. /**
  49024. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49025. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49026. */
  49027. microSurfaceTexture: BaseTexture;
  49028. /**
  49029. * Stores surface normal data used to displace a mesh in a texture.
  49030. */
  49031. bumpTexture: BaseTexture;
  49032. /**
  49033. * Stores the pre-calculated light information of a mesh in a texture.
  49034. */
  49035. lightmapTexture: BaseTexture;
  49036. /**
  49037. * Stores the refracted light information in a texture.
  49038. */
  49039. refractionTexture: Nullable<BaseTexture>;
  49040. /**
  49041. * The color of a material in ambient lighting.
  49042. */
  49043. ambientColor: Color3;
  49044. /**
  49045. * AKA Diffuse Color in other nomenclature.
  49046. */
  49047. albedoColor: Color3;
  49048. /**
  49049. * AKA Specular Color in other nomenclature.
  49050. */
  49051. reflectivityColor: Color3;
  49052. /**
  49053. * The color reflected from the material.
  49054. */
  49055. reflectionColor: Color3;
  49056. /**
  49057. * The color emitted from the material.
  49058. */
  49059. emissiveColor: Color3;
  49060. /**
  49061. * AKA Glossiness in other nomenclature.
  49062. */
  49063. microSurface: number;
  49064. /**
  49065. * source material index of refraction (IOR)' / 'destination material IOR.
  49066. */
  49067. indexOfRefraction: number;
  49068. /**
  49069. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49070. */
  49071. invertRefractionY: boolean;
  49072. /**
  49073. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49074. * Materials half opaque for instance using refraction could benefit from this control.
  49075. */
  49076. linkRefractionWithTransparency: boolean;
  49077. /**
  49078. * If true, the light map contains occlusion information instead of lighting info.
  49079. */
  49080. useLightmapAsShadowmap: boolean;
  49081. /**
  49082. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49083. */
  49084. useAlphaFromAlbedoTexture: boolean;
  49085. /**
  49086. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49087. */
  49088. forceAlphaTest: boolean;
  49089. /**
  49090. * Defines the alpha limits in alpha test mode.
  49091. */
  49092. alphaCutOff: number;
  49093. /**
  49094. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49096. */
  49097. useSpecularOverAlpha: boolean;
  49098. /**
  49099. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49100. */
  49101. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49102. /**
  49103. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49104. */
  49105. useRoughnessFromMetallicTextureAlpha: boolean;
  49106. /**
  49107. * Specifies if the metallic texture contains the roughness information in its green channel.
  49108. */
  49109. useRoughnessFromMetallicTextureGreen: boolean;
  49110. /**
  49111. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49112. */
  49113. useMetallnessFromMetallicTextureBlue: boolean;
  49114. /**
  49115. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49116. */
  49117. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49118. /**
  49119. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49120. */
  49121. useAmbientInGrayScale: boolean;
  49122. /**
  49123. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49124. * The material will try to infer what glossiness each pixel should be.
  49125. */
  49126. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49127. /**
  49128. * BJS is using an harcoded light falloff based on a manually sets up range.
  49129. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49130. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49131. */
  49132. /**
  49133. * BJS is using an harcoded light falloff based on a manually sets up range.
  49134. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49135. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49136. */
  49137. usePhysicalLightFalloff: boolean;
  49138. /**
  49139. * In order to support the falloff compatibility with gltf, a special mode has been added
  49140. * to reproduce the gltf light falloff.
  49141. */
  49142. /**
  49143. * In order to support the falloff compatibility with gltf, a special mode has been added
  49144. * to reproduce the gltf light falloff.
  49145. */
  49146. useGLTFLightFalloff: boolean;
  49147. /**
  49148. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49149. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49150. */
  49151. useRadianceOverAlpha: boolean;
  49152. /**
  49153. * Allows using an object space normal map (instead of tangent space).
  49154. */
  49155. useObjectSpaceNormalMap: boolean;
  49156. /**
  49157. * Allows using the bump map in parallax mode.
  49158. */
  49159. useParallax: boolean;
  49160. /**
  49161. * Allows using the bump map in parallax occlusion mode.
  49162. */
  49163. useParallaxOcclusion: boolean;
  49164. /**
  49165. * Controls the scale bias of the parallax mode.
  49166. */
  49167. parallaxScaleBias: number;
  49168. /**
  49169. * If sets to true, disables all the lights affecting the material.
  49170. */
  49171. disableLighting: boolean;
  49172. /**
  49173. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49174. */
  49175. forceIrradianceInFragment: boolean;
  49176. /**
  49177. * Number of Simultaneous lights allowed on the material.
  49178. */
  49179. maxSimultaneousLights: number;
  49180. /**
  49181. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49182. */
  49183. invertNormalMapX: boolean;
  49184. /**
  49185. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49186. */
  49187. invertNormalMapY: boolean;
  49188. /**
  49189. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49190. */
  49191. twoSidedLighting: boolean;
  49192. /**
  49193. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49194. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49195. */
  49196. useAlphaFresnel: boolean;
  49197. /**
  49198. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49199. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49200. */
  49201. useLinearAlphaFresnel: boolean;
  49202. /**
  49203. * Let user defines the brdf lookup texture used for IBL.
  49204. * A default 8bit version is embedded but you could point at :
  49205. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49206. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49207. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49208. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49209. */
  49210. environmentBRDFTexture: Nullable<BaseTexture>;
  49211. /**
  49212. * Force normal to face away from face.
  49213. */
  49214. forceNormalForward: boolean;
  49215. /**
  49216. * Enables specular anti aliasing in the PBR shader.
  49217. * It will both interacts on the Geometry for analytical and IBL lighting.
  49218. * It also prefilter the roughness map based on the bump values.
  49219. */
  49220. enableSpecularAntiAliasing: boolean;
  49221. /**
  49222. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49223. * makes the reflect vector face the model (under horizon).
  49224. */
  49225. useHorizonOcclusion: boolean;
  49226. /**
  49227. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49228. * too much the area relying on ambient texture to define their ambient occlusion.
  49229. */
  49230. useRadianceOcclusion: boolean;
  49231. /**
  49232. * If set to true, no lighting calculations will be applied.
  49233. */
  49234. unlit: boolean;
  49235. /**
  49236. * Gets the image processing configuration used either in this material.
  49237. */
  49238. /**
  49239. * Sets the Default image processing configuration used either in the this material.
  49240. *
  49241. * If sets to null, the scene one is in use.
  49242. */
  49243. imageProcessingConfiguration: ImageProcessingConfiguration;
  49244. /**
  49245. * Gets wether the color curves effect is enabled.
  49246. */
  49247. /**
  49248. * Sets wether the color curves effect is enabled.
  49249. */
  49250. cameraColorCurvesEnabled: boolean;
  49251. /**
  49252. * Gets wether the color grading effect is enabled.
  49253. */
  49254. /**
  49255. * Gets wether the color grading effect is enabled.
  49256. */
  49257. cameraColorGradingEnabled: boolean;
  49258. /**
  49259. * Gets wether tonemapping is enabled or not.
  49260. */
  49261. /**
  49262. * Sets wether tonemapping is enabled or not
  49263. */
  49264. cameraToneMappingEnabled: boolean;
  49265. /**
  49266. * The camera exposure used on this material.
  49267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49268. * This corresponds to a photographic exposure.
  49269. */
  49270. /**
  49271. * The camera exposure used on this material.
  49272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49273. * This corresponds to a photographic exposure.
  49274. */
  49275. cameraExposure: number;
  49276. /**
  49277. * Gets The camera contrast used on this material.
  49278. */
  49279. /**
  49280. * Sets The camera contrast used on this material.
  49281. */
  49282. cameraContrast: number;
  49283. /**
  49284. * Gets the Color Grading 2D Lookup Texture.
  49285. */
  49286. /**
  49287. * Sets the Color Grading 2D Lookup Texture.
  49288. */
  49289. cameraColorGradingTexture: Nullable<BaseTexture>;
  49290. /**
  49291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49293. * 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;
  49294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49295. */
  49296. /**
  49297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49299. * 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;
  49300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49301. */
  49302. cameraColorCurves: Nullable<ColorCurves>;
  49303. /**
  49304. * Instantiates a new PBRMaterial instance.
  49305. *
  49306. * @param name The material name
  49307. * @param scene The scene the material will be use in.
  49308. */
  49309. constructor(name: string, scene: Scene);
  49310. /**
  49311. * Returns the name of this material class.
  49312. */
  49313. getClassName(): string;
  49314. /**
  49315. * Makes a duplicate of the current material.
  49316. * @param name - name to use for the new material.
  49317. */
  49318. clone(name: string): PBRMaterial;
  49319. /**
  49320. * Serializes this PBR Material.
  49321. * @returns - An object with the serialized material.
  49322. */
  49323. serialize(): any;
  49324. /**
  49325. * Parses a PBR Material from a serialized object.
  49326. * @param source - Serialized object.
  49327. * @param scene - BJS scene instance.
  49328. * @param rootUrl - url for the scene object
  49329. * @returns - PBRMaterial
  49330. */
  49331. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49332. }
  49333. }
  49334. declare module "babylonjs/Misc/dds" {
  49335. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49336. import { Engine } from "babylonjs/Engines/engine";
  49337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49338. import { Nullable } from "babylonjs/types";
  49339. import { Scene } from "babylonjs/scene";
  49340. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49341. /**
  49342. * Direct draw surface info
  49343. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49344. */
  49345. export interface DDSInfo {
  49346. /**
  49347. * Width of the texture
  49348. */
  49349. width: number;
  49350. /**
  49351. * Width of the texture
  49352. */
  49353. height: number;
  49354. /**
  49355. * Number of Mipmaps for the texture
  49356. * @see https://en.wikipedia.org/wiki/Mipmap
  49357. */
  49358. mipmapCount: number;
  49359. /**
  49360. * If the textures format is a known fourCC format
  49361. * @see https://www.fourcc.org/
  49362. */
  49363. isFourCC: boolean;
  49364. /**
  49365. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49366. */
  49367. isRGB: boolean;
  49368. /**
  49369. * If the texture is a lumincance format
  49370. */
  49371. isLuminance: boolean;
  49372. /**
  49373. * If this is a cube texture
  49374. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49375. */
  49376. isCube: boolean;
  49377. /**
  49378. * If the texture is a compressed format eg. FOURCC_DXT1
  49379. */
  49380. isCompressed: boolean;
  49381. /**
  49382. * The dxgiFormat of the texture
  49383. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49384. */
  49385. dxgiFormat: number;
  49386. /**
  49387. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49388. */
  49389. textureType: number;
  49390. /**
  49391. * Sphericle polynomial created for the dds texture
  49392. */
  49393. sphericalPolynomial?: SphericalPolynomial;
  49394. }
  49395. /**
  49396. * Class used to provide DDS decompression tools
  49397. */
  49398. export class DDSTools {
  49399. /**
  49400. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49401. */
  49402. static StoreLODInAlphaChannel: boolean;
  49403. /**
  49404. * Gets DDS information from an array buffer
  49405. * @param arrayBuffer defines the array buffer to read data from
  49406. * @returns the DDS information
  49407. */
  49408. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49409. private static _FloatView;
  49410. private static _Int32View;
  49411. private static _ToHalfFloat;
  49412. private static _FromHalfFloat;
  49413. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49414. private static _GetHalfFloatRGBAArrayBuffer;
  49415. private static _GetFloatRGBAArrayBuffer;
  49416. private static _GetFloatAsUIntRGBAArrayBuffer;
  49417. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49418. private static _GetRGBAArrayBuffer;
  49419. private static _ExtractLongWordOrder;
  49420. private static _GetRGBArrayBuffer;
  49421. private static _GetLuminanceArrayBuffer;
  49422. /**
  49423. * Uploads DDS Levels to a Babylon Texture
  49424. * @hidden
  49425. */
  49426. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49427. }
  49428. module "babylonjs/Engines/engine" {
  49429. interface Engine {
  49430. /**
  49431. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49432. * @param rootUrl defines the url where the file to load is located
  49433. * @param scene defines the current scene
  49434. * @param lodScale defines scale to apply to the mip map selection
  49435. * @param lodOffset defines offset to apply to the mip map selection
  49436. * @param onLoad defines an optional callback raised when the texture is loaded
  49437. * @param onError defines an optional callback raised if there is an issue to load the texture
  49438. * @param format defines the format of the data
  49439. * @param forcedExtension defines the extension to use to pick the right loader
  49440. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49441. * @returns the cube texture as an InternalTexture
  49442. */
  49443. 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;
  49444. }
  49445. }
  49446. }
  49447. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49448. import { Nullable } from "babylonjs/types";
  49449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49450. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49451. /**
  49452. * Implementation of the DDS Texture Loader.
  49453. * @hidden
  49454. */
  49455. export class _DDSTextureLoader implements IInternalTextureLoader {
  49456. /**
  49457. * Defines wether the loader supports cascade loading the different faces.
  49458. */
  49459. readonly supportCascades: boolean;
  49460. /**
  49461. * This returns if the loader support the current file information.
  49462. * @param extension defines the file extension of the file being loaded
  49463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49464. * @param fallback defines the fallback internal texture if any
  49465. * @param isBase64 defines whether the texture is encoded as a base64
  49466. * @param isBuffer defines whether the texture data are stored as a buffer
  49467. * @returns true if the loader can load the specified file
  49468. */
  49469. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49470. /**
  49471. * Transform the url before loading if required.
  49472. * @param rootUrl the url of the texture
  49473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49474. * @returns the transformed texture
  49475. */
  49476. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49477. /**
  49478. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49479. * @param rootUrl the url of the texture
  49480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49481. * @returns the fallback texture
  49482. */
  49483. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49484. /**
  49485. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49486. * @param data contains the texture data
  49487. * @param texture defines the BabylonJS internal texture
  49488. * @param createPolynomials will be true if polynomials have been requested
  49489. * @param onLoad defines the callback to trigger once the texture is ready
  49490. * @param onError defines the callback to trigger in case of error
  49491. */
  49492. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49493. /**
  49494. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49495. * @param data contains the texture data
  49496. * @param texture defines the BabylonJS internal texture
  49497. * @param callback defines the method to call once ready to upload
  49498. */
  49499. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49500. }
  49501. }
  49502. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49504. /** @hidden */
  49505. export var rgbdEncodePixelShader: {
  49506. name: string;
  49507. shader: string;
  49508. };
  49509. }
  49510. declare module "babylonjs/Misc/environmentTextureTools" {
  49511. import { Nullable } from "babylonjs/types";
  49512. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49514. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49515. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49516. import "babylonjs/Shaders/rgbdEncode.fragment";
  49517. import "babylonjs/Shaders/rgbdDecode.fragment";
  49518. /**
  49519. * Raw texture data and descriptor sufficient for WebGL texture upload
  49520. */
  49521. export interface EnvironmentTextureInfo {
  49522. /**
  49523. * Version of the environment map
  49524. */
  49525. version: number;
  49526. /**
  49527. * Width of image
  49528. */
  49529. width: number;
  49530. /**
  49531. * Irradiance information stored in the file.
  49532. */
  49533. irradiance: any;
  49534. /**
  49535. * Specular information stored in the file.
  49536. */
  49537. specular: any;
  49538. }
  49539. /**
  49540. * Sets of helpers addressing the serialization and deserialization of environment texture
  49541. * stored in a BabylonJS env file.
  49542. * Those files are usually stored as .env files.
  49543. */
  49544. export class EnvironmentTextureTools {
  49545. /**
  49546. * Magic number identifying the env file.
  49547. */
  49548. private static _MagicBytes;
  49549. /**
  49550. * Gets the environment info from an env file.
  49551. * @param data The array buffer containing the .env bytes.
  49552. * @returns the environment file info (the json header) if successfully parsed.
  49553. */
  49554. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49555. /**
  49556. * Creates an environment texture from a loaded cube texture.
  49557. * @param texture defines the cube texture to convert in env file
  49558. * @return a promise containing the environment data if succesfull.
  49559. */
  49560. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49561. /**
  49562. * Creates a JSON representation of the spherical data.
  49563. * @param texture defines the texture containing the polynomials
  49564. * @return the JSON representation of the spherical info
  49565. */
  49566. private static _CreateEnvTextureIrradiance;
  49567. /**
  49568. * Uploads the texture info contained in the env file to the GPU.
  49569. * @param texture defines the internal texture to upload to
  49570. * @param arrayBuffer defines the buffer cotaining the data to load
  49571. * @param info defines the texture info retrieved through the GetEnvInfo method
  49572. * @returns a promise
  49573. */
  49574. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49575. /**
  49576. * Uploads the levels of image data to the GPU.
  49577. * @param texture defines the internal texture to upload to
  49578. * @param imageData defines the array buffer views of image data [mipmap][face]
  49579. * @returns a promise
  49580. */
  49581. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49582. /**
  49583. * Uploads spherical polynomials information to the texture.
  49584. * @param texture defines the texture we are trying to upload the information to
  49585. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49586. */
  49587. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49588. /** @hidden */
  49589. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49590. }
  49591. }
  49592. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49593. import { Nullable } from "babylonjs/types";
  49594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49595. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49596. /**
  49597. * Implementation of the ENV Texture Loader.
  49598. * @hidden
  49599. */
  49600. export class _ENVTextureLoader implements IInternalTextureLoader {
  49601. /**
  49602. * Defines wether the loader supports cascade loading the different faces.
  49603. */
  49604. readonly supportCascades: boolean;
  49605. /**
  49606. * This returns if the loader support the current file information.
  49607. * @param extension defines the file extension of the file being loaded
  49608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49609. * @param fallback defines the fallback internal texture if any
  49610. * @param isBase64 defines whether the texture is encoded as a base64
  49611. * @param isBuffer defines whether the texture data are stored as a buffer
  49612. * @returns true if the loader can load the specified file
  49613. */
  49614. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49615. /**
  49616. * Transform the url before loading if required.
  49617. * @param rootUrl the url of the texture
  49618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49619. * @returns the transformed texture
  49620. */
  49621. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49622. /**
  49623. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49624. * @param rootUrl the url of the texture
  49625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49626. * @returns the fallback texture
  49627. */
  49628. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49629. /**
  49630. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49631. * @param data contains the texture data
  49632. * @param texture defines the BabylonJS internal texture
  49633. * @param createPolynomials will be true if polynomials have been requested
  49634. * @param onLoad defines the callback to trigger once the texture is ready
  49635. * @param onError defines the callback to trigger in case of error
  49636. */
  49637. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49638. /**
  49639. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49640. * @param data contains the texture data
  49641. * @param texture defines the BabylonJS internal texture
  49642. * @param callback defines the method to call once ready to upload
  49643. */
  49644. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49645. }
  49646. }
  49647. declare module "babylonjs/Misc/khronosTextureContainer" {
  49648. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49649. /**
  49650. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49651. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49652. */
  49653. export class KhronosTextureContainer {
  49654. /** contents of the KTX container file */
  49655. arrayBuffer: any;
  49656. private static HEADER_LEN;
  49657. private static COMPRESSED_2D;
  49658. private static COMPRESSED_3D;
  49659. private static TEX_2D;
  49660. private static TEX_3D;
  49661. /**
  49662. * Gets the openGL type
  49663. */
  49664. glType: number;
  49665. /**
  49666. * Gets the openGL type size
  49667. */
  49668. glTypeSize: number;
  49669. /**
  49670. * Gets the openGL format
  49671. */
  49672. glFormat: number;
  49673. /**
  49674. * Gets the openGL internal format
  49675. */
  49676. glInternalFormat: number;
  49677. /**
  49678. * Gets the base internal format
  49679. */
  49680. glBaseInternalFormat: number;
  49681. /**
  49682. * Gets image width in pixel
  49683. */
  49684. pixelWidth: number;
  49685. /**
  49686. * Gets image height in pixel
  49687. */
  49688. pixelHeight: number;
  49689. /**
  49690. * Gets image depth in pixels
  49691. */
  49692. pixelDepth: number;
  49693. /**
  49694. * Gets the number of array elements
  49695. */
  49696. numberOfArrayElements: number;
  49697. /**
  49698. * Gets the number of faces
  49699. */
  49700. numberOfFaces: number;
  49701. /**
  49702. * Gets the number of mipmap levels
  49703. */
  49704. numberOfMipmapLevels: number;
  49705. /**
  49706. * Gets the bytes of key value data
  49707. */
  49708. bytesOfKeyValueData: number;
  49709. /**
  49710. * Gets the load type
  49711. */
  49712. loadType: number;
  49713. /**
  49714. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49715. */
  49716. isInvalid: boolean;
  49717. /**
  49718. * Creates a new KhronosTextureContainer
  49719. * @param arrayBuffer contents of the KTX container file
  49720. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49721. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49722. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49723. */
  49724. constructor(
  49725. /** contents of the KTX container file */
  49726. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49727. /**
  49728. * Uploads KTX content to a Babylon Texture.
  49729. * It is assumed that the texture has already been created & is currently bound
  49730. * @hidden
  49731. */
  49732. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49733. private _upload2DCompressedLevels;
  49734. }
  49735. }
  49736. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49737. import { Nullable } from "babylonjs/types";
  49738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49739. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49740. /**
  49741. * Implementation of the KTX Texture Loader.
  49742. * @hidden
  49743. */
  49744. export class _KTXTextureLoader implements IInternalTextureLoader {
  49745. /**
  49746. * Defines wether the loader supports cascade loading the different faces.
  49747. */
  49748. readonly supportCascades: boolean;
  49749. /**
  49750. * This returns if the loader support the current file information.
  49751. * @param extension defines the file extension of the file being loaded
  49752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49753. * @param fallback defines the fallback internal texture if any
  49754. * @param isBase64 defines whether the texture is encoded as a base64
  49755. * @param isBuffer defines whether the texture data are stored as a buffer
  49756. * @returns true if the loader can load the specified file
  49757. */
  49758. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49759. /**
  49760. * Transform the url before loading if required.
  49761. * @param rootUrl the url of the texture
  49762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49763. * @returns the transformed texture
  49764. */
  49765. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49766. /**
  49767. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49768. * @param rootUrl the url of the texture
  49769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49770. * @returns the fallback texture
  49771. */
  49772. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49773. /**
  49774. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49775. * @param data contains the texture data
  49776. * @param texture defines the BabylonJS internal texture
  49777. * @param createPolynomials will be true if polynomials have been requested
  49778. * @param onLoad defines the callback to trigger once the texture is ready
  49779. * @param onError defines the callback to trigger in case of error
  49780. */
  49781. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49782. /**
  49783. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49784. * @param data contains the texture data
  49785. * @param texture defines the BabylonJS internal texture
  49786. * @param callback defines the method to call once ready to upload
  49787. */
  49788. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49789. }
  49790. }
  49791. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49792. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49793. import { Scene } from "babylonjs/scene";
  49794. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49795. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49796. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49797. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49798. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49799. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49801. /**
  49802. * Options for the default xr helper
  49803. */
  49804. export class WebXRDefaultExperienceOptions {
  49805. /**
  49806. * Floor meshes that should be used for teleporting
  49807. */
  49808. floorMeshes: Array<AbstractMesh>;
  49809. }
  49810. /**
  49811. * Default experience which provides a similar setup to the previous webVRExperience
  49812. */
  49813. export class WebXRDefaultExperience {
  49814. /**
  49815. * Base experience
  49816. */
  49817. baseExperience: WebXRExperienceHelper;
  49818. /**
  49819. * Input experience extension
  49820. */
  49821. input: WebXRInput;
  49822. /**
  49823. * Loads the controller models
  49824. */
  49825. controllerModelLoader: WebXRControllerModelLoader;
  49826. /**
  49827. * Enables laser pointer and selection
  49828. */
  49829. pointerSelection: WebXRControllerPointerSelection;
  49830. /**
  49831. * Enables teleportation
  49832. */
  49833. teleportation: WebXRControllerTeleportation;
  49834. /**
  49835. * Enables ui for enetering/exiting xr
  49836. */
  49837. enterExitUI: WebXREnterExitUI;
  49838. /**
  49839. * Default output canvas xr should render to
  49840. */
  49841. outputCanvas: WebXRManagedOutputCanvas;
  49842. /**
  49843. * Creates the default xr experience
  49844. * @param scene scene
  49845. * @param options options for basic configuration
  49846. * @returns resulting WebXRDefaultExperience
  49847. */
  49848. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49849. private constructor();
  49850. /**
  49851. * DIsposes of the experience helper
  49852. */
  49853. dispose(): void;
  49854. }
  49855. }
  49856. declare module "babylonjs/Helpers/sceneHelpers" {
  49857. import { Nullable } from "babylonjs/types";
  49858. import { Mesh } from "babylonjs/Meshes/mesh";
  49859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49860. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49861. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49862. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49863. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49864. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49865. import "babylonjs/Meshes/Builders/boxBuilder";
  49866. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49867. /** @hidden */
  49868. export var _forceSceneHelpersToBundle: boolean;
  49869. module "babylonjs/scene" {
  49870. interface Scene {
  49871. /**
  49872. * Creates a default light for the scene.
  49873. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49874. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49875. */
  49876. createDefaultLight(replace?: boolean): void;
  49877. /**
  49878. * Creates a default camera for the scene.
  49879. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49880. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49881. * @param replace has default false, when true replaces the active camera in the scene
  49882. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49883. */
  49884. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49885. /**
  49886. * Creates a default camera and a default light.
  49887. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49889. * @param replace has the default false, when true replaces the active camera/light in the scene
  49890. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49891. */
  49892. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49893. /**
  49894. * Creates a new sky box
  49895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49896. * @param environmentTexture defines the texture to use as environment texture
  49897. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49898. * @param scale defines the overall scale of the skybox
  49899. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49900. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49901. * @returns a new mesh holding the sky box
  49902. */
  49903. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49904. /**
  49905. * Creates a new environment
  49906. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49907. * @param options defines the options you can use to configure the environment
  49908. * @returns the new EnvironmentHelper
  49909. */
  49910. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49911. /**
  49912. * Creates a new VREXperienceHelper
  49913. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49914. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49915. * @returns a new VREXperienceHelper
  49916. */
  49917. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49918. /**
  49919. * Creates a new WebXRDefaultExperience
  49920. * @see http://doc.babylonjs.com/how_to/webxr
  49921. * @param options experience options
  49922. * @returns a promise for a new WebXRDefaultExperience
  49923. */
  49924. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49925. }
  49926. }
  49927. }
  49928. declare module "babylonjs/Helpers/videoDome" {
  49929. import { Scene } from "babylonjs/scene";
  49930. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49931. import { Mesh } from "babylonjs/Meshes/mesh";
  49932. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49933. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49934. import "babylonjs/Meshes/Builders/sphereBuilder";
  49935. /**
  49936. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49937. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49938. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49939. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49940. */
  49941. export class VideoDome extends TransformNode {
  49942. /**
  49943. * Define the video source as a Monoscopic panoramic 360 video.
  49944. */
  49945. static readonly MODE_MONOSCOPIC: number;
  49946. /**
  49947. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49948. */
  49949. static readonly MODE_TOPBOTTOM: number;
  49950. /**
  49951. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49952. */
  49953. static readonly MODE_SIDEBYSIDE: number;
  49954. private _useDirectMapping;
  49955. /**
  49956. * The video texture being displayed on the sphere
  49957. */
  49958. protected _videoTexture: VideoTexture;
  49959. /**
  49960. * Gets the video texture being displayed on the sphere
  49961. */
  49962. readonly videoTexture: VideoTexture;
  49963. /**
  49964. * The skybox material
  49965. */
  49966. protected _material: BackgroundMaterial;
  49967. /**
  49968. * The surface used for the skybox
  49969. */
  49970. protected _mesh: Mesh;
  49971. /**
  49972. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49973. * Also see the options.resolution property.
  49974. */
  49975. fovMultiplier: number;
  49976. private _videoMode;
  49977. /**
  49978. * Gets or set the current video mode for the video. It can be:
  49979. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49980. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49981. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49982. */
  49983. videoMode: number;
  49984. /**
  49985. * Oberserver used in Stereoscopic VR Mode.
  49986. */
  49987. private _onBeforeCameraRenderObserver;
  49988. /**
  49989. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49990. * @param name Element's name, child elements will append suffixes for their own names.
  49991. * @param urlsOrVideo defines the url(s) or the video element to use
  49992. * @param options An object containing optional or exposed sub element properties
  49993. */
  49994. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49995. resolution?: number;
  49996. clickToPlay?: boolean;
  49997. autoPlay?: boolean;
  49998. loop?: boolean;
  49999. size?: number;
  50000. poster?: string;
  50001. faceForward?: boolean;
  50002. useDirectMapping?: boolean;
  50003. }, scene: Scene);
  50004. private _changeVideoMode;
  50005. /**
  50006. * Releases resources associated with this node.
  50007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50009. */
  50010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50011. }
  50012. }
  50013. declare module "babylonjs/Helpers/index" {
  50014. export * from "babylonjs/Helpers/environmentHelper";
  50015. export * from "babylonjs/Helpers/photoDome";
  50016. export * from "babylonjs/Helpers/sceneHelpers";
  50017. export * from "babylonjs/Helpers/videoDome";
  50018. }
  50019. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50020. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50021. import { IDisposable } from "babylonjs/scene";
  50022. import { Engine } from "babylonjs/Engines/engine";
  50023. /**
  50024. * This class can be used to get instrumentation data from a Babylon engine
  50025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50026. */
  50027. export class EngineInstrumentation implements IDisposable {
  50028. /**
  50029. * Define the instrumented engine.
  50030. */
  50031. engine: Engine;
  50032. private _captureGPUFrameTime;
  50033. private _gpuFrameTimeToken;
  50034. private _gpuFrameTime;
  50035. private _captureShaderCompilationTime;
  50036. private _shaderCompilationTime;
  50037. private _onBeginFrameObserver;
  50038. private _onEndFrameObserver;
  50039. private _onBeforeShaderCompilationObserver;
  50040. private _onAfterShaderCompilationObserver;
  50041. /**
  50042. * Gets the perf counter used for GPU frame time
  50043. */
  50044. readonly gpuFrameTimeCounter: PerfCounter;
  50045. /**
  50046. * Gets the GPU frame time capture status
  50047. */
  50048. /**
  50049. * Enable or disable the GPU frame time capture
  50050. */
  50051. captureGPUFrameTime: boolean;
  50052. /**
  50053. * Gets the perf counter used for shader compilation time
  50054. */
  50055. readonly shaderCompilationTimeCounter: PerfCounter;
  50056. /**
  50057. * Gets the shader compilation time capture status
  50058. */
  50059. /**
  50060. * Enable or disable the shader compilation time capture
  50061. */
  50062. captureShaderCompilationTime: boolean;
  50063. /**
  50064. * Instantiates a new engine instrumentation.
  50065. * This class can be used to get instrumentation data from a Babylon engine
  50066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50067. * @param engine Defines the engine to instrument
  50068. */
  50069. constructor(
  50070. /**
  50071. * Define the instrumented engine.
  50072. */
  50073. engine: Engine);
  50074. /**
  50075. * Dispose and release associated resources.
  50076. */
  50077. dispose(): void;
  50078. }
  50079. }
  50080. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50081. import { Scene, IDisposable } from "babylonjs/scene";
  50082. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50083. /**
  50084. * This class can be used to get instrumentation data from a Babylon engine
  50085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50086. */
  50087. export class SceneInstrumentation implements IDisposable {
  50088. /**
  50089. * Defines the scene to instrument
  50090. */
  50091. scene: Scene;
  50092. private _captureActiveMeshesEvaluationTime;
  50093. private _activeMeshesEvaluationTime;
  50094. private _captureRenderTargetsRenderTime;
  50095. private _renderTargetsRenderTime;
  50096. private _captureFrameTime;
  50097. private _frameTime;
  50098. private _captureRenderTime;
  50099. private _renderTime;
  50100. private _captureInterFrameTime;
  50101. private _interFrameTime;
  50102. private _captureParticlesRenderTime;
  50103. private _particlesRenderTime;
  50104. private _captureSpritesRenderTime;
  50105. private _spritesRenderTime;
  50106. private _capturePhysicsTime;
  50107. private _physicsTime;
  50108. private _captureAnimationsTime;
  50109. private _animationsTime;
  50110. private _captureCameraRenderTime;
  50111. private _cameraRenderTime;
  50112. private _onBeforeActiveMeshesEvaluationObserver;
  50113. private _onAfterActiveMeshesEvaluationObserver;
  50114. private _onBeforeRenderTargetsRenderObserver;
  50115. private _onAfterRenderTargetsRenderObserver;
  50116. private _onAfterRenderObserver;
  50117. private _onBeforeDrawPhaseObserver;
  50118. private _onAfterDrawPhaseObserver;
  50119. private _onBeforeAnimationsObserver;
  50120. private _onBeforeParticlesRenderingObserver;
  50121. private _onAfterParticlesRenderingObserver;
  50122. private _onBeforeSpritesRenderingObserver;
  50123. private _onAfterSpritesRenderingObserver;
  50124. private _onBeforePhysicsObserver;
  50125. private _onAfterPhysicsObserver;
  50126. private _onAfterAnimationsObserver;
  50127. private _onBeforeCameraRenderObserver;
  50128. private _onAfterCameraRenderObserver;
  50129. /**
  50130. * Gets the perf counter used for active meshes evaluation time
  50131. */
  50132. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50133. /**
  50134. * Gets the active meshes evaluation time capture status
  50135. */
  50136. /**
  50137. * Enable or disable the active meshes evaluation time capture
  50138. */
  50139. captureActiveMeshesEvaluationTime: boolean;
  50140. /**
  50141. * Gets the perf counter used for render targets render time
  50142. */
  50143. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50144. /**
  50145. * Gets the render targets render time capture status
  50146. */
  50147. /**
  50148. * Enable or disable the render targets render time capture
  50149. */
  50150. captureRenderTargetsRenderTime: boolean;
  50151. /**
  50152. * Gets the perf counter used for particles render time
  50153. */
  50154. readonly particlesRenderTimeCounter: PerfCounter;
  50155. /**
  50156. * Gets the particles render time capture status
  50157. */
  50158. /**
  50159. * Enable or disable the particles render time capture
  50160. */
  50161. captureParticlesRenderTime: boolean;
  50162. /**
  50163. * Gets the perf counter used for sprites render time
  50164. */
  50165. readonly spritesRenderTimeCounter: PerfCounter;
  50166. /**
  50167. * Gets the sprites render time capture status
  50168. */
  50169. /**
  50170. * Enable or disable the sprites render time capture
  50171. */
  50172. captureSpritesRenderTime: boolean;
  50173. /**
  50174. * Gets the perf counter used for physics time
  50175. */
  50176. readonly physicsTimeCounter: PerfCounter;
  50177. /**
  50178. * Gets the physics time capture status
  50179. */
  50180. /**
  50181. * Enable or disable the physics time capture
  50182. */
  50183. capturePhysicsTime: boolean;
  50184. /**
  50185. * Gets the perf counter used for animations time
  50186. */
  50187. readonly animationsTimeCounter: PerfCounter;
  50188. /**
  50189. * Gets the animations time capture status
  50190. */
  50191. /**
  50192. * Enable or disable the animations time capture
  50193. */
  50194. captureAnimationsTime: boolean;
  50195. /**
  50196. * Gets the perf counter used for frame time capture
  50197. */
  50198. readonly frameTimeCounter: PerfCounter;
  50199. /**
  50200. * Gets the frame time capture status
  50201. */
  50202. /**
  50203. * Enable or disable the frame time capture
  50204. */
  50205. captureFrameTime: boolean;
  50206. /**
  50207. * Gets the perf counter used for inter-frames time capture
  50208. */
  50209. readonly interFrameTimeCounter: PerfCounter;
  50210. /**
  50211. * Gets the inter-frames time capture status
  50212. */
  50213. /**
  50214. * Enable or disable the inter-frames time capture
  50215. */
  50216. captureInterFrameTime: boolean;
  50217. /**
  50218. * Gets the perf counter used for render time capture
  50219. */
  50220. readonly renderTimeCounter: PerfCounter;
  50221. /**
  50222. * Gets the render time capture status
  50223. */
  50224. /**
  50225. * Enable or disable the render time capture
  50226. */
  50227. captureRenderTime: boolean;
  50228. /**
  50229. * Gets the perf counter used for camera render time capture
  50230. */
  50231. readonly cameraRenderTimeCounter: PerfCounter;
  50232. /**
  50233. * Gets the camera render time capture status
  50234. */
  50235. /**
  50236. * Enable or disable the camera render time capture
  50237. */
  50238. captureCameraRenderTime: boolean;
  50239. /**
  50240. * Gets the perf counter used for draw calls
  50241. */
  50242. readonly drawCallsCounter: PerfCounter;
  50243. /**
  50244. * Instantiates a new scene instrumentation.
  50245. * This class can be used to get instrumentation data from a Babylon engine
  50246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50247. * @param scene Defines the scene to instrument
  50248. */
  50249. constructor(
  50250. /**
  50251. * Defines the scene to instrument
  50252. */
  50253. scene: Scene);
  50254. /**
  50255. * Dispose and release associated resources.
  50256. */
  50257. dispose(): void;
  50258. }
  50259. }
  50260. declare module "babylonjs/Instrumentation/index" {
  50261. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50262. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50263. export * from "babylonjs/Instrumentation/timeToken";
  50264. }
  50265. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50266. /** @hidden */
  50267. export var glowMapGenerationPixelShader: {
  50268. name: string;
  50269. shader: string;
  50270. };
  50271. }
  50272. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50273. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50274. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50275. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50276. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50277. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50278. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50279. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50280. /** @hidden */
  50281. export var glowMapGenerationVertexShader: {
  50282. name: string;
  50283. shader: string;
  50284. };
  50285. }
  50286. declare module "babylonjs/Layers/effectLayer" {
  50287. import { Observable } from "babylonjs/Misc/observable";
  50288. import { Nullable } from "babylonjs/types";
  50289. import { Camera } from "babylonjs/Cameras/camera";
  50290. import { Scene } from "babylonjs/scene";
  50291. import { ISize } from "babylonjs/Maths/math.size";
  50292. import { Color4 } from "babylonjs/Maths/math.color";
  50293. import { Engine } from "babylonjs/Engines/engine";
  50294. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50296. import { Mesh } from "babylonjs/Meshes/mesh";
  50297. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50300. import { Effect } from "babylonjs/Materials/effect";
  50301. import { Material } from "babylonjs/Materials/material";
  50302. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50303. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50304. /**
  50305. * Effect layer options. This helps customizing the behaviour
  50306. * of the effect layer.
  50307. */
  50308. export interface IEffectLayerOptions {
  50309. /**
  50310. * Multiplication factor apply to the canvas size to compute the render target size
  50311. * used to generated the objects (the smaller the faster).
  50312. */
  50313. mainTextureRatio: number;
  50314. /**
  50315. * Enforces a fixed size texture to ensure effect stability across devices.
  50316. */
  50317. mainTextureFixedSize?: number;
  50318. /**
  50319. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50320. */
  50321. alphaBlendingMode: number;
  50322. /**
  50323. * The camera attached to the layer.
  50324. */
  50325. camera: Nullable<Camera>;
  50326. /**
  50327. * The rendering group to draw the layer in.
  50328. */
  50329. renderingGroupId: number;
  50330. }
  50331. /**
  50332. * The effect layer Helps adding post process effect blended with the main pass.
  50333. *
  50334. * This can be for instance use to generate glow or higlight effects on the scene.
  50335. *
  50336. * The effect layer class can not be used directly and is intented to inherited from to be
  50337. * customized per effects.
  50338. */
  50339. export abstract class EffectLayer {
  50340. private _vertexBuffers;
  50341. private _indexBuffer;
  50342. private _cachedDefines;
  50343. private _effectLayerMapGenerationEffect;
  50344. private _effectLayerOptions;
  50345. private _mergeEffect;
  50346. protected _scene: Scene;
  50347. protected _engine: Engine;
  50348. protected _maxSize: number;
  50349. protected _mainTextureDesiredSize: ISize;
  50350. protected _mainTexture: RenderTargetTexture;
  50351. protected _shouldRender: boolean;
  50352. protected _postProcesses: PostProcess[];
  50353. protected _textures: BaseTexture[];
  50354. protected _emissiveTextureAndColor: {
  50355. texture: Nullable<BaseTexture>;
  50356. color: Color4;
  50357. };
  50358. /**
  50359. * The name of the layer
  50360. */
  50361. name: string;
  50362. /**
  50363. * The clear color of the texture used to generate the glow map.
  50364. */
  50365. neutralColor: Color4;
  50366. /**
  50367. * Specifies wether the highlight layer is enabled or not.
  50368. */
  50369. isEnabled: boolean;
  50370. /**
  50371. * Gets the camera attached to the layer.
  50372. */
  50373. readonly camera: Nullable<Camera>;
  50374. /**
  50375. * Gets the rendering group id the layer should render in.
  50376. */
  50377. renderingGroupId: number;
  50378. /**
  50379. * An event triggered when the effect layer has been disposed.
  50380. */
  50381. onDisposeObservable: Observable<EffectLayer>;
  50382. /**
  50383. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50384. */
  50385. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50386. /**
  50387. * An event triggered when the generated texture is being merged in the scene.
  50388. */
  50389. onBeforeComposeObservable: Observable<EffectLayer>;
  50390. /**
  50391. * An event triggered when the generated texture has been merged in the scene.
  50392. */
  50393. onAfterComposeObservable: Observable<EffectLayer>;
  50394. /**
  50395. * An event triggered when the efffect layer changes its size.
  50396. */
  50397. onSizeChangedObservable: Observable<EffectLayer>;
  50398. /** @hidden */
  50399. static _SceneComponentInitialization: (scene: Scene) => void;
  50400. /**
  50401. * Instantiates a new effect Layer and references it in the scene.
  50402. * @param name The name of the layer
  50403. * @param scene The scene to use the layer in
  50404. */
  50405. constructor(
  50406. /** The Friendly of the effect in the scene */
  50407. name: string, scene: Scene);
  50408. /**
  50409. * Get the effect name of the layer.
  50410. * @return The effect name
  50411. */
  50412. abstract getEffectName(): string;
  50413. /**
  50414. * Checks for the readiness of the element composing the layer.
  50415. * @param subMesh the mesh to check for
  50416. * @param useInstances specify wether or not to use instances to render the mesh
  50417. * @return true if ready otherwise, false
  50418. */
  50419. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50420. /**
  50421. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50422. * @returns true if the effect requires stencil during the main canvas render pass.
  50423. */
  50424. abstract needStencil(): boolean;
  50425. /**
  50426. * Create the merge effect. This is the shader use to blit the information back
  50427. * to the main canvas at the end of the scene rendering.
  50428. * @returns The effect containing the shader used to merge the effect on the main canvas
  50429. */
  50430. protected abstract _createMergeEffect(): Effect;
  50431. /**
  50432. * Creates the render target textures and post processes used in the effect layer.
  50433. */
  50434. protected abstract _createTextureAndPostProcesses(): void;
  50435. /**
  50436. * Implementation specific of rendering the generating effect on the main canvas.
  50437. * @param effect The effect used to render through
  50438. */
  50439. protected abstract _internalRender(effect: Effect): void;
  50440. /**
  50441. * Sets the required values for both the emissive texture and and the main color.
  50442. */
  50443. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50444. /**
  50445. * Free any resources and references associated to a mesh.
  50446. * Internal use
  50447. * @param mesh The mesh to free.
  50448. */
  50449. abstract _disposeMesh(mesh: Mesh): void;
  50450. /**
  50451. * Serializes this layer (Glow or Highlight for example)
  50452. * @returns a serialized layer object
  50453. */
  50454. abstract serialize?(): any;
  50455. /**
  50456. * Initializes the effect layer with the required options.
  50457. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50458. */
  50459. protected _init(options: Partial<IEffectLayerOptions>): void;
  50460. /**
  50461. * Generates the index buffer of the full screen quad blending to the main canvas.
  50462. */
  50463. private _generateIndexBuffer;
  50464. /**
  50465. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50466. */
  50467. private _generateVertexBuffer;
  50468. /**
  50469. * Sets the main texture desired size which is the closest power of two
  50470. * of the engine canvas size.
  50471. */
  50472. private _setMainTextureSize;
  50473. /**
  50474. * Creates the main texture for the effect layer.
  50475. */
  50476. protected _createMainTexture(): void;
  50477. /**
  50478. * Adds specific effects defines.
  50479. * @param defines The defines to add specifics to.
  50480. */
  50481. protected _addCustomEffectDefines(defines: string[]): void;
  50482. /**
  50483. * Checks for the readiness of the element composing the layer.
  50484. * @param subMesh the mesh to check for
  50485. * @param useInstances specify wether or not to use instances to render the mesh
  50486. * @param emissiveTexture the associated emissive texture used to generate the glow
  50487. * @return true if ready otherwise, false
  50488. */
  50489. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50490. /**
  50491. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50492. */
  50493. render(): void;
  50494. /**
  50495. * Determine if a given mesh will be used in the current effect.
  50496. * @param mesh mesh to test
  50497. * @returns true if the mesh will be used
  50498. */
  50499. hasMesh(mesh: AbstractMesh): boolean;
  50500. /**
  50501. * Returns true if the layer contains information to display, otherwise false.
  50502. * @returns true if the glow layer should be rendered
  50503. */
  50504. shouldRender(): boolean;
  50505. /**
  50506. * Returns true if the mesh should render, otherwise false.
  50507. * @param mesh The mesh to render
  50508. * @returns true if it should render otherwise false
  50509. */
  50510. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50511. /**
  50512. * Returns true if the mesh can be rendered, otherwise false.
  50513. * @param mesh The mesh to render
  50514. * @param material The material used on the mesh
  50515. * @returns true if it can be rendered otherwise false
  50516. */
  50517. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50518. /**
  50519. * Returns true if the mesh should render, otherwise false.
  50520. * @param mesh The mesh to render
  50521. * @returns true if it should render otherwise false
  50522. */
  50523. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50524. /**
  50525. * Renders the submesh passed in parameter to the generation map.
  50526. */
  50527. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50528. /**
  50529. * Rebuild the required buffers.
  50530. * @hidden Internal use only.
  50531. */
  50532. _rebuild(): void;
  50533. /**
  50534. * Dispose only the render target textures and post process.
  50535. */
  50536. private _disposeTextureAndPostProcesses;
  50537. /**
  50538. * Dispose the highlight layer and free resources.
  50539. */
  50540. dispose(): void;
  50541. /**
  50542. * Gets the class name of the effect layer
  50543. * @returns the string with the class name of the effect layer
  50544. */
  50545. getClassName(): string;
  50546. /**
  50547. * Creates an effect layer from parsed effect layer data
  50548. * @param parsedEffectLayer defines effect layer data
  50549. * @param scene defines the current scene
  50550. * @param rootUrl defines the root URL containing the effect layer information
  50551. * @returns a parsed effect Layer
  50552. */
  50553. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50554. }
  50555. }
  50556. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50557. import { Scene } from "babylonjs/scene";
  50558. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50559. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50560. import { AbstractScene } from "babylonjs/abstractScene";
  50561. module "babylonjs/abstractScene" {
  50562. interface AbstractScene {
  50563. /**
  50564. * The list of effect layers (highlights/glow) added to the scene
  50565. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50566. * @see http://doc.babylonjs.com/how_to/glow_layer
  50567. */
  50568. effectLayers: Array<EffectLayer>;
  50569. /**
  50570. * Removes the given effect layer from this scene.
  50571. * @param toRemove defines the effect layer to remove
  50572. * @returns the index of the removed effect layer
  50573. */
  50574. removeEffectLayer(toRemove: EffectLayer): number;
  50575. /**
  50576. * Adds the given effect layer to this scene
  50577. * @param newEffectLayer defines the effect layer to add
  50578. */
  50579. addEffectLayer(newEffectLayer: EffectLayer): void;
  50580. }
  50581. }
  50582. /**
  50583. * Defines the layer scene component responsible to manage any effect layers
  50584. * in a given scene.
  50585. */
  50586. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50587. /**
  50588. * The component name helpfull to identify the component in the list of scene components.
  50589. */
  50590. readonly name: string;
  50591. /**
  50592. * The scene the component belongs to.
  50593. */
  50594. scene: Scene;
  50595. private _engine;
  50596. private _renderEffects;
  50597. private _needStencil;
  50598. private _previousStencilState;
  50599. /**
  50600. * Creates a new instance of the component for the given scene
  50601. * @param scene Defines the scene to register the component in
  50602. */
  50603. constructor(scene: Scene);
  50604. /**
  50605. * Registers the component in a given scene
  50606. */
  50607. register(): void;
  50608. /**
  50609. * Rebuilds the elements related to this component in case of
  50610. * context lost for instance.
  50611. */
  50612. rebuild(): void;
  50613. /**
  50614. * Serializes the component data to the specified json object
  50615. * @param serializationObject The object to serialize to
  50616. */
  50617. serialize(serializationObject: any): void;
  50618. /**
  50619. * Adds all the elements from the container to the scene
  50620. * @param container the container holding the elements
  50621. */
  50622. addFromContainer(container: AbstractScene): void;
  50623. /**
  50624. * Removes all the elements in the container from the scene
  50625. * @param container contains the elements to remove
  50626. * @param dispose if the removed element should be disposed (default: false)
  50627. */
  50628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50629. /**
  50630. * Disposes the component and the associated ressources.
  50631. */
  50632. dispose(): void;
  50633. private _isReadyForMesh;
  50634. private _renderMainTexture;
  50635. private _setStencil;
  50636. private _setStencilBack;
  50637. private _draw;
  50638. private _drawCamera;
  50639. private _drawRenderingGroup;
  50640. }
  50641. }
  50642. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50643. /** @hidden */
  50644. export var glowMapMergePixelShader: {
  50645. name: string;
  50646. shader: string;
  50647. };
  50648. }
  50649. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50650. /** @hidden */
  50651. export var glowMapMergeVertexShader: {
  50652. name: string;
  50653. shader: string;
  50654. };
  50655. }
  50656. declare module "babylonjs/Layers/glowLayer" {
  50657. import { Nullable } from "babylonjs/types";
  50658. import { Camera } from "babylonjs/Cameras/camera";
  50659. import { Scene } from "babylonjs/scene";
  50660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50662. import { Mesh } from "babylonjs/Meshes/mesh";
  50663. import { Texture } from "babylonjs/Materials/Textures/texture";
  50664. import { Effect } from "babylonjs/Materials/effect";
  50665. import { Material } from "babylonjs/Materials/material";
  50666. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50667. import { Color4 } from "babylonjs/Maths/math.color";
  50668. import "babylonjs/Shaders/glowMapMerge.fragment";
  50669. import "babylonjs/Shaders/glowMapMerge.vertex";
  50670. import "babylonjs/Layers/effectLayerSceneComponent";
  50671. module "babylonjs/abstractScene" {
  50672. interface AbstractScene {
  50673. /**
  50674. * Return a the first highlight layer of the scene with a given name.
  50675. * @param name The name of the highlight layer to look for.
  50676. * @return The highlight layer if found otherwise null.
  50677. */
  50678. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50679. }
  50680. }
  50681. /**
  50682. * Glow layer options. This helps customizing the behaviour
  50683. * of the glow layer.
  50684. */
  50685. export interface IGlowLayerOptions {
  50686. /**
  50687. * Multiplication factor apply to the canvas size to compute the render target size
  50688. * used to generated the glowing objects (the smaller the faster).
  50689. */
  50690. mainTextureRatio: number;
  50691. /**
  50692. * Enforces a fixed size texture to ensure resize independant blur.
  50693. */
  50694. mainTextureFixedSize?: number;
  50695. /**
  50696. * How big is the kernel of the blur texture.
  50697. */
  50698. blurKernelSize: number;
  50699. /**
  50700. * The camera attached to the layer.
  50701. */
  50702. camera: Nullable<Camera>;
  50703. /**
  50704. * Enable MSAA by chosing the number of samples.
  50705. */
  50706. mainTextureSamples?: number;
  50707. /**
  50708. * The rendering group to draw the layer in.
  50709. */
  50710. renderingGroupId: number;
  50711. }
  50712. /**
  50713. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50714. *
  50715. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50716. * glowy meshes to your scene.
  50717. *
  50718. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50719. */
  50720. export class GlowLayer extends EffectLayer {
  50721. /**
  50722. * Effect Name of the layer.
  50723. */
  50724. static readonly EffectName: string;
  50725. /**
  50726. * The default blur kernel size used for the glow.
  50727. */
  50728. static DefaultBlurKernelSize: number;
  50729. /**
  50730. * The default texture size ratio used for the glow.
  50731. */
  50732. static DefaultTextureRatio: number;
  50733. /**
  50734. * Sets the kernel size of the blur.
  50735. */
  50736. /**
  50737. * Gets the kernel size of the blur.
  50738. */
  50739. blurKernelSize: number;
  50740. /**
  50741. * Sets the glow intensity.
  50742. */
  50743. /**
  50744. * Gets the glow intensity.
  50745. */
  50746. intensity: number;
  50747. private _options;
  50748. private _intensity;
  50749. private _horizontalBlurPostprocess1;
  50750. private _verticalBlurPostprocess1;
  50751. private _horizontalBlurPostprocess2;
  50752. private _verticalBlurPostprocess2;
  50753. private _blurTexture1;
  50754. private _blurTexture2;
  50755. private _postProcesses1;
  50756. private _postProcesses2;
  50757. private _includedOnlyMeshes;
  50758. private _excludedMeshes;
  50759. /**
  50760. * Callback used to let the user override the color selection on a per mesh basis
  50761. */
  50762. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50763. /**
  50764. * Callback used to let the user override the texture selection on a per mesh basis
  50765. */
  50766. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50767. /**
  50768. * Instantiates a new glow Layer and references it to the scene.
  50769. * @param name The name of the layer
  50770. * @param scene The scene to use the layer in
  50771. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50772. */
  50773. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50774. /**
  50775. * Get the effect name of the layer.
  50776. * @return The effect name
  50777. */
  50778. getEffectName(): string;
  50779. /**
  50780. * Create the merge effect. This is the shader use to blit the information back
  50781. * to the main canvas at the end of the scene rendering.
  50782. */
  50783. protected _createMergeEffect(): Effect;
  50784. /**
  50785. * Creates the render target textures and post processes used in the glow layer.
  50786. */
  50787. protected _createTextureAndPostProcesses(): void;
  50788. /**
  50789. * Checks for the readiness of the element composing the layer.
  50790. * @param subMesh the mesh to check for
  50791. * @param useInstances specify wether or not to use instances to render the mesh
  50792. * @param emissiveTexture the associated emissive texture used to generate the glow
  50793. * @return true if ready otherwise, false
  50794. */
  50795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50796. /**
  50797. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50798. */
  50799. needStencil(): boolean;
  50800. /**
  50801. * Returns true if the mesh can be rendered, otherwise false.
  50802. * @param mesh The mesh to render
  50803. * @param material The material used on the mesh
  50804. * @returns true if it can be rendered otherwise false
  50805. */
  50806. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50807. /**
  50808. * Implementation specific of rendering the generating effect on the main canvas.
  50809. * @param effect The effect used to render through
  50810. */
  50811. protected _internalRender(effect: Effect): void;
  50812. /**
  50813. * Sets the required values for both the emissive texture and and the main color.
  50814. */
  50815. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50816. /**
  50817. * Returns true if the mesh should render, otherwise false.
  50818. * @param mesh The mesh to render
  50819. * @returns true if it should render otherwise false
  50820. */
  50821. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50822. /**
  50823. * Adds specific effects defines.
  50824. * @param defines The defines to add specifics to.
  50825. */
  50826. protected _addCustomEffectDefines(defines: string[]): void;
  50827. /**
  50828. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50829. * @param mesh The mesh to exclude from the glow layer
  50830. */
  50831. addExcludedMesh(mesh: Mesh): void;
  50832. /**
  50833. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50834. * @param mesh The mesh to remove
  50835. */
  50836. removeExcludedMesh(mesh: Mesh): void;
  50837. /**
  50838. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50839. * @param mesh The mesh to include in the glow layer
  50840. */
  50841. addIncludedOnlyMesh(mesh: Mesh): void;
  50842. /**
  50843. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50844. * @param mesh The mesh to remove
  50845. */
  50846. removeIncludedOnlyMesh(mesh: Mesh): void;
  50847. /**
  50848. * Determine if a given mesh will be used in the glow layer
  50849. * @param mesh The mesh to test
  50850. * @returns true if the mesh will be highlighted by the current glow layer
  50851. */
  50852. hasMesh(mesh: AbstractMesh): boolean;
  50853. /**
  50854. * Free any resources and references associated to a mesh.
  50855. * Internal use
  50856. * @param mesh The mesh to free.
  50857. * @hidden
  50858. */
  50859. _disposeMesh(mesh: Mesh): void;
  50860. /**
  50861. * Gets the class name of the effect layer
  50862. * @returns the string with the class name of the effect layer
  50863. */
  50864. getClassName(): string;
  50865. /**
  50866. * Serializes this glow layer
  50867. * @returns a serialized glow layer object
  50868. */
  50869. serialize(): any;
  50870. /**
  50871. * Creates a Glow Layer from parsed glow layer data
  50872. * @param parsedGlowLayer defines glow layer data
  50873. * @param scene defines the current scene
  50874. * @param rootUrl defines the root URL containing the glow layer information
  50875. * @returns a parsed Glow Layer
  50876. */
  50877. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50878. }
  50879. }
  50880. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50881. /** @hidden */
  50882. export var glowBlurPostProcessPixelShader: {
  50883. name: string;
  50884. shader: string;
  50885. };
  50886. }
  50887. declare module "babylonjs/Layers/highlightLayer" {
  50888. import { Observable } from "babylonjs/Misc/observable";
  50889. import { Nullable } from "babylonjs/types";
  50890. import { Camera } from "babylonjs/Cameras/camera";
  50891. import { Scene } from "babylonjs/scene";
  50892. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50894. import { Mesh } from "babylonjs/Meshes/mesh";
  50895. import { Effect } from "babylonjs/Materials/effect";
  50896. import { Material } from "babylonjs/Materials/material";
  50897. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50898. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50899. import "babylonjs/Shaders/glowMapMerge.fragment";
  50900. import "babylonjs/Shaders/glowMapMerge.vertex";
  50901. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50902. module "babylonjs/abstractScene" {
  50903. interface AbstractScene {
  50904. /**
  50905. * Return a the first highlight layer of the scene with a given name.
  50906. * @param name The name of the highlight layer to look for.
  50907. * @return The highlight layer if found otherwise null.
  50908. */
  50909. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50910. }
  50911. }
  50912. /**
  50913. * Highlight layer options. This helps customizing the behaviour
  50914. * of the highlight layer.
  50915. */
  50916. export interface IHighlightLayerOptions {
  50917. /**
  50918. * Multiplication factor apply to the canvas size to compute the render target size
  50919. * used to generated the glowing objects (the smaller the faster).
  50920. */
  50921. mainTextureRatio: number;
  50922. /**
  50923. * Enforces a fixed size texture to ensure resize independant blur.
  50924. */
  50925. mainTextureFixedSize?: number;
  50926. /**
  50927. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50928. * of the picture to blur (the smaller the faster).
  50929. */
  50930. blurTextureSizeRatio: number;
  50931. /**
  50932. * How big in texel of the blur texture is the vertical blur.
  50933. */
  50934. blurVerticalSize: number;
  50935. /**
  50936. * How big in texel of the blur texture is the horizontal blur.
  50937. */
  50938. blurHorizontalSize: number;
  50939. /**
  50940. * Alpha blending mode used to apply the blur. Default is combine.
  50941. */
  50942. alphaBlendingMode: number;
  50943. /**
  50944. * The camera attached to the layer.
  50945. */
  50946. camera: Nullable<Camera>;
  50947. /**
  50948. * Should we display highlight as a solid stroke?
  50949. */
  50950. isStroke?: boolean;
  50951. /**
  50952. * The rendering group to draw the layer in.
  50953. */
  50954. renderingGroupId: number;
  50955. }
  50956. /**
  50957. * The highlight layer Helps adding a glow effect around a mesh.
  50958. *
  50959. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50960. * glowy meshes to your scene.
  50961. *
  50962. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50963. */
  50964. export class HighlightLayer extends EffectLayer {
  50965. name: string;
  50966. /**
  50967. * Effect Name of the highlight layer.
  50968. */
  50969. static readonly EffectName: string;
  50970. /**
  50971. * The neutral color used during the preparation of the glow effect.
  50972. * This is black by default as the blend operation is a blend operation.
  50973. */
  50974. static NeutralColor: Color4;
  50975. /**
  50976. * Stencil value used for glowing meshes.
  50977. */
  50978. static GlowingMeshStencilReference: number;
  50979. /**
  50980. * Stencil value used for the other meshes in the scene.
  50981. */
  50982. static NormalMeshStencilReference: number;
  50983. /**
  50984. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50985. */
  50986. innerGlow: boolean;
  50987. /**
  50988. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50989. */
  50990. outerGlow: boolean;
  50991. /**
  50992. * Specifies the horizontal size of the blur.
  50993. */
  50994. /**
  50995. * Gets the horizontal size of the blur.
  50996. */
  50997. blurHorizontalSize: number;
  50998. /**
  50999. * Specifies the vertical size of the blur.
  51000. */
  51001. /**
  51002. * Gets the vertical size of the blur.
  51003. */
  51004. blurVerticalSize: number;
  51005. /**
  51006. * An event triggered when the highlight layer is being blurred.
  51007. */
  51008. onBeforeBlurObservable: Observable<HighlightLayer>;
  51009. /**
  51010. * An event triggered when the highlight layer has been blurred.
  51011. */
  51012. onAfterBlurObservable: Observable<HighlightLayer>;
  51013. private _instanceGlowingMeshStencilReference;
  51014. private _options;
  51015. private _downSamplePostprocess;
  51016. private _horizontalBlurPostprocess;
  51017. private _verticalBlurPostprocess;
  51018. private _blurTexture;
  51019. private _meshes;
  51020. private _excludedMeshes;
  51021. /**
  51022. * Instantiates a new highlight Layer and references it to the scene..
  51023. * @param name The name of the layer
  51024. * @param scene The scene to use the layer in
  51025. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51026. */
  51027. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51028. /**
  51029. * Get the effect name of the layer.
  51030. * @return The effect name
  51031. */
  51032. getEffectName(): string;
  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. */
  51037. protected _createMergeEffect(): Effect;
  51038. /**
  51039. * Creates the render target textures and post processes used in the highlight layer.
  51040. */
  51041. protected _createTextureAndPostProcesses(): void;
  51042. /**
  51043. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51044. */
  51045. needStencil(): boolean;
  51046. /**
  51047. * Checks for the readiness of the element composing the layer.
  51048. * @param subMesh the mesh to check for
  51049. * @param useInstances specify wether or not to use instances to render the mesh
  51050. * @param emissiveTexture the associated emissive texture used to generate the glow
  51051. * @return true if ready otherwise, false
  51052. */
  51053. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51054. /**
  51055. * Implementation specific of rendering the generating effect on the main canvas.
  51056. * @param effect The effect used to render through
  51057. */
  51058. protected _internalRender(effect: Effect): void;
  51059. /**
  51060. * Returns true if the layer contains information to display, otherwise false.
  51061. */
  51062. shouldRender(): boolean;
  51063. /**
  51064. * Returns true if the mesh should render, otherwise false.
  51065. * @param mesh The mesh to render
  51066. * @returns true if it should render otherwise false
  51067. */
  51068. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51069. /**
  51070. * Sets the required values for both the emissive texture and and the main color.
  51071. */
  51072. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51073. /**
  51074. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51075. * @param mesh The mesh to exclude from the highlight layer
  51076. */
  51077. addExcludedMesh(mesh: Mesh): void;
  51078. /**
  51079. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51080. * @param mesh The mesh to highlight
  51081. */
  51082. removeExcludedMesh(mesh: Mesh): void;
  51083. /**
  51084. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51085. * @param mesh mesh to test
  51086. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51087. */
  51088. hasMesh(mesh: AbstractMesh): boolean;
  51089. /**
  51090. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51091. * @param mesh The mesh to highlight
  51092. * @param color The color of the highlight
  51093. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51094. */
  51095. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51096. /**
  51097. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51098. * @param mesh The mesh to highlight
  51099. */
  51100. removeMesh(mesh: Mesh): void;
  51101. /**
  51102. * Force the stencil to the normal expected value for none glowing parts
  51103. */
  51104. private _defaultStencilReference;
  51105. /**
  51106. * Free any resources and references associated to a mesh.
  51107. * Internal use
  51108. * @param mesh The mesh to free.
  51109. * @hidden
  51110. */
  51111. _disposeMesh(mesh: Mesh): void;
  51112. /**
  51113. * Dispose the highlight layer and free resources.
  51114. */
  51115. dispose(): void;
  51116. /**
  51117. * Gets the class name of the effect layer
  51118. * @returns the string with the class name of the effect layer
  51119. */
  51120. getClassName(): string;
  51121. /**
  51122. * Serializes this Highlight layer
  51123. * @returns a serialized Highlight layer object
  51124. */
  51125. serialize(): any;
  51126. /**
  51127. * Creates a Highlight layer from parsed Highlight layer data
  51128. * @param parsedHightlightLayer defines the Highlight layer data
  51129. * @param scene defines the current scene
  51130. * @param rootUrl defines the root URL containing the Highlight layer information
  51131. * @returns a parsed Highlight layer
  51132. */
  51133. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51134. }
  51135. }
  51136. declare module "babylonjs/Layers/layerSceneComponent" {
  51137. import { Scene } from "babylonjs/scene";
  51138. import { ISceneComponent } from "babylonjs/sceneComponent";
  51139. import { Layer } from "babylonjs/Layers/layer";
  51140. import { AbstractScene } from "babylonjs/abstractScene";
  51141. module "babylonjs/abstractScene" {
  51142. interface AbstractScene {
  51143. /**
  51144. * The list of layers (background and foreground) of the scene
  51145. */
  51146. layers: Array<Layer>;
  51147. }
  51148. }
  51149. /**
  51150. * Defines the layer scene component responsible to manage any layers
  51151. * in a given scene.
  51152. */
  51153. export class LayerSceneComponent implements ISceneComponent {
  51154. /**
  51155. * The component name helpfull to identify the component in the list of scene components.
  51156. */
  51157. readonly name: string;
  51158. /**
  51159. * The scene the component belongs to.
  51160. */
  51161. scene: Scene;
  51162. private _engine;
  51163. /**
  51164. * Creates a new instance of the component for the given scene
  51165. * @param scene Defines the scene to register the component in
  51166. */
  51167. constructor(scene: Scene);
  51168. /**
  51169. * Registers the component in a given scene
  51170. */
  51171. register(): void;
  51172. /**
  51173. * Rebuilds the elements related to this component in case of
  51174. * context lost for instance.
  51175. */
  51176. rebuild(): void;
  51177. /**
  51178. * Disposes the component and the associated ressources.
  51179. */
  51180. dispose(): void;
  51181. private _draw;
  51182. private _drawCameraPredicate;
  51183. private _drawCameraBackground;
  51184. private _drawCameraForeground;
  51185. private _drawRenderTargetPredicate;
  51186. private _drawRenderTargetBackground;
  51187. private _drawRenderTargetForeground;
  51188. /**
  51189. * Adds all the elements from the container to the scene
  51190. * @param container the container holding the elements
  51191. */
  51192. addFromContainer(container: AbstractScene): void;
  51193. /**
  51194. * Removes all the elements in the container from the scene
  51195. * @param container contains the elements to remove
  51196. * @param dispose if the removed element should be disposed (default: false)
  51197. */
  51198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51199. }
  51200. }
  51201. declare module "babylonjs/Shaders/layer.fragment" {
  51202. /** @hidden */
  51203. export var layerPixelShader: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module "babylonjs/Shaders/layer.vertex" {
  51209. /** @hidden */
  51210. export var layerVertexShader: {
  51211. name: string;
  51212. shader: string;
  51213. };
  51214. }
  51215. declare module "babylonjs/Layers/layer" {
  51216. import { Observable } from "babylonjs/Misc/observable";
  51217. import { Nullable } from "babylonjs/types";
  51218. import { Scene } from "babylonjs/scene";
  51219. import { Vector2 } from "babylonjs/Maths/math.vector";
  51220. import { Color4 } from "babylonjs/Maths/math.color";
  51221. import { Texture } from "babylonjs/Materials/Textures/texture";
  51222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51223. import "babylonjs/Shaders/layer.fragment";
  51224. import "babylonjs/Shaders/layer.vertex";
  51225. /**
  51226. * This represents a full screen 2d layer.
  51227. * This can be useful to display a picture in the background of your scene for instance.
  51228. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51229. */
  51230. export class Layer {
  51231. /**
  51232. * Define the name of the layer.
  51233. */
  51234. name: string;
  51235. /**
  51236. * Define the texture the layer should display.
  51237. */
  51238. texture: Nullable<Texture>;
  51239. /**
  51240. * Is the layer in background or foreground.
  51241. */
  51242. isBackground: boolean;
  51243. /**
  51244. * Define the color of the layer (instead of texture).
  51245. */
  51246. color: Color4;
  51247. /**
  51248. * Define the scale of the layer in order to zoom in out of the texture.
  51249. */
  51250. scale: Vector2;
  51251. /**
  51252. * Define an offset for the layer in order to shift the texture.
  51253. */
  51254. offset: Vector2;
  51255. /**
  51256. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51257. */
  51258. alphaBlendingMode: number;
  51259. /**
  51260. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51261. * Alpha test will not mix with the background color in case of transparency.
  51262. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51263. */
  51264. alphaTest: boolean;
  51265. /**
  51266. * Define a mask to restrict the layer to only some of the scene cameras.
  51267. */
  51268. layerMask: number;
  51269. /**
  51270. * Define the list of render target the layer is visible into.
  51271. */
  51272. renderTargetTextures: RenderTargetTexture[];
  51273. /**
  51274. * Define if the layer is only used in renderTarget or if it also
  51275. * renders in the main frame buffer of the canvas.
  51276. */
  51277. renderOnlyInRenderTargetTextures: boolean;
  51278. private _scene;
  51279. private _vertexBuffers;
  51280. private _indexBuffer;
  51281. private _effect;
  51282. private _alphaTestEffect;
  51283. /**
  51284. * An event triggered when the layer is disposed.
  51285. */
  51286. onDisposeObservable: Observable<Layer>;
  51287. private _onDisposeObserver;
  51288. /**
  51289. * Back compatibility with callback before the onDisposeObservable existed.
  51290. * The set callback will be triggered when the layer has been disposed.
  51291. */
  51292. onDispose: () => void;
  51293. /**
  51294. * An event triggered before rendering the scene
  51295. */
  51296. onBeforeRenderObservable: Observable<Layer>;
  51297. private _onBeforeRenderObserver;
  51298. /**
  51299. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51300. * The set callback will be triggered just before rendering the layer.
  51301. */
  51302. onBeforeRender: () => void;
  51303. /**
  51304. * An event triggered after rendering the scene
  51305. */
  51306. onAfterRenderObservable: Observable<Layer>;
  51307. private _onAfterRenderObserver;
  51308. /**
  51309. * Back compatibility with callback before the onAfterRenderObservable existed.
  51310. * The set callback will be triggered just after rendering the layer.
  51311. */
  51312. onAfterRender: () => void;
  51313. /**
  51314. * Instantiates a new layer.
  51315. * This represents a full screen 2d layer.
  51316. * This can be useful to display a picture in the background of your scene for instance.
  51317. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51318. * @param name Define the name of the layer in the scene
  51319. * @param imgUrl Define the url of the texture to display in the layer
  51320. * @param scene Define the scene the layer belongs to
  51321. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51322. * @param color Defines a color for the layer
  51323. */
  51324. constructor(
  51325. /**
  51326. * Define the name of the layer.
  51327. */
  51328. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51329. private _createIndexBuffer;
  51330. /** @hidden */
  51331. _rebuild(): void;
  51332. /**
  51333. * Renders the layer in the scene.
  51334. */
  51335. render(): void;
  51336. /**
  51337. * Disposes and releases the associated ressources.
  51338. */
  51339. dispose(): void;
  51340. }
  51341. }
  51342. declare module "babylonjs/Layers/index" {
  51343. export * from "babylonjs/Layers/effectLayer";
  51344. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51345. export * from "babylonjs/Layers/glowLayer";
  51346. export * from "babylonjs/Layers/highlightLayer";
  51347. export * from "babylonjs/Layers/layer";
  51348. export * from "babylonjs/Layers/layerSceneComponent";
  51349. }
  51350. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51351. /** @hidden */
  51352. export var lensFlarePixelShader: {
  51353. name: string;
  51354. shader: string;
  51355. };
  51356. }
  51357. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51358. /** @hidden */
  51359. export var lensFlareVertexShader: {
  51360. name: string;
  51361. shader: string;
  51362. };
  51363. }
  51364. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51365. import { Scene } from "babylonjs/scene";
  51366. import { Vector3 } from "babylonjs/Maths/math.vector";
  51367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51368. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51369. import "babylonjs/Shaders/lensFlare.fragment";
  51370. import "babylonjs/Shaders/lensFlare.vertex";
  51371. import { Viewport } from "babylonjs/Maths/math.viewport";
  51372. /**
  51373. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51374. * It is usually composed of several `lensFlare`.
  51375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51376. */
  51377. export class LensFlareSystem {
  51378. /**
  51379. * Define the name of the lens flare system
  51380. */
  51381. name: string;
  51382. /**
  51383. * List of lens flares used in this system.
  51384. */
  51385. lensFlares: LensFlare[];
  51386. /**
  51387. * Define a limit from the border the lens flare can be visible.
  51388. */
  51389. borderLimit: number;
  51390. /**
  51391. * Define a viewport border we do not want to see the lens flare in.
  51392. */
  51393. viewportBorder: number;
  51394. /**
  51395. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51396. */
  51397. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51398. /**
  51399. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51400. */
  51401. layerMask: number;
  51402. /**
  51403. * Define the id of the lens flare system in the scene.
  51404. * (equal to name by default)
  51405. */
  51406. id: string;
  51407. private _scene;
  51408. private _emitter;
  51409. private _vertexBuffers;
  51410. private _indexBuffer;
  51411. private _effect;
  51412. private _positionX;
  51413. private _positionY;
  51414. private _isEnabled;
  51415. /** @hidden */
  51416. static _SceneComponentInitialization: (scene: Scene) => void;
  51417. /**
  51418. * Instantiates a lens flare system.
  51419. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51420. * It is usually composed of several `lensFlare`.
  51421. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51422. * @param name Define the name of the lens flare system in the scene
  51423. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51424. * @param scene Define the scene the lens flare system belongs to
  51425. */
  51426. constructor(
  51427. /**
  51428. * Define the name of the lens flare system
  51429. */
  51430. name: string, emitter: any, scene: Scene);
  51431. /**
  51432. * Define if the lens flare system is enabled.
  51433. */
  51434. isEnabled: boolean;
  51435. /**
  51436. * Get the scene the effects belongs to.
  51437. * @returns the scene holding the lens flare system
  51438. */
  51439. getScene(): Scene;
  51440. /**
  51441. * Get the emitter of the lens flare system.
  51442. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51443. * @returns the emitter of the lens flare system
  51444. */
  51445. getEmitter(): any;
  51446. /**
  51447. * Set the emitter of the lens flare system.
  51448. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51449. * @param newEmitter Define the new emitter of the system
  51450. */
  51451. setEmitter(newEmitter: any): void;
  51452. /**
  51453. * Get the lens flare system emitter position.
  51454. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51455. * @returns the position
  51456. */
  51457. getEmitterPosition(): Vector3;
  51458. /**
  51459. * @hidden
  51460. */
  51461. computeEffectivePosition(globalViewport: Viewport): boolean;
  51462. /** @hidden */
  51463. _isVisible(): boolean;
  51464. /**
  51465. * @hidden
  51466. */
  51467. render(): boolean;
  51468. /**
  51469. * Dispose and release the lens flare with its associated resources.
  51470. */
  51471. dispose(): void;
  51472. /**
  51473. * Parse a lens flare system from a JSON repressentation
  51474. * @param parsedLensFlareSystem Define the JSON to parse
  51475. * @param scene Define the scene the parsed system should be instantiated in
  51476. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51477. * @returns the parsed system
  51478. */
  51479. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51480. /**
  51481. * Serialize the current Lens Flare System into a JSON representation.
  51482. * @returns the serialized JSON
  51483. */
  51484. serialize(): any;
  51485. }
  51486. }
  51487. declare module "babylonjs/LensFlares/lensFlare" {
  51488. import { Nullable } from "babylonjs/types";
  51489. import { Color3 } from "babylonjs/Maths/math.color";
  51490. import { Texture } from "babylonjs/Materials/Textures/texture";
  51491. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51492. /**
  51493. * This represents one of the lens effect in a `lensFlareSystem`.
  51494. * It controls one of the indiviual texture used in the effect.
  51495. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51496. */
  51497. export class LensFlare {
  51498. /**
  51499. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51500. */
  51501. size: number;
  51502. /**
  51503. * 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.
  51504. */
  51505. position: number;
  51506. /**
  51507. * Define the lens color.
  51508. */
  51509. color: Color3;
  51510. /**
  51511. * Define the lens texture.
  51512. */
  51513. texture: Nullable<Texture>;
  51514. /**
  51515. * Define the alpha mode to render this particular lens.
  51516. */
  51517. alphaMode: number;
  51518. private _system;
  51519. /**
  51520. * Creates a new Lens Flare.
  51521. * This represents one of the lens effect in a `lensFlareSystem`.
  51522. * It controls one of the indiviual texture used in the effect.
  51523. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51524. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51525. * @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.
  51526. * @param color Define the lens color
  51527. * @param imgUrl Define the lens texture url
  51528. * @param system Define the `lensFlareSystem` this flare is part of
  51529. * @returns The newly created Lens Flare
  51530. */
  51531. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51532. /**
  51533. * Instantiates a new Lens Flare.
  51534. * This represents one of the lens effect in a `lensFlareSystem`.
  51535. * It controls one of the indiviual texture used in the effect.
  51536. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51537. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51538. * @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.
  51539. * @param color Define the lens color
  51540. * @param imgUrl Define the lens texture url
  51541. * @param system Define the `lensFlareSystem` this flare is part of
  51542. */
  51543. constructor(
  51544. /**
  51545. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51546. */
  51547. size: number,
  51548. /**
  51549. * 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.
  51550. */
  51551. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51552. /**
  51553. * Dispose and release the lens flare with its associated resources.
  51554. */
  51555. dispose(): void;
  51556. }
  51557. }
  51558. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51559. import { Nullable } from "babylonjs/types";
  51560. import { Scene } from "babylonjs/scene";
  51561. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51562. import { AbstractScene } from "babylonjs/abstractScene";
  51563. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51564. module "babylonjs/abstractScene" {
  51565. interface AbstractScene {
  51566. /**
  51567. * The list of lens flare system added to the scene
  51568. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51569. */
  51570. lensFlareSystems: Array<LensFlareSystem>;
  51571. /**
  51572. * Removes the given lens flare system from this scene.
  51573. * @param toRemove The lens flare system to remove
  51574. * @returns The index of the removed lens flare system
  51575. */
  51576. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51577. /**
  51578. * Adds the given lens flare system to this scene
  51579. * @param newLensFlareSystem The lens flare system to add
  51580. */
  51581. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51582. /**
  51583. * Gets a lens flare system using its name
  51584. * @param name defines the name to look for
  51585. * @returns the lens flare system or null if not found
  51586. */
  51587. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51588. /**
  51589. * Gets a lens flare system using its id
  51590. * @param id defines the id to look for
  51591. * @returns the lens flare system or null if not found
  51592. */
  51593. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51594. }
  51595. }
  51596. /**
  51597. * Defines the lens flare scene component responsible to manage any lens flares
  51598. * in a given scene.
  51599. */
  51600. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51601. /**
  51602. * The component name helpfull to identify the component in the list of scene components.
  51603. */
  51604. readonly name: string;
  51605. /**
  51606. * The scene the component belongs to.
  51607. */
  51608. scene: Scene;
  51609. /**
  51610. * Creates a new instance of the component for the given scene
  51611. * @param scene Defines the scene to register the component in
  51612. */
  51613. constructor(scene: Scene);
  51614. /**
  51615. * Registers the component in a given scene
  51616. */
  51617. register(): void;
  51618. /**
  51619. * Rebuilds the elements related to this component in case of
  51620. * context lost for instance.
  51621. */
  51622. rebuild(): void;
  51623. /**
  51624. * Adds all the elements from the container to the scene
  51625. * @param container the container holding the elements
  51626. */
  51627. addFromContainer(container: AbstractScene): void;
  51628. /**
  51629. * Removes all the elements in the container from the scene
  51630. * @param container contains the elements to remove
  51631. * @param dispose if the removed element should be disposed (default: false)
  51632. */
  51633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51634. /**
  51635. * Serializes the component data to the specified json object
  51636. * @param serializationObject The object to serialize to
  51637. */
  51638. serialize(serializationObject: any): void;
  51639. /**
  51640. * Disposes the component and the associated ressources.
  51641. */
  51642. dispose(): void;
  51643. private _draw;
  51644. }
  51645. }
  51646. declare module "babylonjs/LensFlares/index" {
  51647. export * from "babylonjs/LensFlares/lensFlare";
  51648. export * from "babylonjs/LensFlares/lensFlareSystem";
  51649. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51650. }
  51651. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51652. import { Scene } from "babylonjs/scene";
  51653. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51654. import { AbstractScene } from "babylonjs/abstractScene";
  51655. /**
  51656. * Defines the shadow generator component responsible to manage any shadow generators
  51657. * in a given scene.
  51658. */
  51659. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51660. /**
  51661. * The component name helpfull to identify the component in the list of scene components.
  51662. */
  51663. readonly name: string;
  51664. /**
  51665. * The scene the component belongs to.
  51666. */
  51667. scene: Scene;
  51668. /**
  51669. * Creates a new instance of the component for the given scene
  51670. * @param scene Defines the scene to register the component in
  51671. */
  51672. constructor(scene: Scene);
  51673. /**
  51674. * Registers the component in a given scene
  51675. */
  51676. register(): void;
  51677. /**
  51678. * Rebuilds the elements related to this component in case of
  51679. * context lost for instance.
  51680. */
  51681. rebuild(): void;
  51682. /**
  51683. * Serializes the component data to the specified json object
  51684. * @param serializationObject The object to serialize to
  51685. */
  51686. serialize(serializationObject: any): void;
  51687. /**
  51688. * Adds all the elements from the container to the scene
  51689. * @param container the container holding the elements
  51690. */
  51691. addFromContainer(container: AbstractScene): void;
  51692. /**
  51693. * Removes all the elements in the container from the scene
  51694. * @param container contains the elements to remove
  51695. * @param dispose if the removed element should be disposed (default: false)
  51696. */
  51697. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51698. /**
  51699. * Rebuilds the elements related to this component in case of
  51700. * context lost for instance.
  51701. */
  51702. dispose(): void;
  51703. private _gatherRenderTargets;
  51704. }
  51705. }
  51706. declare module "babylonjs/Lights/Shadows/index" {
  51707. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51708. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51709. }
  51710. declare module "babylonjs/Lights/pointLight" {
  51711. import { Scene } from "babylonjs/scene";
  51712. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51714. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51715. import { Effect } from "babylonjs/Materials/effect";
  51716. /**
  51717. * A point light is a light defined by an unique point in world space.
  51718. * The light is emitted in every direction from this point.
  51719. * A good example of a point light is a standard light bulb.
  51720. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51721. */
  51722. export class PointLight extends ShadowLight {
  51723. private _shadowAngle;
  51724. /**
  51725. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51726. * This specifies what angle the shadow will use to be created.
  51727. *
  51728. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51729. */
  51730. /**
  51731. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51732. * This specifies what angle the shadow will use to be created.
  51733. *
  51734. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51735. */
  51736. shadowAngle: number;
  51737. /**
  51738. * Gets the direction if it has been set.
  51739. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51740. */
  51741. /**
  51742. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51743. */
  51744. direction: Vector3;
  51745. /**
  51746. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51747. * A PointLight emits the light in every direction.
  51748. * It can cast shadows.
  51749. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51750. * ```javascript
  51751. * var pointLight = new PointLight("pl", camera.position, scene);
  51752. * ```
  51753. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51754. * @param name The light friendly name
  51755. * @param position The position of the point light in the scene
  51756. * @param scene The scene the lights belongs to
  51757. */
  51758. constructor(name: string, position: Vector3, scene: Scene);
  51759. /**
  51760. * Returns the string "PointLight"
  51761. * @returns the class name
  51762. */
  51763. getClassName(): string;
  51764. /**
  51765. * Returns the integer 0.
  51766. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51767. */
  51768. getTypeID(): number;
  51769. /**
  51770. * Specifies wether or not the shadowmap should be a cube texture.
  51771. * @returns true if the shadowmap needs to be a cube texture.
  51772. */
  51773. needCube(): boolean;
  51774. /**
  51775. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51776. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51777. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51778. */
  51779. getShadowDirection(faceIndex?: number): Vector3;
  51780. /**
  51781. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51782. * - fov = PI / 2
  51783. * - aspect ratio : 1.0
  51784. * - z-near and far equal to the active camera minZ and maxZ.
  51785. * Returns the PointLight.
  51786. */
  51787. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51788. protected _buildUniformLayout(): void;
  51789. /**
  51790. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51791. * @param effect The effect to update
  51792. * @param lightIndex The index of the light in the effect to update
  51793. * @returns The point light
  51794. */
  51795. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51796. /**
  51797. * Prepares the list of defines specific to the light type.
  51798. * @param defines the list of defines
  51799. * @param lightIndex defines the index of the light for the effect
  51800. */
  51801. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51802. }
  51803. }
  51804. declare module "babylonjs/Lights/index" {
  51805. export * from "babylonjs/Lights/light";
  51806. export * from "babylonjs/Lights/shadowLight";
  51807. export * from "babylonjs/Lights/Shadows/index";
  51808. export * from "babylonjs/Lights/directionalLight";
  51809. export * from "babylonjs/Lights/hemisphericLight";
  51810. export * from "babylonjs/Lights/pointLight";
  51811. export * from "babylonjs/Lights/spotLight";
  51812. }
  51813. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51814. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51815. /**
  51816. * Header information of HDR texture files.
  51817. */
  51818. export interface HDRInfo {
  51819. /**
  51820. * The height of the texture in pixels.
  51821. */
  51822. height: number;
  51823. /**
  51824. * The width of the texture in pixels.
  51825. */
  51826. width: number;
  51827. /**
  51828. * The index of the beginning of the data in the binary file.
  51829. */
  51830. dataPosition: number;
  51831. }
  51832. /**
  51833. * This groups tools to convert HDR texture to native colors array.
  51834. */
  51835. export class HDRTools {
  51836. private static Ldexp;
  51837. private static Rgbe2float;
  51838. private static readStringLine;
  51839. /**
  51840. * Reads header information from an RGBE texture stored in a native array.
  51841. * More information on this format are available here:
  51842. * https://en.wikipedia.org/wiki/RGBE_image_format
  51843. *
  51844. * @param uint8array The binary file stored in native array.
  51845. * @return The header information.
  51846. */
  51847. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51848. /**
  51849. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51850. * This RGBE texture needs to store the information as a panorama.
  51851. *
  51852. * More information on this format are available here:
  51853. * https://en.wikipedia.org/wiki/RGBE_image_format
  51854. *
  51855. * @param buffer The binary file stored in an array buffer.
  51856. * @param size The expected size of the extracted cubemap.
  51857. * @return The Cube Map information.
  51858. */
  51859. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51860. /**
  51861. * Returns the pixels data extracted from an RGBE texture.
  51862. * This pixels will be stored left to right up to down in the R G B order in one array.
  51863. *
  51864. * More information on this format are available here:
  51865. * https://en.wikipedia.org/wiki/RGBE_image_format
  51866. *
  51867. * @param uint8array The binary file stored in an array buffer.
  51868. * @param hdrInfo The header information of the file.
  51869. * @return The pixels data in RGB right to left up to down order.
  51870. */
  51871. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51872. private static RGBE_ReadPixels_RLE;
  51873. }
  51874. }
  51875. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51876. import { Nullable } from "babylonjs/types";
  51877. import { Scene } from "babylonjs/scene";
  51878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51880. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51881. /**
  51882. * This represents a texture coming from an HDR input.
  51883. *
  51884. * The only supported format is currently panorama picture stored in RGBE format.
  51885. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51886. */
  51887. export class HDRCubeTexture extends BaseTexture {
  51888. private static _facesMapping;
  51889. private _generateHarmonics;
  51890. private _noMipmap;
  51891. private _textureMatrix;
  51892. private _size;
  51893. private _onLoad;
  51894. private _onError;
  51895. /**
  51896. * The texture URL.
  51897. */
  51898. url: string;
  51899. /**
  51900. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51901. */
  51902. coordinatesMode: number;
  51903. protected _isBlocking: boolean;
  51904. /**
  51905. * Sets wether or not the texture is blocking during loading.
  51906. */
  51907. /**
  51908. * Gets wether or not the texture is blocking during loading.
  51909. */
  51910. isBlocking: boolean;
  51911. protected _rotationY: number;
  51912. /**
  51913. * Sets texture matrix rotation angle around Y axis in radians.
  51914. */
  51915. /**
  51916. * Gets texture matrix rotation angle around Y axis radians.
  51917. */
  51918. rotationY: number;
  51919. /**
  51920. * Gets or sets the center of the bounding box associated with the cube texture
  51921. * It must define where the camera used to render the texture was set
  51922. */
  51923. boundingBoxPosition: Vector3;
  51924. private _boundingBoxSize;
  51925. /**
  51926. * Gets or sets the size of the bounding box associated with the cube texture
  51927. * When defined, the cubemap will switch to local mode
  51928. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51929. * @example https://www.babylonjs-playground.com/#RNASML
  51930. */
  51931. boundingBoxSize: Vector3;
  51932. /**
  51933. * Instantiates an HDRTexture from the following parameters.
  51934. *
  51935. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51936. * @param scene The scene the texture will be used in
  51937. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51938. * @param noMipmap Forces to not generate the mipmap if true
  51939. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51940. * @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)
  51941. * @param reserved Reserved flag for internal use.
  51942. */
  51943. 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>);
  51944. /**
  51945. * Get the current class name of the texture useful for serialization or dynamic coding.
  51946. * @returns "HDRCubeTexture"
  51947. */
  51948. getClassName(): string;
  51949. /**
  51950. * Occurs when the file is raw .hdr file.
  51951. */
  51952. private loadTexture;
  51953. clone(): HDRCubeTexture;
  51954. delayLoad(): void;
  51955. /**
  51956. * Get the texture reflection matrix used to rotate/transform the reflection.
  51957. * @returns the reflection matrix
  51958. */
  51959. getReflectionTextureMatrix(): Matrix;
  51960. /**
  51961. * Set the texture reflection matrix used to rotate/transform the reflection.
  51962. * @param value Define the reflection matrix to set
  51963. */
  51964. setReflectionTextureMatrix(value: Matrix): void;
  51965. /**
  51966. * Parses a JSON representation of an HDR Texture in order to create the texture
  51967. * @param parsedTexture Define the JSON representation
  51968. * @param scene Define the scene the texture should be created in
  51969. * @param rootUrl Define the root url in case we need to load relative dependencies
  51970. * @returns the newly created texture after parsing
  51971. */
  51972. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51973. serialize(): any;
  51974. }
  51975. }
  51976. declare module "babylonjs/Physics/physicsEngine" {
  51977. import { Nullable } from "babylonjs/types";
  51978. import { Vector3 } from "babylonjs/Maths/math.vector";
  51979. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51980. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51981. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51982. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51983. /**
  51984. * Class used to control physics engine
  51985. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51986. */
  51987. export class PhysicsEngine implements IPhysicsEngine {
  51988. private _physicsPlugin;
  51989. /**
  51990. * Global value used to control the smallest number supported by the simulation
  51991. */
  51992. static Epsilon: number;
  51993. private _impostors;
  51994. private _joints;
  51995. /**
  51996. * Gets the gravity vector used by the simulation
  51997. */
  51998. gravity: Vector3;
  51999. /**
  52000. * Factory used to create the default physics plugin.
  52001. * @returns The default physics plugin
  52002. */
  52003. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52004. /**
  52005. * Creates a new Physics Engine
  52006. * @param gravity defines the gravity vector used by the simulation
  52007. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52008. */
  52009. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52010. /**
  52011. * Sets the gravity vector used by the simulation
  52012. * @param gravity defines the gravity vector to use
  52013. */
  52014. setGravity(gravity: Vector3): void;
  52015. /**
  52016. * Set the time step of the physics engine.
  52017. * Default is 1/60.
  52018. * To slow it down, enter 1/600 for example.
  52019. * To speed it up, 1/30
  52020. * @param newTimeStep defines the new timestep to apply to this world.
  52021. */
  52022. setTimeStep(newTimeStep?: number): void;
  52023. /**
  52024. * Get the time step of the physics engine.
  52025. * @returns the current time step
  52026. */
  52027. getTimeStep(): number;
  52028. /**
  52029. * Release all resources
  52030. */
  52031. dispose(): void;
  52032. /**
  52033. * Gets the name of the current physics plugin
  52034. * @returns the name of the plugin
  52035. */
  52036. getPhysicsPluginName(): string;
  52037. /**
  52038. * Adding a new impostor for the impostor tracking.
  52039. * This will be done by the impostor itself.
  52040. * @param impostor the impostor to add
  52041. */
  52042. addImpostor(impostor: PhysicsImpostor): void;
  52043. /**
  52044. * Remove an impostor from the engine.
  52045. * This impostor and its mesh will not longer be updated by the physics engine.
  52046. * @param impostor the impostor to remove
  52047. */
  52048. removeImpostor(impostor: PhysicsImpostor): void;
  52049. /**
  52050. * Add a joint to the physics engine
  52051. * @param mainImpostor defines the main impostor to which the joint is added.
  52052. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52053. * @param joint defines the joint that will connect both impostors.
  52054. */
  52055. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52056. /**
  52057. * Removes a joint from the simulation
  52058. * @param mainImpostor defines the impostor used with the joint
  52059. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52060. * @param joint defines the joint to remove
  52061. */
  52062. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52063. /**
  52064. * Called by the scene. No need to call it.
  52065. * @param delta defines the timespam between frames
  52066. */
  52067. _step(delta: number): void;
  52068. /**
  52069. * Gets the current plugin used to run the simulation
  52070. * @returns current plugin
  52071. */
  52072. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52073. /**
  52074. * Gets the list of physic impostors
  52075. * @returns an array of PhysicsImpostor
  52076. */
  52077. getImpostors(): Array<PhysicsImpostor>;
  52078. /**
  52079. * Gets the impostor for a physics enabled object
  52080. * @param object defines the object impersonated by the impostor
  52081. * @returns the PhysicsImpostor or null if not found
  52082. */
  52083. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52084. /**
  52085. * Gets the impostor for a physics body object
  52086. * @param body defines physics body used by the impostor
  52087. * @returns the PhysicsImpostor or null if not found
  52088. */
  52089. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52090. /**
  52091. * Does a raycast in the physics world
  52092. * @param from when should the ray start?
  52093. * @param to when should the ray end?
  52094. * @returns PhysicsRaycastResult
  52095. */
  52096. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52097. }
  52098. }
  52099. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52100. import { Nullable } from "babylonjs/types";
  52101. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52103. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52104. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52105. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52106. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52107. /** @hidden */
  52108. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52109. private _useDeltaForWorldStep;
  52110. world: any;
  52111. name: string;
  52112. private _physicsMaterials;
  52113. private _fixedTimeStep;
  52114. private _cannonRaycastResult;
  52115. private _raycastResult;
  52116. private _physicsBodysToRemoveAfterStep;
  52117. BJSCANNON: any;
  52118. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52119. setGravity(gravity: Vector3): void;
  52120. setTimeStep(timeStep: number): void;
  52121. getTimeStep(): number;
  52122. executeStep(delta: number): void;
  52123. private _removeMarkedPhysicsBodiesFromWorld;
  52124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52127. private _processChildMeshes;
  52128. removePhysicsBody(impostor: PhysicsImpostor): void;
  52129. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52130. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52131. private _addMaterial;
  52132. private _checkWithEpsilon;
  52133. private _createShape;
  52134. private _createHeightmap;
  52135. private _minus90X;
  52136. private _plus90X;
  52137. private _tmpPosition;
  52138. private _tmpDeltaPosition;
  52139. private _tmpUnityRotation;
  52140. private _updatePhysicsBodyTransformation;
  52141. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52142. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52143. isSupported(): boolean;
  52144. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52145. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52146. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52147. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52148. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52149. getBodyMass(impostor: PhysicsImpostor): number;
  52150. getBodyFriction(impostor: PhysicsImpostor): number;
  52151. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52152. getBodyRestitution(impostor: PhysicsImpostor): number;
  52153. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52154. sleepBody(impostor: PhysicsImpostor): void;
  52155. wakeUpBody(impostor: PhysicsImpostor): void;
  52156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52157. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52159. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52160. getRadius(impostor: PhysicsImpostor): number;
  52161. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52162. dispose(): void;
  52163. private _extendNamespace;
  52164. /**
  52165. * Does a raycast in the physics world
  52166. * @param from when should the ray start?
  52167. * @param to when should the ray end?
  52168. * @returns PhysicsRaycastResult
  52169. */
  52170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52171. }
  52172. }
  52173. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52174. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52175. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52176. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52178. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52179. import { Nullable } from "babylonjs/types";
  52180. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52181. /** @hidden */
  52182. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52183. world: any;
  52184. name: string;
  52185. BJSOIMO: any;
  52186. private _raycastResult;
  52187. constructor(iterations?: number, oimoInjection?: any);
  52188. setGravity(gravity: Vector3): void;
  52189. setTimeStep(timeStep: number): void;
  52190. getTimeStep(): number;
  52191. private _tmpImpostorsArray;
  52192. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52193. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52194. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52195. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52196. private _tmpPositionVector;
  52197. removePhysicsBody(impostor: PhysicsImpostor): void;
  52198. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52199. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52200. isSupported(): boolean;
  52201. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52203. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52204. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52206. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52208. getBodyMass(impostor: PhysicsImpostor): number;
  52209. getBodyFriction(impostor: PhysicsImpostor): number;
  52210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52211. getBodyRestitution(impostor: PhysicsImpostor): number;
  52212. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52213. sleepBody(impostor: PhysicsImpostor): void;
  52214. wakeUpBody(impostor: PhysicsImpostor): void;
  52215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52216. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52218. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52219. getRadius(impostor: PhysicsImpostor): number;
  52220. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52221. dispose(): void;
  52222. /**
  52223. * Does a raycast in the physics world
  52224. * @param from when should the ray start?
  52225. * @param to when should the ray end?
  52226. * @returns PhysicsRaycastResult
  52227. */
  52228. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52229. }
  52230. }
  52231. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52232. import { Nullable } from "babylonjs/types";
  52233. import { Scene } from "babylonjs/scene";
  52234. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52235. import { Color4 } from "babylonjs/Maths/math.color";
  52236. import { Mesh } from "babylonjs/Meshes/mesh";
  52237. /**
  52238. * Class containing static functions to help procedurally build meshes
  52239. */
  52240. export class RibbonBuilder {
  52241. /**
  52242. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52243. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52244. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52245. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52246. * * 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
  52247. * * 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
  52248. * * 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
  52249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52252. * * 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
  52253. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52254. * * 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
  52255. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52257. * @param name defines the name of the mesh
  52258. * @param options defines the options used to create the mesh
  52259. * @param scene defines the hosting scene
  52260. * @returns the ribbon mesh
  52261. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52263. */
  52264. static CreateRibbon(name: string, options: {
  52265. pathArray: Vector3[][];
  52266. closeArray?: boolean;
  52267. closePath?: boolean;
  52268. offset?: number;
  52269. updatable?: boolean;
  52270. sideOrientation?: number;
  52271. frontUVs?: Vector4;
  52272. backUVs?: Vector4;
  52273. instance?: Mesh;
  52274. invertUV?: boolean;
  52275. uvs?: Vector2[];
  52276. colors?: Color4[];
  52277. }, scene?: Nullable<Scene>): Mesh;
  52278. }
  52279. }
  52280. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52281. import { Nullable } from "babylonjs/types";
  52282. import { Scene } from "babylonjs/scene";
  52283. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52284. import { Mesh } from "babylonjs/Meshes/mesh";
  52285. /**
  52286. * Class containing static functions to help procedurally build meshes
  52287. */
  52288. export class ShapeBuilder {
  52289. /**
  52290. * 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.
  52291. * * 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.
  52292. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52293. * * 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.
  52294. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52295. * * 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
  52296. * * 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
  52297. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52302. * @param name defines the name of the mesh
  52303. * @param options defines the options used to create the mesh
  52304. * @param scene defines the hosting scene
  52305. * @returns the extruded shape mesh
  52306. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52308. */
  52309. static ExtrudeShape(name: string, options: {
  52310. shape: Vector3[];
  52311. path: Vector3[];
  52312. scale?: number;
  52313. rotation?: number;
  52314. cap?: number;
  52315. updatable?: boolean;
  52316. sideOrientation?: number;
  52317. frontUVs?: Vector4;
  52318. backUVs?: Vector4;
  52319. instance?: Mesh;
  52320. invertUV?: boolean;
  52321. }, scene?: Nullable<Scene>): Mesh;
  52322. /**
  52323. * Creates an custom extruded shape mesh.
  52324. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52325. * * 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.
  52326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52327. * * 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
  52328. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52329. * * 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
  52330. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52331. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52332. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52333. * * 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
  52334. * * 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
  52335. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52340. * @param name defines the name of the mesh
  52341. * @param options defines the options used to create the mesh
  52342. * @param scene defines the hosting scene
  52343. * @returns the custom extruded shape mesh
  52344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52347. */
  52348. static ExtrudeShapeCustom(name: string, options: {
  52349. shape: Vector3[];
  52350. path: Vector3[];
  52351. scaleFunction?: any;
  52352. rotationFunction?: any;
  52353. ribbonCloseArray?: boolean;
  52354. ribbonClosePath?: boolean;
  52355. cap?: number;
  52356. updatable?: boolean;
  52357. sideOrientation?: number;
  52358. frontUVs?: Vector4;
  52359. backUVs?: Vector4;
  52360. instance?: Mesh;
  52361. invertUV?: boolean;
  52362. }, scene?: Nullable<Scene>): Mesh;
  52363. private static _ExtrudeShapeGeneric;
  52364. }
  52365. }
  52366. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52367. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52368. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52369. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52370. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52371. import { Nullable } from "babylonjs/types";
  52372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52373. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52374. /**
  52375. * AmmoJS Physics plugin
  52376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52377. * @see https://github.com/kripken/ammo.js/
  52378. */
  52379. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52380. private _useDeltaForWorldStep;
  52381. /**
  52382. * Reference to the Ammo library
  52383. */
  52384. bjsAMMO: any;
  52385. /**
  52386. * Created ammoJS world which physics bodies are added to
  52387. */
  52388. world: any;
  52389. /**
  52390. * Name of the plugin
  52391. */
  52392. name: string;
  52393. private _timeStep;
  52394. private _fixedTimeStep;
  52395. private _maxSteps;
  52396. private _tmpQuaternion;
  52397. private _tmpAmmoTransform;
  52398. private _tmpAmmoQuaternion;
  52399. private _tmpAmmoConcreteContactResultCallback;
  52400. private _collisionConfiguration;
  52401. private _dispatcher;
  52402. private _overlappingPairCache;
  52403. private _solver;
  52404. private _softBodySolver;
  52405. private _tmpAmmoVectorA;
  52406. private _tmpAmmoVectorB;
  52407. private _tmpAmmoVectorC;
  52408. private _tmpAmmoVectorD;
  52409. private _tmpContactCallbackResult;
  52410. private _tmpAmmoVectorRCA;
  52411. private _tmpAmmoVectorRCB;
  52412. private _raycastResult;
  52413. private static readonly DISABLE_COLLISION_FLAG;
  52414. private static readonly KINEMATIC_FLAG;
  52415. private static readonly DISABLE_DEACTIVATION_FLAG;
  52416. /**
  52417. * Initializes the ammoJS plugin
  52418. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52419. * @param ammoInjection can be used to inject your own ammo reference
  52420. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52421. */
  52422. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52423. /**
  52424. * Sets the gravity of the physics world (m/(s^2))
  52425. * @param gravity Gravity to set
  52426. */
  52427. setGravity(gravity: Vector3): void;
  52428. /**
  52429. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52430. * @param timeStep timestep to use in seconds
  52431. */
  52432. setTimeStep(timeStep: number): void;
  52433. /**
  52434. * 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)
  52435. * @param fixedTimeStep fixedTimeStep to use in seconds
  52436. */
  52437. setFixedTimeStep(fixedTimeStep: number): void;
  52438. /**
  52439. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52440. * @param maxSteps the maximum number of steps by the physics engine per frame
  52441. */
  52442. setMaxSteps(maxSteps: number): void;
  52443. /**
  52444. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52445. * @returns the current timestep in seconds
  52446. */
  52447. getTimeStep(): number;
  52448. private _isImpostorInContact;
  52449. private _isImpostorPairInContact;
  52450. private _stepSimulation;
  52451. /**
  52452. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52453. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52454. * After the step the babylon meshes are set to the position of the physics imposters
  52455. * @param delta amount of time to step forward
  52456. * @param impostors array of imposters to update before/after the step
  52457. */
  52458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52459. /**
  52460. * Update babylon mesh to match physics world object
  52461. * @param impostor imposter to match
  52462. */
  52463. private _afterSoftStep;
  52464. /**
  52465. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52466. * @param impostor imposter to match
  52467. */
  52468. private _ropeStep;
  52469. /**
  52470. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52471. * @param impostor imposter to match
  52472. */
  52473. private _softbodyOrClothStep;
  52474. private _tmpVector;
  52475. private _tmpMatrix;
  52476. /**
  52477. * Applies an impulse on the imposter
  52478. * @param impostor imposter to apply impulse to
  52479. * @param force amount of force to be applied to the imposter
  52480. * @param contactPoint the location to apply the impulse on the imposter
  52481. */
  52482. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52483. /**
  52484. * Applies a force on the imposter
  52485. * @param impostor imposter to apply force
  52486. * @param force amount of force to be applied to the imposter
  52487. * @param contactPoint the location to apply the force on the imposter
  52488. */
  52489. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52490. /**
  52491. * Creates a physics body using the plugin
  52492. * @param impostor the imposter to create the physics body on
  52493. */
  52494. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52495. /**
  52496. * Removes the physics body from the imposter and disposes of the body's memory
  52497. * @param impostor imposter to remove the physics body from
  52498. */
  52499. removePhysicsBody(impostor: PhysicsImpostor): void;
  52500. /**
  52501. * Generates a joint
  52502. * @param impostorJoint the imposter joint to create the joint with
  52503. */
  52504. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52505. /**
  52506. * Removes a joint
  52507. * @param impostorJoint the imposter joint to remove the joint from
  52508. */
  52509. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52510. private _addMeshVerts;
  52511. /**
  52512. * Initialise the soft body vertices to match its object's (mesh) vertices
  52513. * Softbody vertices (nodes) are in world space and to match this
  52514. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52515. * @param impostor to create the softbody for
  52516. */
  52517. private _softVertexData;
  52518. /**
  52519. * Create an impostor's soft body
  52520. * @param impostor to create the softbody for
  52521. */
  52522. private _createSoftbody;
  52523. /**
  52524. * Create cloth for an impostor
  52525. * @param impostor to create the softbody for
  52526. */
  52527. private _createCloth;
  52528. /**
  52529. * Create rope for an impostor
  52530. * @param impostor to create the softbody for
  52531. */
  52532. private _createRope;
  52533. private _addHullVerts;
  52534. private _createShape;
  52535. /**
  52536. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52537. * @param impostor imposter containing the physics body and babylon object
  52538. */
  52539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52540. /**
  52541. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52542. * @param impostor imposter containing the physics body and babylon object
  52543. * @param newPosition new position
  52544. * @param newRotation new rotation
  52545. */
  52546. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52547. /**
  52548. * If this plugin is supported
  52549. * @returns true if its supported
  52550. */
  52551. isSupported(): boolean;
  52552. /**
  52553. * Sets the linear velocity of the physics body
  52554. * @param impostor imposter to set the velocity on
  52555. * @param velocity velocity to set
  52556. */
  52557. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52558. /**
  52559. * Sets the angular velocity of the physics body
  52560. * @param impostor imposter to set the velocity on
  52561. * @param velocity velocity to set
  52562. */
  52563. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52564. /**
  52565. * gets the linear velocity
  52566. * @param impostor imposter to get linear velocity from
  52567. * @returns linear velocity
  52568. */
  52569. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52570. /**
  52571. * gets the angular velocity
  52572. * @param impostor imposter to get angular velocity from
  52573. * @returns angular velocity
  52574. */
  52575. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52576. /**
  52577. * Sets the mass of physics body
  52578. * @param impostor imposter to set the mass on
  52579. * @param mass mass to set
  52580. */
  52581. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52582. /**
  52583. * Gets the mass of the physics body
  52584. * @param impostor imposter to get the mass from
  52585. * @returns mass
  52586. */
  52587. getBodyMass(impostor: PhysicsImpostor): number;
  52588. /**
  52589. * Gets friction of the impostor
  52590. * @param impostor impostor to get friction from
  52591. * @returns friction value
  52592. */
  52593. getBodyFriction(impostor: PhysicsImpostor): number;
  52594. /**
  52595. * Sets friction of the impostor
  52596. * @param impostor impostor to set friction on
  52597. * @param friction friction value
  52598. */
  52599. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52600. /**
  52601. * Gets restitution of the impostor
  52602. * @param impostor impostor to get restitution from
  52603. * @returns restitution value
  52604. */
  52605. getBodyRestitution(impostor: PhysicsImpostor): number;
  52606. /**
  52607. * Sets resitution of the impostor
  52608. * @param impostor impostor to set resitution on
  52609. * @param restitution resitution value
  52610. */
  52611. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52612. /**
  52613. * Gets pressure inside the impostor
  52614. * @param impostor impostor to get pressure from
  52615. * @returns pressure value
  52616. */
  52617. getBodyPressure(impostor: PhysicsImpostor): number;
  52618. /**
  52619. * Sets pressure inside a soft body impostor
  52620. * Cloth and rope must remain 0 pressure
  52621. * @param impostor impostor to set pressure on
  52622. * @param pressure pressure value
  52623. */
  52624. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52625. /**
  52626. * Gets stiffness of the impostor
  52627. * @param impostor impostor to get stiffness from
  52628. * @returns pressure value
  52629. */
  52630. getBodyStiffness(impostor: PhysicsImpostor): number;
  52631. /**
  52632. * Sets stiffness of the impostor
  52633. * @param impostor impostor to set stiffness on
  52634. * @param stiffness stiffness value from 0 to 1
  52635. */
  52636. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52637. /**
  52638. * Gets velocityIterations of the impostor
  52639. * @param impostor impostor to get velocity iterations from
  52640. * @returns velocityIterations value
  52641. */
  52642. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52643. /**
  52644. * Sets velocityIterations of the impostor
  52645. * @param impostor impostor to set velocity iterations on
  52646. * @param velocityIterations velocityIterations value
  52647. */
  52648. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52649. /**
  52650. * Gets positionIterations of the impostor
  52651. * @param impostor impostor to get position iterations from
  52652. * @returns positionIterations value
  52653. */
  52654. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52655. /**
  52656. * Sets positionIterations of the impostor
  52657. * @param impostor impostor to set position on
  52658. * @param positionIterations positionIterations value
  52659. */
  52660. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52661. /**
  52662. * Append an anchor to a cloth object
  52663. * @param impostor is the cloth impostor to add anchor to
  52664. * @param otherImpostor is the rigid impostor to anchor to
  52665. * @param width ratio across width from 0 to 1
  52666. * @param height ratio up height from 0 to 1
  52667. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52668. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52669. */
  52670. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52671. /**
  52672. * Append an hook to a rope object
  52673. * @param impostor is the rope impostor to add hook to
  52674. * @param otherImpostor is the rigid impostor to hook to
  52675. * @param length ratio along the rope from 0 to 1
  52676. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52677. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52678. */
  52679. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52680. /**
  52681. * Sleeps the physics body and stops it from being active
  52682. * @param impostor impostor to sleep
  52683. */
  52684. sleepBody(impostor: PhysicsImpostor): void;
  52685. /**
  52686. * Activates the physics body
  52687. * @param impostor impostor to activate
  52688. */
  52689. wakeUpBody(impostor: PhysicsImpostor): void;
  52690. /**
  52691. * Updates the distance parameters of the joint
  52692. * @param joint joint to update
  52693. * @param maxDistance maximum distance of the joint
  52694. * @param minDistance minimum distance of the joint
  52695. */
  52696. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52697. /**
  52698. * Sets a motor on the joint
  52699. * @param joint joint to set motor on
  52700. * @param speed speed of the motor
  52701. * @param maxForce maximum force of the motor
  52702. * @param motorIndex index of the motor
  52703. */
  52704. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52705. /**
  52706. * Sets the motors limit
  52707. * @param joint joint to set limit on
  52708. * @param upperLimit upper limit
  52709. * @param lowerLimit lower limit
  52710. */
  52711. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52712. /**
  52713. * Syncs the position and rotation of a mesh with the impostor
  52714. * @param mesh mesh to sync
  52715. * @param impostor impostor to update the mesh with
  52716. */
  52717. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52718. /**
  52719. * Gets the radius of the impostor
  52720. * @param impostor impostor to get radius from
  52721. * @returns the radius
  52722. */
  52723. getRadius(impostor: PhysicsImpostor): number;
  52724. /**
  52725. * Gets the box size of the impostor
  52726. * @param impostor impostor to get box size from
  52727. * @param result the resulting box size
  52728. */
  52729. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52730. /**
  52731. * Disposes of the impostor
  52732. */
  52733. dispose(): void;
  52734. /**
  52735. * Does a raycast in the physics world
  52736. * @param from when should the ray start?
  52737. * @param to when should the ray end?
  52738. * @returns PhysicsRaycastResult
  52739. */
  52740. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52741. }
  52742. }
  52743. declare module "babylonjs/Probes/reflectionProbe" {
  52744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52745. import { Vector3 } from "babylonjs/Maths/math.vector";
  52746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52747. import { Nullable } from "babylonjs/types";
  52748. import { Scene } from "babylonjs/scene";
  52749. module "babylonjs/abstractScene" {
  52750. interface AbstractScene {
  52751. /**
  52752. * The list of reflection probes added to the scene
  52753. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52754. */
  52755. reflectionProbes: Array<ReflectionProbe>;
  52756. /**
  52757. * Removes the given reflection probe from this scene.
  52758. * @param toRemove The reflection probe to remove
  52759. * @returns The index of the removed reflection probe
  52760. */
  52761. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52762. /**
  52763. * Adds the given reflection probe to this scene.
  52764. * @param newReflectionProbe The reflection probe to add
  52765. */
  52766. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52767. }
  52768. }
  52769. /**
  52770. * Class used to generate realtime reflection / refraction cube textures
  52771. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52772. */
  52773. export class ReflectionProbe {
  52774. /** defines the name of the probe */
  52775. name: string;
  52776. private _scene;
  52777. private _renderTargetTexture;
  52778. private _projectionMatrix;
  52779. private _viewMatrix;
  52780. private _target;
  52781. private _add;
  52782. private _attachedMesh;
  52783. private _invertYAxis;
  52784. /** Gets or sets probe position (center of the cube map) */
  52785. position: Vector3;
  52786. /**
  52787. * Creates a new reflection probe
  52788. * @param name defines the name of the probe
  52789. * @param size defines the texture resolution (for each face)
  52790. * @param scene defines the hosting scene
  52791. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52792. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52793. */
  52794. constructor(
  52795. /** defines the name of the probe */
  52796. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52797. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52798. samples: number;
  52799. /** Gets or sets the refresh rate to use (on every frame by default) */
  52800. refreshRate: number;
  52801. /**
  52802. * Gets the hosting scene
  52803. * @returns a Scene
  52804. */
  52805. getScene(): Scene;
  52806. /** Gets the internal CubeTexture used to render to */
  52807. readonly cubeTexture: RenderTargetTexture;
  52808. /** Gets the list of meshes to render */
  52809. readonly renderList: Nullable<AbstractMesh[]>;
  52810. /**
  52811. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52812. * @param mesh defines the mesh to attach to
  52813. */
  52814. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52815. /**
  52816. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52817. * @param renderingGroupId The rendering group id corresponding to its index
  52818. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52819. */
  52820. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52821. /**
  52822. * Clean all associated resources
  52823. */
  52824. dispose(): void;
  52825. /**
  52826. * Converts the reflection probe information to a readable string for debug purpose.
  52827. * @param fullDetails Supports for multiple levels of logging within scene loading
  52828. * @returns the human readable reflection probe info
  52829. */
  52830. toString(fullDetails?: boolean): string;
  52831. /**
  52832. * Get the class name of the relfection probe.
  52833. * @returns "ReflectionProbe"
  52834. */
  52835. getClassName(): string;
  52836. /**
  52837. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52838. * @returns The JSON representation of the texture
  52839. */
  52840. serialize(): any;
  52841. /**
  52842. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52843. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52844. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52845. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52846. * @returns The parsed reflection probe if successful
  52847. */
  52848. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52849. }
  52850. }
  52851. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52852. /** @hidden */
  52853. export var _BabylonLoaderRegistered: boolean;
  52854. }
  52855. declare module "babylonjs/Loading/Plugins/index" {
  52856. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52857. }
  52858. declare module "babylonjs/Loading/index" {
  52859. export * from "babylonjs/Loading/loadingScreen";
  52860. export * from "babylonjs/Loading/Plugins/index";
  52861. export * from "babylonjs/Loading/sceneLoader";
  52862. export * from "babylonjs/Loading/sceneLoaderFlags";
  52863. }
  52864. declare module "babylonjs/Materials/Background/index" {
  52865. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52866. }
  52867. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52868. import { Scene } from "babylonjs/scene";
  52869. import { Color3 } from "babylonjs/Maths/math.color";
  52870. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52872. /**
  52873. * The Physically based simple base material of BJS.
  52874. *
  52875. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52876. * It is used as the base class for both the specGloss and metalRough conventions.
  52877. */
  52878. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52879. /**
  52880. * Number of Simultaneous lights allowed on the material.
  52881. */
  52882. maxSimultaneousLights: number;
  52883. /**
  52884. * If sets to true, disables all the lights affecting the material.
  52885. */
  52886. disableLighting: boolean;
  52887. /**
  52888. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52889. */
  52890. environmentTexture: BaseTexture;
  52891. /**
  52892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52893. */
  52894. invertNormalMapX: boolean;
  52895. /**
  52896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52897. */
  52898. invertNormalMapY: boolean;
  52899. /**
  52900. * Normal map used in the model.
  52901. */
  52902. normalTexture: BaseTexture;
  52903. /**
  52904. * Emissivie color used to self-illuminate the model.
  52905. */
  52906. emissiveColor: Color3;
  52907. /**
  52908. * Emissivie texture used to self-illuminate the model.
  52909. */
  52910. emissiveTexture: BaseTexture;
  52911. /**
  52912. * Occlusion Channel Strenght.
  52913. */
  52914. occlusionStrength: number;
  52915. /**
  52916. * Occlusion Texture of the material (adding extra occlusion effects).
  52917. */
  52918. occlusionTexture: BaseTexture;
  52919. /**
  52920. * Defines the alpha limits in alpha test mode.
  52921. */
  52922. alphaCutOff: number;
  52923. /**
  52924. * Gets the current double sided mode.
  52925. */
  52926. /**
  52927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52928. */
  52929. doubleSided: boolean;
  52930. /**
  52931. * Stores the pre-calculated light information of a mesh in a texture.
  52932. */
  52933. lightmapTexture: BaseTexture;
  52934. /**
  52935. * If true, the light map contains occlusion information instead of lighting info.
  52936. */
  52937. useLightmapAsShadowmap: boolean;
  52938. /**
  52939. * Instantiates a new PBRMaterial instance.
  52940. *
  52941. * @param name The material name
  52942. * @param scene The scene the material will be use in.
  52943. */
  52944. constructor(name: string, scene: Scene);
  52945. getClassName(): string;
  52946. }
  52947. }
  52948. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52949. import { Scene } from "babylonjs/scene";
  52950. import { Color3 } from "babylonjs/Maths/math.color";
  52951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52952. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52953. /**
  52954. * The PBR material of BJS following the metal roughness convention.
  52955. *
  52956. * This fits to the PBR convention in the GLTF definition:
  52957. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52958. */
  52959. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52960. /**
  52961. * The base color has two different interpretations depending on the value of metalness.
  52962. * When the material is a metal, the base color is the specific measured reflectance value
  52963. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52964. * of the material.
  52965. */
  52966. baseColor: Color3;
  52967. /**
  52968. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52969. * well as opacity information in the alpha channel.
  52970. */
  52971. baseTexture: BaseTexture;
  52972. /**
  52973. * Specifies the metallic scalar value of the material.
  52974. * Can also be used to scale the metalness values of the metallic texture.
  52975. */
  52976. metallic: number;
  52977. /**
  52978. * Specifies the roughness scalar value of the material.
  52979. * Can also be used to scale the roughness values of the metallic texture.
  52980. */
  52981. roughness: number;
  52982. /**
  52983. * Texture containing both the metallic value in the B channel and the
  52984. * roughness value in the G channel to keep better precision.
  52985. */
  52986. metallicRoughnessTexture: BaseTexture;
  52987. /**
  52988. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52989. *
  52990. * @param name The material name
  52991. * @param scene The scene the material will be use in.
  52992. */
  52993. constructor(name: string, scene: Scene);
  52994. /**
  52995. * Return the currrent class name of the material.
  52996. */
  52997. getClassName(): string;
  52998. /**
  52999. * Makes a duplicate of the current material.
  53000. * @param name - name to use for the new material.
  53001. */
  53002. clone(name: string): PBRMetallicRoughnessMaterial;
  53003. /**
  53004. * Serialize the material to a parsable JSON object.
  53005. */
  53006. serialize(): any;
  53007. /**
  53008. * Parses a JSON object correponding to the serialize function.
  53009. */
  53010. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53011. }
  53012. }
  53013. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53014. import { Scene } from "babylonjs/scene";
  53015. import { Color3 } from "babylonjs/Maths/math.color";
  53016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53017. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53018. /**
  53019. * The PBR material of BJS following the specular glossiness convention.
  53020. *
  53021. * This fits to the PBR convention in the GLTF definition:
  53022. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53023. */
  53024. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53025. /**
  53026. * Specifies the diffuse color of the material.
  53027. */
  53028. diffuseColor: Color3;
  53029. /**
  53030. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53031. * channel.
  53032. */
  53033. diffuseTexture: BaseTexture;
  53034. /**
  53035. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53036. */
  53037. specularColor: Color3;
  53038. /**
  53039. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53040. */
  53041. glossiness: number;
  53042. /**
  53043. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53044. */
  53045. specularGlossinessTexture: BaseTexture;
  53046. /**
  53047. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53048. *
  53049. * @param name The material name
  53050. * @param scene The scene the material will be use in.
  53051. */
  53052. constructor(name: string, scene: Scene);
  53053. /**
  53054. * Return the currrent class name of the material.
  53055. */
  53056. getClassName(): string;
  53057. /**
  53058. * Makes a duplicate of the current material.
  53059. * @param name - name to use for the new material.
  53060. */
  53061. clone(name: string): PBRSpecularGlossinessMaterial;
  53062. /**
  53063. * Serialize the material to a parsable JSON object.
  53064. */
  53065. serialize(): any;
  53066. /**
  53067. * Parses a JSON object correponding to the serialize function.
  53068. */
  53069. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53070. }
  53071. }
  53072. declare module "babylonjs/Materials/PBR/index" {
  53073. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53074. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53075. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53076. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53077. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53078. }
  53079. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53080. import { Nullable } from "babylonjs/types";
  53081. import { Scene } from "babylonjs/scene";
  53082. import { Matrix } from "babylonjs/Maths/math.vector";
  53083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53084. /**
  53085. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53086. * It can help converting any input color in a desired output one. This can then be used to create effects
  53087. * from sepia, black and white to sixties or futuristic rendering...
  53088. *
  53089. * The only supported format is currently 3dl.
  53090. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53091. */
  53092. export class ColorGradingTexture extends BaseTexture {
  53093. /**
  53094. * The current texture matrix. (will always be identity in color grading texture)
  53095. */
  53096. private _textureMatrix;
  53097. /**
  53098. * The texture URL.
  53099. */
  53100. url: string;
  53101. /**
  53102. * Empty line regex stored for GC.
  53103. */
  53104. private static _noneEmptyLineRegex;
  53105. private _engine;
  53106. /**
  53107. * Instantiates a ColorGradingTexture from the following parameters.
  53108. *
  53109. * @param url The location of the color gradind data (currently only supporting 3dl)
  53110. * @param scene The scene the texture will be used in
  53111. */
  53112. constructor(url: string, scene: Scene);
  53113. /**
  53114. * Returns the texture matrix used in most of the material.
  53115. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53116. */
  53117. getTextureMatrix(): Matrix;
  53118. /**
  53119. * Occurs when the file being loaded is a .3dl LUT file.
  53120. */
  53121. private load3dlTexture;
  53122. /**
  53123. * Starts the loading process of the texture.
  53124. */
  53125. private loadTexture;
  53126. /**
  53127. * Clones the color gradind texture.
  53128. */
  53129. clone(): ColorGradingTexture;
  53130. /**
  53131. * Called during delayed load for textures.
  53132. */
  53133. delayLoad(): void;
  53134. /**
  53135. * Parses a color grading texture serialized by Babylon.
  53136. * @param parsedTexture The texture information being parsedTexture
  53137. * @param scene The scene to load the texture in
  53138. * @param rootUrl The root url of the data assets to load
  53139. * @return A color gradind texture
  53140. */
  53141. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53142. /**
  53143. * Serializes the LUT texture to json format.
  53144. */
  53145. serialize(): any;
  53146. }
  53147. }
  53148. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53149. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53150. import { Scene } from "babylonjs/scene";
  53151. import { Nullable } from "babylonjs/types";
  53152. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53153. /**
  53154. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53155. */
  53156. export class EquiRectangularCubeTexture extends BaseTexture {
  53157. /** The six faces of the cube. */
  53158. private static _FacesMapping;
  53159. private _noMipmap;
  53160. private _onLoad;
  53161. private _onError;
  53162. /** The size of the cubemap. */
  53163. private _size;
  53164. /** The buffer of the image. */
  53165. private _buffer;
  53166. /** The width of the input image. */
  53167. private _width;
  53168. /** The height of the input image. */
  53169. private _height;
  53170. /** The URL to the image. */
  53171. url: string;
  53172. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53173. coordinatesMode: number;
  53174. /**
  53175. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53176. * @param url The location of the image
  53177. * @param scene The scene the texture will be used in
  53178. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53179. * @param noMipmap Forces to not generate the mipmap if true
  53180. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53181. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53182. * @param onLoad — defines a callback called when texture is loaded
  53183. * @param onError — defines a callback called if there is an error
  53184. */
  53185. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53186. /**
  53187. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53188. */
  53189. private loadImage;
  53190. /**
  53191. * Convert the image buffer into a cubemap and create a CubeTexture.
  53192. */
  53193. private loadTexture;
  53194. /**
  53195. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53196. * @param buffer The ArrayBuffer that should be converted.
  53197. * @returns The buffer as Float32Array.
  53198. */
  53199. private getFloat32ArrayFromArrayBuffer;
  53200. /**
  53201. * Get the current class name of the texture useful for serialization or dynamic coding.
  53202. * @returns "EquiRectangularCubeTexture"
  53203. */
  53204. getClassName(): string;
  53205. /**
  53206. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53207. * @returns A clone of the current EquiRectangularCubeTexture.
  53208. */
  53209. clone(): EquiRectangularCubeTexture;
  53210. }
  53211. }
  53212. declare module "babylonjs/Misc/tga" {
  53213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53214. /**
  53215. * Based on jsTGALoader - Javascript loader for TGA file
  53216. * By Vincent Thibault
  53217. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53218. */
  53219. export class TGATools {
  53220. private static _TYPE_INDEXED;
  53221. private static _TYPE_RGB;
  53222. private static _TYPE_GREY;
  53223. private static _TYPE_RLE_INDEXED;
  53224. private static _TYPE_RLE_RGB;
  53225. private static _TYPE_RLE_GREY;
  53226. private static _ORIGIN_MASK;
  53227. private static _ORIGIN_SHIFT;
  53228. private static _ORIGIN_BL;
  53229. private static _ORIGIN_BR;
  53230. private static _ORIGIN_UL;
  53231. private static _ORIGIN_UR;
  53232. /**
  53233. * Gets the header of a TGA file
  53234. * @param data defines the TGA data
  53235. * @returns the header
  53236. */
  53237. static GetTGAHeader(data: Uint8Array): any;
  53238. /**
  53239. * Uploads TGA content to a Babylon Texture
  53240. * @hidden
  53241. */
  53242. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53243. /** @hidden */
  53244. 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;
  53245. /** @hidden */
  53246. 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;
  53247. /** @hidden */
  53248. 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;
  53249. /** @hidden */
  53250. 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;
  53251. /** @hidden */
  53252. 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;
  53253. /** @hidden */
  53254. 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;
  53255. }
  53256. }
  53257. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53258. import { Nullable } from "babylonjs/types";
  53259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53260. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53261. /**
  53262. * Implementation of the TGA Texture Loader.
  53263. * @hidden
  53264. */
  53265. export class _TGATextureLoader implements IInternalTextureLoader {
  53266. /**
  53267. * Defines wether the loader supports cascade loading the different faces.
  53268. */
  53269. readonly supportCascades: boolean;
  53270. /**
  53271. * This returns if the loader support the current file information.
  53272. * @param extension defines the file extension of the file being loaded
  53273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53274. * @param fallback defines the fallback internal texture if any
  53275. * @param isBase64 defines whether the texture is encoded as a base64
  53276. * @param isBuffer defines whether the texture data are stored as a buffer
  53277. * @returns true if the loader can load the specified file
  53278. */
  53279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53280. /**
  53281. * Transform the url before loading if required.
  53282. * @param rootUrl the url of the texture
  53283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53284. * @returns the transformed texture
  53285. */
  53286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53287. /**
  53288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53289. * @param rootUrl the url of the texture
  53290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53291. * @returns the fallback texture
  53292. */
  53293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53294. /**
  53295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53296. * @param data contains the texture data
  53297. * @param texture defines the BabylonJS internal texture
  53298. * @param createPolynomials will be true if polynomials have been requested
  53299. * @param onLoad defines the callback to trigger once the texture is ready
  53300. * @param onError defines the callback to trigger in case of error
  53301. */
  53302. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53303. /**
  53304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53305. * @param data contains the texture data
  53306. * @param texture defines the BabylonJS internal texture
  53307. * @param callback defines the method to call once ready to upload
  53308. */
  53309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53310. }
  53311. }
  53312. declare module "babylonjs/Misc/basis" {
  53313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53314. /**
  53315. * Info about the .basis files
  53316. */
  53317. class BasisFileInfo {
  53318. /**
  53319. * If the file has alpha
  53320. */
  53321. hasAlpha: boolean;
  53322. /**
  53323. * Info about each image of the basis file
  53324. */
  53325. images: Array<{
  53326. levels: Array<{
  53327. width: number;
  53328. height: number;
  53329. transcodedPixels: ArrayBufferView;
  53330. }>;
  53331. }>;
  53332. }
  53333. /**
  53334. * Result of transcoding a basis file
  53335. */
  53336. class TranscodeResult {
  53337. /**
  53338. * Info about the .basis file
  53339. */
  53340. fileInfo: BasisFileInfo;
  53341. /**
  53342. * Format to use when loading the file
  53343. */
  53344. format: number;
  53345. }
  53346. /**
  53347. * Configuration options for the Basis transcoder
  53348. */
  53349. export class BasisTranscodeConfiguration {
  53350. /**
  53351. * Supported compression formats used to determine the supported output format of the transcoder
  53352. */
  53353. supportedCompressionFormats?: {
  53354. /**
  53355. * etc1 compression format
  53356. */
  53357. etc1?: boolean;
  53358. /**
  53359. * s3tc compression format
  53360. */
  53361. s3tc?: boolean;
  53362. /**
  53363. * pvrtc compression format
  53364. */
  53365. pvrtc?: boolean;
  53366. /**
  53367. * etc2 compression format
  53368. */
  53369. etc2?: boolean;
  53370. };
  53371. /**
  53372. * If mipmap levels should be loaded for transcoded images (Default: true)
  53373. */
  53374. loadMipmapLevels?: boolean;
  53375. /**
  53376. * Index of a single image to load (Default: all images)
  53377. */
  53378. loadSingleImage?: number;
  53379. }
  53380. /**
  53381. * Used to load .Basis files
  53382. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53383. */
  53384. export class BasisTools {
  53385. private static _IgnoreSupportedFormats;
  53386. /**
  53387. * URL to use when loading the basis transcoder
  53388. */
  53389. static JSModuleURL: string;
  53390. /**
  53391. * URL to use when loading the wasm module for the transcoder
  53392. */
  53393. static WasmModuleURL: string;
  53394. /**
  53395. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53396. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53397. * @returns internal format corresponding to the Basis format
  53398. */
  53399. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53400. private static _WorkerPromise;
  53401. private static _Worker;
  53402. private static _actionId;
  53403. private static _CreateWorkerAsync;
  53404. /**
  53405. * Transcodes a loaded image file to compressed pixel data
  53406. * @param imageData image data to transcode
  53407. * @param config configuration options for the transcoding
  53408. * @returns a promise resulting in the transcoded image
  53409. */
  53410. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53411. /**
  53412. * Loads a texture from the transcode result
  53413. * @param texture texture load to
  53414. * @param transcodeResult the result of transcoding the basis file to load from
  53415. */
  53416. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53417. }
  53418. }
  53419. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53420. import { Nullable } from "babylonjs/types";
  53421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53422. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53423. /**
  53424. * Loader for .basis file format
  53425. */
  53426. export class _BasisTextureLoader implements IInternalTextureLoader {
  53427. /**
  53428. * Defines whether the loader supports cascade loading the different faces.
  53429. */
  53430. readonly supportCascades: boolean;
  53431. /**
  53432. * This returns if the loader support the current file information.
  53433. * @param extension defines the file extension of the file being loaded
  53434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53435. * @param fallback defines the fallback internal texture if any
  53436. * @param isBase64 defines whether the texture is encoded as a base64
  53437. * @param isBuffer defines whether the texture data are stored as a buffer
  53438. * @returns true if the loader can load the specified file
  53439. */
  53440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53441. /**
  53442. * Transform the url before loading if required.
  53443. * @param rootUrl the url of the texture
  53444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53445. * @returns the transformed texture
  53446. */
  53447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53448. /**
  53449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53450. * @param rootUrl the url of the texture
  53451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53452. * @returns the fallback texture
  53453. */
  53454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53455. /**
  53456. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53457. * @param data contains the texture data
  53458. * @param texture defines the BabylonJS internal texture
  53459. * @param createPolynomials will be true if polynomials have been requested
  53460. * @param onLoad defines the callback to trigger once the texture is ready
  53461. * @param onError defines the callback to trigger in case of error
  53462. */
  53463. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53464. /**
  53465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53466. * @param data contains the texture data
  53467. * @param texture defines the BabylonJS internal texture
  53468. * @param callback defines the method to call once ready to upload
  53469. */
  53470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53471. }
  53472. }
  53473. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53474. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53475. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53476. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53477. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53478. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53479. }
  53480. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53481. import { Scene } from "babylonjs/scene";
  53482. import { Texture } from "babylonjs/Materials/Textures/texture";
  53483. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53484. /**
  53485. * 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.
  53486. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53487. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53488. */
  53489. export class CustomProceduralTexture extends ProceduralTexture {
  53490. private _animate;
  53491. private _time;
  53492. private _config;
  53493. private _texturePath;
  53494. /**
  53495. * Instantiates a new Custom Procedural Texture.
  53496. * 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.
  53497. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53498. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53499. * @param name Define the name of the texture
  53500. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53501. * @param size Define the size of the texture to create
  53502. * @param scene Define the scene the texture belongs to
  53503. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53504. * @param generateMipMaps Define if the texture should creates mip maps or not
  53505. */
  53506. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53507. private _loadJson;
  53508. /**
  53509. * Is the texture ready to be used ? (rendered at least once)
  53510. * @returns true if ready, otherwise, false.
  53511. */
  53512. isReady(): boolean;
  53513. /**
  53514. * Render the texture to its associated render target.
  53515. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53516. */
  53517. render(useCameraPostProcess?: boolean): void;
  53518. /**
  53519. * Update the list of dependant textures samplers in the shader.
  53520. */
  53521. updateTextures(): void;
  53522. /**
  53523. * Update the uniform values of the procedural texture in the shader.
  53524. */
  53525. updateShaderUniforms(): void;
  53526. /**
  53527. * Define if the texture animates or not.
  53528. */
  53529. animate: boolean;
  53530. }
  53531. }
  53532. declare module "babylonjs/Shaders/noise.fragment" {
  53533. /** @hidden */
  53534. export var noisePixelShader: {
  53535. name: string;
  53536. shader: string;
  53537. };
  53538. }
  53539. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53540. import { Nullable } from "babylonjs/types";
  53541. import { Scene } from "babylonjs/scene";
  53542. import { Texture } from "babylonjs/Materials/Textures/texture";
  53543. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53544. import "babylonjs/Shaders/noise.fragment";
  53545. /**
  53546. * Class used to generate noise procedural textures
  53547. */
  53548. export class NoiseProceduralTexture extends ProceduralTexture {
  53549. private _time;
  53550. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53551. brightness: number;
  53552. /** Defines the number of octaves to process */
  53553. octaves: number;
  53554. /** Defines the level of persistence (0.8 by default) */
  53555. persistence: number;
  53556. /** Gets or sets animation speed factor (default is 1) */
  53557. animationSpeedFactor: number;
  53558. /**
  53559. * Creates a new NoiseProceduralTexture
  53560. * @param name defines the name fo the texture
  53561. * @param size defines the size of the texture (default is 256)
  53562. * @param scene defines the hosting scene
  53563. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53564. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53565. */
  53566. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53567. private _updateShaderUniforms;
  53568. protected _getDefines(): string;
  53569. /** Generate the current state of the procedural texture */
  53570. render(useCameraPostProcess?: boolean): void;
  53571. /**
  53572. * Serializes this noise procedural texture
  53573. * @returns a serialized noise procedural texture object
  53574. */
  53575. serialize(): any;
  53576. /**
  53577. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53578. * @param parsedTexture defines parsed texture data
  53579. * @param scene defines the current scene
  53580. * @param rootUrl defines the root URL containing noise procedural texture information
  53581. * @returns a parsed NoiseProceduralTexture
  53582. */
  53583. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53584. }
  53585. }
  53586. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53587. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53588. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53589. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53590. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53591. }
  53592. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53593. import { Nullable } from "babylonjs/types";
  53594. import { Scene } from "babylonjs/scene";
  53595. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53597. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53598. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53599. /**
  53600. * Raw cube texture where the raw buffers are passed in
  53601. */
  53602. export class RawCubeTexture extends CubeTexture {
  53603. /**
  53604. * Creates a cube texture where the raw buffers are passed in.
  53605. * @param scene defines the scene the texture is attached to
  53606. * @param data defines the array of data to use to create each face
  53607. * @param size defines the size of the textures
  53608. * @param format defines the format of the data
  53609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53610. * @param generateMipMaps defines if the engine should generate the mip levels
  53611. * @param invertY defines if data must be stored with Y axis inverted
  53612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53613. * @param compression defines the compression used (null by default)
  53614. */
  53615. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53616. /**
  53617. * Updates the raw cube texture.
  53618. * @param data defines the data to store
  53619. * @param format defines the data format
  53620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53621. * @param invertY defines if data must be stored with Y axis inverted
  53622. * @param compression defines the compression used (null by default)
  53623. * @param level defines which level of the texture to update
  53624. */
  53625. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53626. /**
  53627. * Updates a raw cube texture with RGBD encoded data.
  53628. * @param data defines the array of data [mipmap][face] to use to create each face
  53629. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53632. * @returns a promsie that resolves when the operation is complete
  53633. */
  53634. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53635. /**
  53636. * Clones the raw cube texture.
  53637. * @return a new cube texture
  53638. */
  53639. clone(): CubeTexture;
  53640. /** @hidden */
  53641. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53642. }
  53643. }
  53644. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53645. import { Scene } from "babylonjs/scene";
  53646. import { Texture } from "babylonjs/Materials/Textures/texture";
  53647. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53648. /**
  53649. * Class used to store 3D textures containing user data
  53650. */
  53651. export class RawTexture3D extends Texture {
  53652. /** Gets or sets the texture format to use */
  53653. format: number;
  53654. private _engine;
  53655. /**
  53656. * Create a new RawTexture3D
  53657. * @param data defines the data of the texture
  53658. * @param width defines the width of the texture
  53659. * @param height defines the height of the texture
  53660. * @param depth defines the depth of the texture
  53661. * @param format defines the texture format to use
  53662. * @param scene defines the hosting scene
  53663. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53664. * @param invertY defines if texture must be stored with Y axis inverted
  53665. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53666. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53667. */
  53668. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53669. /** Gets or sets the texture format to use */
  53670. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53671. /**
  53672. * Update the texture with new data
  53673. * @param data defines the data to store in the texture
  53674. */
  53675. update(data: ArrayBufferView): void;
  53676. }
  53677. }
  53678. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53679. import { Scene } from "babylonjs/scene";
  53680. import { Plane } from "babylonjs/Maths/math.plane";
  53681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53682. /**
  53683. * Creates a refraction texture used by refraction channel of the standard material.
  53684. * It is like a mirror but to see through a material.
  53685. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53686. */
  53687. export class RefractionTexture extends RenderTargetTexture {
  53688. /**
  53689. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53690. * 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.
  53691. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53692. */
  53693. refractionPlane: Plane;
  53694. /**
  53695. * Define how deep under the surface we should see.
  53696. */
  53697. depth: number;
  53698. /**
  53699. * Creates a refraction texture used by refraction channel of the standard material.
  53700. * It is like a mirror but to see through a material.
  53701. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53702. * @param name Define the texture name
  53703. * @param size Define the size of the underlying texture
  53704. * @param scene Define the scene the refraction belongs to
  53705. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53706. */
  53707. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53708. /**
  53709. * Clone the refraction texture.
  53710. * @returns the cloned texture
  53711. */
  53712. clone(): RefractionTexture;
  53713. /**
  53714. * Serialize the texture to a JSON representation you could use in Parse later on
  53715. * @returns the serialized JSON representation
  53716. */
  53717. serialize(): any;
  53718. }
  53719. }
  53720. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53721. import { Nullable } from "babylonjs/types";
  53722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53723. import { Matrix } from "babylonjs/Maths/math.vector";
  53724. import { Engine } from "babylonjs/Engines/engine";
  53725. import { Scene } from "babylonjs/scene";
  53726. /**
  53727. * Defines the options related to the creation of an HtmlElementTexture
  53728. */
  53729. export interface IHtmlElementTextureOptions {
  53730. /**
  53731. * Defines wether mip maps should be created or not.
  53732. */
  53733. generateMipMaps?: boolean;
  53734. /**
  53735. * Defines the sampling mode of the texture.
  53736. */
  53737. samplingMode?: number;
  53738. /**
  53739. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53740. */
  53741. engine: Nullable<Engine>;
  53742. /**
  53743. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53744. */
  53745. scene: Nullable<Scene>;
  53746. }
  53747. /**
  53748. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53749. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53750. * is automatically managed.
  53751. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53752. * in your application.
  53753. *
  53754. * As the update is not automatic, you need to call them manually.
  53755. */
  53756. export class HtmlElementTexture extends BaseTexture {
  53757. /**
  53758. * The texture URL.
  53759. */
  53760. element: HTMLVideoElement | HTMLCanvasElement;
  53761. private static readonly DefaultOptions;
  53762. private _textureMatrix;
  53763. private _engine;
  53764. private _isVideo;
  53765. private _generateMipMaps;
  53766. private _samplingMode;
  53767. /**
  53768. * Instantiates a HtmlElementTexture from the following parameters.
  53769. *
  53770. * @param name Defines the name of the texture
  53771. * @param element Defines the video or canvas the texture is filled with
  53772. * @param options Defines the other none mandatory texture creation options
  53773. */
  53774. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53775. private _createInternalTexture;
  53776. /**
  53777. * Returns the texture matrix used in most of the material.
  53778. */
  53779. getTextureMatrix(): Matrix;
  53780. /**
  53781. * Updates the content of the texture.
  53782. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53783. */
  53784. update(invertY?: Nullable<boolean>): void;
  53785. }
  53786. }
  53787. declare module "babylonjs/Materials/Textures/index" {
  53788. export * from "babylonjs/Materials/Textures/baseTexture";
  53789. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53790. export * from "babylonjs/Materials/Textures/cubeTexture";
  53791. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53792. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53793. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53794. export * from "babylonjs/Materials/Textures/internalTexture";
  53795. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53796. export * from "babylonjs/Materials/Textures/Loaders/index";
  53797. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53798. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53799. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53800. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53801. export * from "babylonjs/Materials/Textures/rawTexture";
  53802. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53803. export * from "babylonjs/Materials/Textures/refractionTexture";
  53804. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53805. export * from "babylonjs/Materials/Textures/texture";
  53806. export * from "babylonjs/Materials/Textures/videoTexture";
  53807. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53808. }
  53809. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53810. /**
  53811. * Enum used to define the target of a block
  53812. */
  53813. export enum NodeMaterialBlockTargets {
  53814. /** Vertex shader */
  53815. Vertex = 1,
  53816. /** Fragment shader */
  53817. Fragment = 2,
  53818. /** Neutral */
  53819. Neutral = 4,
  53820. /** Vertex and Fragment */
  53821. VertexAndFragment = 3
  53822. }
  53823. }
  53824. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53825. /**
  53826. * Defines the kind of connection point for node based material
  53827. */
  53828. export enum NodeMaterialBlockConnectionPointTypes {
  53829. /** Float */
  53830. Float = 1,
  53831. /** Int */
  53832. Int = 2,
  53833. /** Vector2 */
  53834. Vector2 = 4,
  53835. /** Vector3 */
  53836. Vector3 = 8,
  53837. /** Vector4 */
  53838. Vector4 = 16,
  53839. /** Color3 */
  53840. Color3 = 32,
  53841. /** Color4 */
  53842. Color4 = 64,
  53843. /** Matrix */
  53844. Matrix = 128,
  53845. /** Detect type based on connection */
  53846. AutoDetect = 1024,
  53847. /** Output type that will be defined by input type */
  53848. BasedOnInput = 2048
  53849. }
  53850. }
  53851. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53853. /**
  53854. * Root class for all node material optimizers
  53855. */
  53856. export class NodeMaterialOptimizer {
  53857. /**
  53858. * Function used to optimize a NodeMaterial graph
  53859. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53860. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53861. */
  53862. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53863. }
  53864. }
  53865. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53869. import { Scene } from "babylonjs/scene";
  53870. /**
  53871. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53872. */
  53873. export class TransformBlock extends NodeMaterialBlock {
  53874. /**
  53875. * Defines the value to use to complement W value to transform it to a Vector4
  53876. */
  53877. complementW: number;
  53878. /**
  53879. * Defines the value to use to complement z value to transform it to a Vector4
  53880. */
  53881. complementZ: number;
  53882. /**
  53883. * Creates a new TransformBlock
  53884. * @param name defines the block name
  53885. */
  53886. constructor(name: string);
  53887. /**
  53888. * Gets the current class name
  53889. * @returns the class name
  53890. */
  53891. getClassName(): string;
  53892. /**
  53893. * Gets the vector input
  53894. */
  53895. readonly vector: NodeMaterialConnectionPoint;
  53896. /**
  53897. * Gets the output component
  53898. */
  53899. readonly output: NodeMaterialConnectionPoint;
  53900. /**
  53901. * Gets the matrix transform input
  53902. */
  53903. readonly transform: NodeMaterialConnectionPoint;
  53904. protected _buildBlock(state: NodeMaterialBuildState): this;
  53905. serialize(): any;
  53906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53907. }
  53908. }
  53909. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53913. /**
  53914. * Block used to output the vertex position
  53915. */
  53916. export class VertexOutputBlock extends NodeMaterialBlock {
  53917. /**
  53918. * Creates a new VertexOutputBlock
  53919. * @param name defines the block name
  53920. */
  53921. constructor(name: string);
  53922. /**
  53923. * Gets the current class name
  53924. * @returns the class name
  53925. */
  53926. getClassName(): string;
  53927. /**
  53928. * Gets the vector input component
  53929. */
  53930. readonly vector: NodeMaterialConnectionPoint;
  53931. protected _buildBlock(state: NodeMaterialBuildState): this;
  53932. }
  53933. }
  53934. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53938. /**
  53939. * Block used to output the final color
  53940. */
  53941. export class FragmentOutputBlock extends NodeMaterialBlock {
  53942. /**
  53943. * Create a new FragmentOutputBlock
  53944. * @param name defines the block name
  53945. */
  53946. constructor(name: string);
  53947. /**
  53948. * Gets the current class name
  53949. * @returns the class name
  53950. */
  53951. getClassName(): string;
  53952. /**
  53953. * Gets the rgba input component
  53954. */
  53955. readonly rgba: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the rgb input component
  53958. */
  53959. readonly rgb: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the a input component
  53962. */
  53963. readonly a: NodeMaterialConnectionPoint;
  53964. protected _buildBlock(state: NodeMaterialBuildState): this;
  53965. }
  53966. }
  53967. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53969. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53970. import { Scene } from "babylonjs/scene";
  53971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53972. import { Matrix } from "babylonjs/Maths/math.vector";
  53973. import { Mesh } from "babylonjs/Meshes/mesh";
  53974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53975. import { Observable } from "babylonjs/Misc/observable";
  53976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53977. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53978. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53979. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53980. import { Nullable } from "babylonjs/types";
  53981. /**
  53982. * Interface used to configure the node material editor
  53983. */
  53984. export interface INodeMaterialEditorOptions {
  53985. /** Define the URl to load node editor script */
  53986. editorURL?: string;
  53987. }
  53988. /** @hidden */
  53989. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53990. /** BONES */
  53991. NUM_BONE_INFLUENCERS: number;
  53992. BonesPerMesh: number;
  53993. BONETEXTURE: boolean;
  53994. /** MORPH TARGETS */
  53995. MORPHTARGETS: boolean;
  53996. MORPHTARGETS_NORMAL: boolean;
  53997. MORPHTARGETS_TANGENT: boolean;
  53998. MORPHTARGETS_UV: boolean;
  53999. NUM_MORPH_INFLUENCERS: number;
  54000. /** IMAGE PROCESSING */
  54001. IMAGEPROCESSING: boolean;
  54002. VIGNETTE: boolean;
  54003. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54004. VIGNETTEBLENDMODEOPAQUE: boolean;
  54005. TONEMAPPING: boolean;
  54006. TONEMAPPING_ACES: boolean;
  54007. CONTRAST: boolean;
  54008. EXPOSURE: boolean;
  54009. COLORCURVES: boolean;
  54010. COLORGRADING: boolean;
  54011. COLORGRADING3D: boolean;
  54012. SAMPLER3DGREENDEPTH: boolean;
  54013. SAMPLER3DBGRMAP: boolean;
  54014. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54015. constructor();
  54016. setValue(name: string, value: boolean): void;
  54017. }
  54018. /**
  54019. * Class used to configure NodeMaterial
  54020. */
  54021. export interface INodeMaterialOptions {
  54022. /**
  54023. * Defines if blocks should emit comments
  54024. */
  54025. emitComments: boolean;
  54026. }
  54027. /**
  54028. * Class used to create a node based material built by assembling shader blocks
  54029. */
  54030. export class NodeMaterial extends PushMaterial {
  54031. private static _BuildIdGenerator;
  54032. private _options;
  54033. private _vertexCompilationState;
  54034. private _fragmentCompilationState;
  54035. private _sharedData;
  54036. private _buildId;
  54037. private _buildWasSuccessful;
  54038. private _cachedWorldViewMatrix;
  54039. private _cachedWorldViewProjectionMatrix;
  54040. private _optimizers;
  54041. /** Define the URl to load node editor script */
  54042. static EditorURL: string;
  54043. private BJSNODEMATERIALEDITOR;
  54044. /** Get the inspector from bundle or global */
  54045. private _getGlobalNodeMaterialEditor;
  54046. /**
  54047. * 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)
  54048. */
  54049. ignoreAlpha: boolean;
  54050. /**
  54051. * Defines the maximum number of lights that can be used in the material
  54052. */
  54053. maxSimultaneousLights: number;
  54054. /**
  54055. * Observable raised when the material is built
  54056. */
  54057. onBuildObservable: Observable<NodeMaterial>;
  54058. /**
  54059. * Gets or sets the root nodes of the material vertex shader
  54060. */
  54061. _vertexOutputNodes: NodeMaterialBlock[];
  54062. /**
  54063. * Gets or sets the root nodes of the material fragment (pixel) shader
  54064. */
  54065. _fragmentOutputNodes: NodeMaterialBlock[];
  54066. /** Gets or sets options to control the node material overall behavior */
  54067. options: INodeMaterialOptions;
  54068. /**
  54069. * Default configuration related to image processing available in the standard Material.
  54070. */
  54071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54072. /**
  54073. * Gets the image processing configuration used either in this material.
  54074. */
  54075. /**
  54076. * Sets the Default image processing configuration used either in the this material.
  54077. *
  54078. * If sets to null, the scene one is in use.
  54079. */
  54080. imageProcessingConfiguration: ImageProcessingConfiguration;
  54081. /**
  54082. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54083. */
  54084. attachedBlocks: NodeMaterialBlock[];
  54085. /**
  54086. * Create a new node based material
  54087. * @param name defines the material name
  54088. * @param scene defines the hosting scene
  54089. * @param options defines creation option
  54090. */
  54091. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54092. /**
  54093. * Gets the current class name of the material e.g. "NodeMaterial"
  54094. * @returns the class name
  54095. */
  54096. getClassName(): string;
  54097. /**
  54098. * Keep track of the image processing observer to allow dispose and replace.
  54099. */
  54100. private _imageProcessingObserver;
  54101. /**
  54102. * Attaches a new image processing configuration to the Standard Material.
  54103. * @param configuration
  54104. */
  54105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54106. /**
  54107. * Adds a new optimizer to the list of optimizers
  54108. * @param optimizer defines the optimizers to add
  54109. * @returns the current material
  54110. */
  54111. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54112. /**
  54113. * Remove an optimizer from the list of optimizers
  54114. * @param optimizer defines the optimizers to remove
  54115. * @returns the current material
  54116. */
  54117. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54118. /**
  54119. * Add a new block to the list of output nodes
  54120. * @param node defines the node to add
  54121. * @returns the current material
  54122. */
  54123. addOutputNode(node: NodeMaterialBlock): this;
  54124. /**
  54125. * Remove a block from the list of root nodes
  54126. * @param node defines the node to remove
  54127. * @returns the current material
  54128. */
  54129. removeOutputNode(node: NodeMaterialBlock): this;
  54130. private _addVertexOutputNode;
  54131. private _removeVertexOutputNode;
  54132. private _addFragmentOutputNode;
  54133. private _removeFragmentOutputNode;
  54134. /**
  54135. * Specifies if the material will require alpha blending
  54136. * @returns a boolean specifying if alpha blending is needed
  54137. */
  54138. needAlphaBlending(): boolean;
  54139. /**
  54140. * Specifies if this material should be rendered in alpha test mode
  54141. * @returns a boolean specifying if an alpha test is needed.
  54142. */
  54143. needAlphaTesting(): boolean;
  54144. private _initializeBlock;
  54145. private _resetDualBlocks;
  54146. /**
  54147. * Build the material and generates the inner effect
  54148. * @param verbose defines if the build should log activity
  54149. */
  54150. build(verbose?: boolean): void;
  54151. /**
  54152. * Runs an otpimization phase to try to improve the shader code
  54153. */
  54154. optimize(): void;
  54155. private _prepareDefinesForAttributes;
  54156. /**
  54157. * Get if the submesh is ready to be used and all its information available.
  54158. * Child classes can use it to update shaders
  54159. * @param mesh defines the mesh to check
  54160. * @param subMesh defines which submesh to check
  54161. * @param useInstances specifies that instances should be used
  54162. * @returns a boolean indicating that the submesh is ready or not
  54163. */
  54164. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54165. /**
  54166. * Get a string representing the shaders built by the current node graph
  54167. */
  54168. readonly compiledShaders: string;
  54169. /**
  54170. * Binds the world matrix to the material
  54171. * @param world defines the world transformation matrix
  54172. */
  54173. bindOnlyWorldMatrix(world: Matrix): void;
  54174. /**
  54175. * Binds the submesh to this material by preparing the effect and shader to draw
  54176. * @param world defines the world transformation matrix
  54177. * @param mesh defines the mesh containing the submesh
  54178. * @param subMesh defines the submesh to bind the material to
  54179. */
  54180. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54181. /**
  54182. * Gets the active textures from the material
  54183. * @returns an array of textures
  54184. */
  54185. getActiveTextures(): BaseTexture[];
  54186. /**
  54187. * Specifies if the material uses a texture
  54188. * @param texture defines the texture to check against the material
  54189. * @returns a boolean specifying if the material uses the texture
  54190. */
  54191. hasTexture(texture: BaseTexture): boolean;
  54192. /**
  54193. * Disposes the material
  54194. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54195. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54196. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54197. */
  54198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54199. /** Creates the node editor window. */
  54200. private _createNodeEditor;
  54201. /**
  54202. * Launch the node material editor
  54203. * @param config Define the configuration of the editor
  54204. * @return a promise fulfilled when the node editor is visible
  54205. */
  54206. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54207. /**
  54208. * Clear the current material
  54209. */
  54210. clear(): void;
  54211. /**
  54212. * Clear the current material and set it to a default state
  54213. */
  54214. setToDefault(): void;
  54215. private _gatherBlocks;
  54216. /**
  54217. * Serializes this material in a JSON representation
  54218. * @returns the serialized material object
  54219. */
  54220. serialize(): any;
  54221. /**
  54222. * Clear the current graph and load a new one from a serialization object
  54223. * @param source defines the JSON representation of the material
  54224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54225. */
  54226. loadFromSerialization(source: any, rootUrl?: string): void;
  54227. /**
  54228. * Creates a node material from parsed material data
  54229. * @param source defines the JSON representation of the material
  54230. * @param scene defines the hosting scene
  54231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54232. * @returns a new node material
  54233. */
  54234. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54235. }
  54236. }
  54237. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54244. import { Effect } from "babylonjs/Materials/effect";
  54245. import { Mesh } from "babylonjs/Meshes/mesh";
  54246. import { Nullable } from "babylonjs/types";
  54247. import { Scene } from "babylonjs/scene";
  54248. /**
  54249. * Block used to read a texture from a sampler
  54250. */
  54251. export class TextureBlock extends NodeMaterialBlock {
  54252. private _defineName;
  54253. private _samplerName;
  54254. private _transformedUVName;
  54255. private _textureTransformName;
  54256. private _textureInfoName;
  54257. private _mainUVName;
  54258. private _mainUVDefineName;
  54259. /**
  54260. * Gets or sets the texture associated with the node
  54261. */
  54262. texture: Nullable<BaseTexture>;
  54263. /**
  54264. * Create a new TextureBlock
  54265. * @param name defines the block name
  54266. */
  54267. constructor(name: string);
  54268. /**
  54269. * Gets the current class name
  54270. * @returns the class name
  54271. */
  54272. getClassName(): string;
  54273. /**
  54274. * Gets the uv input component
  54275. */
  54276. readonly uv: NodeMaterialConnectionPoint;
  54277. /**
  54278. * Gets the output component
  54279. */
  54280. readonly output: NodeMaterialConnectionPoint;
  54281. autoConfigure(): void;
  54282. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54283. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54284. isReady(): boolean;
  54285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54286. private _injectVertexCode;
  54287. private _writeOutput;
  54288. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54289. serialize(): any;
  54290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54291. }
  54292. }
  54293. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54296. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54297. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54298. /**
  54299. * Class used to store shared data between 2 NodeMaterialBuildState
  54300. */
  54301. export class NodeMaterialBuildStateSharedData {
  54302. /**
  54303. * Gets the list of emitted varyings
  54304. */
  54305. varyings: string[];
  54306. /**
  54307. * Gets the varying declaration string
  54308. */
  54309. varyingDeclaration: string;
  54310. /**
  54311. * Input blocks
  54312. */
  54313. inputBlocks: InputBlock[];
  54314. /**
  54315. * Input blocks
  54316. */
  54317. textureBlocks: TextureBlock[];
  54318. /**
  54319. * Bindable blocks (Blocks that need to set data to the effect)
  54320. */
  54321. bindableBlocks: NodeMaterialBlock[];
  54322. /**
  54323. * List of blocks that can provide a compilation fallback
  54324. */
  54325. blocksWithFallbacks: NodeMaterialBlock[];
  54326. /**
  54327. * List of blocks that can provide a define update
  54328. */
  54329. blocksWithDefines: NodeMaterialBlock[];
  54330. /**
  54331. * List of blocks that can provide a repeatable content
  54332. */
  54333. repeatableContentBlocks: NodeMaterialBlock[];
  54334. /**
  54335. * List of blocks that can provide a dynamic list of uniforms
  54336. */
  54337. dynamicUniformBlocks: NodeMaterialBlock[];
  54338. /**
  54339. * List of blocks that can block the isReady function for the material
  54340. */
  54341. blockingBlocks: NodeMaterialBlock[];
  54342. /**
  54343. * Build Id used to avoid multiple recompilations
  54344. */
  54345. buildId: number;
  54346. /** List of emitted variables */
  54347. variableNames: {
  54348. [key: string]: number;
  54349. };
  54350. /** List of emitted defines */
  54351. defineNames: {
  54352. [key: string]: number;
  54353. };
  54354. /** Should emit comments? */
  54355. emitComments: boolean;
  54356. /** Emit build activity */
  54357. verbose: boolean;
  54358. /**
  54359. * Gets the compilation hints emitted at compilation time
  54360. */
  54361. hints: {
  54362. needWorldViewMatrix: boolean;
  54363. needWorldViewProjectionMatrix: boolean;
  54364. needAlphaBlending: boolean;
  54365. needAlphaTesting: boolean;
  54366. };
  54367. /**
  54368. * List of compilation checks
  54369. */
  54370. checks: {
  54371. emitVertex: boolean;
  54372. emitFragment: boolean;
  54373. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54374. };
  54375. /** Creates a new shared data */
  54376. constructor();
  54377. /**
  54378. * Emits console errors and exceptions if there is a failing check
  54379. */
  54380. emitErrors(): void;
  54381. }
  54382. }
  54383. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54384. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54385. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54386. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54387. /**
  54388. * Class used to store node based material build state
  54389. */
  54390. export class NodeMaterialBuildState {
  54391. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54392. supportUniformBuffers: boolean;
  54393. /**
  54394. * Gets the list of emitted attributes
  54395. */
  54396. attributes: string[];
  54397. /**
  54398. * Gets the list of emitted uniforms
  54399. */
  54400. uniforms: string[];
  54401. /**
  54402. * Gets the list of emitted uniform buffers
  54403. */
  54404. uniformBuffers: string[];
  54405. /**
  54406. * Gets the list of emitted samplers
  54407. */
  54408. samplers: string[];
  54409. /**
  54410. * Gets the list of emitted functions
  54411. */
  54412. functions: {
  54413. [key: string]: string;
  54414. };
  54415. /**
  54416. * Gets the target of the compilation state
  54417. */
  54418. target: NodeMaterialBlockTargets;
  54419. /**
  54420. * Gets the list of emitted counters
  54421. */
  54422. counters: {
  54423. [key: string]: number;
  54424. };
  54425. /**
  54426. * Shared data between multiple NodeMaterialBuildState instances
  54427. */
  54428. sharedData: NodeMaterialBuildStateSharedData;
  54429. /** @hidden */
  54430. _vertexState: NodeMaterialBuildState;
  54431. /** @hidden */
  54432. _attributeDeclaration: string;
  54433. /** @hidden */
  54434. _uniformDeclaration: string;
  54435. /** @hidden */
  54436. _samplerDeclaration: string;
  54437. /** @hidden */
  54438. _varyingTransfer: string;
  54439. private _repeatableContentAnchorIndex;
  54440. /** @hidden */
  54441. _builtCompilationString: string;
  54442. /**
  54443. * Gets the emitted compilation strings
  54444. */
  54445. compilationString: string;
  54446. /**
  54447. * Finalize the compilation strings
  54448. * @param state defines the current compilation state
  54449. */
  54450. finalize(state: NodeMaterialBuildState): void;
  54451. /** @hidden */
  54452. readonly _repeatableContentAnchor: string;
  54453. /** @hidden */
  54454. _getFreeVariableName(prefix: string): string;
  54455. /** @hidden */
  54456. _getFreeDefineName(prefix: string): string;
  54457. /** @hidden */
  54458. _excludeVariableName(name: string): void;
  54459. /** @hidden */
  54460. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54461. /** @hidden */
  54462. _emitFunction(name: string, code: string, comments: string): void;
  54463. /** @hidden */
  54464. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54465. replaceStrings?: {
  54466. search: RegExp;
  54467. replace: string;
  54468. }[];
  54469. repeatKey?: string;
  54470. }): string;
  54471. /** @hidden */
  54472. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54473. repeatKey?: string;
  54474. removeAttributes?: boolean;
  54475. removeUniforms?: boolean;
  54476. removeVaryings?: boolean;
  54477. removeIfDef?: boolean;
  54478. replaceStrings?: {
  54479. search: RegExp;
  54480. replace: string;
  54481. }[];
  54482. }, storeKey?: string): void;
  54483. /** @hidden */
  54484. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54485. /** @hidden */
  54486. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54487. }
  54488. }
  54489. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54490. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54492. import { Nullable } from "babylonjs/types";
  54493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54494. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54495. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54497. import { Mesh } from "babylonjs/Meshes/mesh";
  54498. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54499. import { Scene } from "babylonjs/scene";
  54500. /**
  54501. * Defines a block that can be used inside a node based material
  54502. */
  54503. export class NodeMaterialBlock {
  54504. private _buildId;
  54505. private _buildTarget;
  54506. private _target;
  54507. private _isFinalMerger;
  54508. private _isInput;
  54509. /** @hidden */
  54510. _inputs: NodeMaterialConnectionPoint[];
  54511. /** @hidden */
  54512. _outputs: NodeMaterialConnectionPoint[];
  54513. /**
  54514. * Gets or sets the name of the block
  54515. */
  54516. name: string;
  54517. /**
  54518. * Gets or sets the unique id of the node
  54519. */
  54520. uniqueId: number;
  54521. /**
  54522. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54523. */
  54524. readonly isFinalMerger: boolean;
  54525. /**
  54526. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54527. */
  54528. readonly isInput: boolean;
  54529. /**
  54530. * Gets or sets the build Id
  54531. */
  54532. buildId: number;
  54533. /**
  54534. * Gets or sets the target of the block
  54535. */
  54536. target: NodeMaterialBlockTargets;
  54537. /**
  54538. * Gets the list of input points
  54539. */
  54540. readonly inputs: NodeMaterialConnectionPoint[];
  54541. /** Gets the list of output points */
  54542. readonly outputs: NodeMaterialConnectionPoint[];
  54543. /**
  54544. * Find an input by its name
  54545. * @param name defines the name of the input to look for
  54546. * @returns the input or null if not found
  54547. */
  54548. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54549. /**
  54550. * Find an output by its name
  54551. * @param name defines the name of the outputto look for
  54552. * @returns the output or null if not found
  54553. */
  54554. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54555. /**
  54556. * Creates a new NodeMaterialBlock
  54557. * @param name defines the block name
  54558. * @param target defines the target of that block (Vertex by default)
  54559. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54560. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54561. */
  54562. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54563. /**
  54564. * Initialize the block and prepare the context for build
  54565. * @param state defines the state that will be used for the build
  54566. */
  54567. initialize(state: NodeMaterialBuildState): void;
  54568. /**
  54569. * Bind data to effect. Will only be called for blocks with isBindable === true
  54570. * @param effect defines the effect to bind data to
  54571. * @param nodeMaterial defines the hosting NodeMaterial
  54572. * @param mesh defines the mesh that will be rendered
  54573. */
  54574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54575. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54576. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54577. protected _writeFloat(value: number): string;
  54578. /**
  54579. * Gets the current class name e.g. "NodeMaterialBlock"
  54580. * @returns the class name
  54581. */
  54582. getClassName(): string;
  54583. /**
  54584. * Register a new input. Must be called inside a block constructor
  54585. * @param name defines the connection point name
  54586. * @param type defines the connection point type
  54587. * @param isOptional defines a boolean indicating that this input can be omitted
  54588. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54589. * @returns the current block
  54590. */
  54591. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54592. /**
  54593. * Register a new output. Must be called inside a block constructor
  54594. * @param name defines the connection point name
  54595. * @param type defines the connection point type
  54596. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54597. * @returns the current block
  54598. */
  54599. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54600. /**
  54601. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54602. * @param forOutput defines an optional connection point to check compatibility with
  54603. * @returns the first available input or null
  54604. */
  54605. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54606. /**
  54607. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54608. * @param forBlock defines an optional block to check compatibility with
  54609. * @returns the first available input or null
  54610. */
  54611. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54612. /**
  54613. * Connect current block with another block
  54614. * @param other defines the block to connect with
  54615. * @param options define the various options to help pick the right connections
  54616. * @returns the current block
  54617. */
  54618. connectTo(other: NodeMaterialBlock, options?: {
  54619. input?: string;
  54620. output?: string;
  54621. outputSwizzle?: string;
  54622. }): this | undefined;
  54623. protected _buildBlock(state: NodeMaterialBuildState): void;
  54624. /**
  54625. * Add uniforms, samplers and uniform buffers at compilation time
  54626. * @param state defines the state to update
  54627. * @param nodeMaterial defines the node material requesting the update
  54628. * @param defines defines the material defines to update
  54629. */
  54630. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54631. /**
  54632. * Add potential fallbacks if shader compilation fails
  54633. * @param mesh defines the mesh to be rendered
  54634. * @param fallbacks defines the current prioritized list of fallbacks
  54635. */
  54636. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54637. /**
  54638. * Update defines for shader compilation
  54639. * @param mesh defines the mesh to be rendered
  54640. * @param nodeMaterial defines the node material requesting the update
  54641. * @param defines defines the material defines to update
  54642. * @param useInstances specifies that instances should be used
  54643. */
  54644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54645. /**
  54646. * Initialize defines for shader compilation
  54647. * @param mesh defines the mesh to be rendered
  54648. * @param nodeMaterial defines the node material requesting the update
  54649. * @param defines defines the material defines to be prepared
  54650. * @param useInstances specifies that instances should be used
  54651. */
  54652. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54653. /**
  54654. * Lets the block try to connect some inputs automatically
  54655. */
  54656. autoConfigure(): void;
  54657. /**
  54658. * Function called when a block is declared as repeatable content generator
  54659. * @param vertexShaderState defines the current compilation state for the vertex shader
  54660. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54661. * @param mesh defines the mesh to be rendered
  54662. * @param defines defines the material defines to update
  54663. */
  54664. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54665. /**
  54666. * Checks if the block is ready
  54667. * @param mesh defines the mesh to be rendered
  54668. * @param nodeMaterial defines the node material requesting the update
  54669. * @param defines defines the material defines to update
  54670. * @param useInstances specifies that instances should be used
  54671. * @returns true if the block is ready
  54672. */
  54673. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54674. private _processBuild;
  54675. /**
  54676. * Compile the current node and generate the shader code
  54677. * @param state defines the current compilation state (uniforms, samplers, current string)
  54678. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54679. * @returns true if already built
  54680. */
  54681. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54682. /**
  54683. * Serializes this block in a JSON representation
  54684. * @returns the serialized block object
  54685. */
  54686. serialize(): any;
  54687. /** @hidden */
  54688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54689. }
  54690. }
  54691. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54692. /**
  54693. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54694. */
  54695. export enum NodeMaterialBlockConnectionPointMode {
  54696. /** Value is an uniform */
  54697. Uniform = 0,
  54698. /** Value is a mesh attribute */
  54699. Attribute = 1,
  54700. /** Value is a varying between vertex and fragment shaders */
  54701. Varying = 2,
  54702. /** Mode is undefined */
  54703. Undefined = 3
  54704. }
  54705. }
  54706. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54707. /**
  54708. * Enum used to define well known values e.g. values automatically provided by the system
  54709. */
  54710. export enum NodeMaterialWellKnownValues {
  54711. /** World */
  54712. World = 1,
  54713. /** View */
  54714. View = 2,
  54715. /** Projection */
  54716. Projection = 3,
  54717. /** ViewProjection */
  54718. ViewProjection = 4,
  54719. /** WorldView */
  54720. WorldView = 5,
  54721. /** WorldViewProjection */
  54722. WorldViewProjection = 6,
  54723. /** CameraPosition */
  54724. CameraPosition = 7,
  54725. /** Fog Color */
  54726. FogColor = 8
  54727. }
  54728. }
  54729. declare module "babylonjs/Maths/math.vertexFormat" {
  54730. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54731. /**
  54732. * Contains position and normal vectors for a vertex
  54733. */
  54734. export class PositionNormalVertex {
  54735. /** the position of the vertex (defaut: 0,0,0) */
  54736. position: Vector3;
  54737. /** the normal of the vertex (defaut: 0,1,0) */
  54738. normal: Vector3;
  54739. /**
  54740. * Creates a PositionNormalVertex
  54741. * @param position the position of the vertex (defaut: 0,0,0)
  54742. * @param normal the normal of the vertex (defaut: 0,1,0)
  54743. */
  54744. constructor(
  54745. /** the position of the vertex (defaut: 0,0,0) */
  54746. position?: Vector3,
  54747. /** the normal of the vertex (defaut: 0,1,0) */
  54748. normal?: Vector3);
  54749. /**
  54750. * Clones the PositionNormalVertex
  54751. * @returns the cloned PositionNormalVertex
  54752. */
  54753. clone(): PositionNormalVertex;
  54754. }
  54755. /**
  54756. * Contains position, normal and uv vectors for a vertex
  54757. */
  54758. export class PositionNormalTextureVertex {
  54759. /** the position of the vertex (defaut: 0,0,0) */
  54760. position: Vector3;
  54761. /** the normal of the vertex (defaut: 0,1,0) */
  54762. normal: Vector3;
  54763. /** the uv of the vertex (default: 0,0) */
  54764. uv: Vector2;
  54765. /**
  54766. * Creates a PositionNormalTextureVertex
  54767. * @param position the position of the vertex (defaut: 0,0,0)
  54768. * @param normal the normal of the vertex (defaut: 0,1,0)
  54769. * @param uv the uv of the vertex (default: 0,0)
  54770. */
  54771. constructor(
  54772. /** the position of the vertex (defaut: 0,0,0) */
  54773. position?: Vector3,
  54774. /** the normal of the vertex (defaut: 0,1,0) */
  54775. normal?: Vector3,
  54776. /** the uv of the vertex (default: 0,0) */
  54777. uv?: Vector2);
  54778. /**
  54779. * Clones the PositionNormalTextureVertex
  54780. * @returns the cloned PositionNormalTextureVertex
  54781. */
  54782. clone(): PositionNormalTextureVertex;
  54783. }
  54784. }
  54785. declare module "babylonjs/Maths/math" {
  54786. export * from "babylonjs/Maths/math.axis";
  54787. export * from "babylonjs/Maths/math.color";
  54788. export * from "babylonjs/Maths/math.constants";
  54789. export * from "babylonjs/Maths/math.frustum";
  54790. export * from "babylonjs/Maths/math.path";
  54791. export * from "babylonjs/Maths/math.plane";
  54792. export * from "babylonjs/Maths/math.size";
  54793. export * from "babylonjs/Maths/math.vector";
  54794. export * from "babylonjs/Maths/math.vertexFormat";
  54795. export * from "babylonjs/Maths/math.viewport";
  54796. }
  54797. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54799. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54800. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54801. import { Nullable } from "babylonjs/types";
  54802. import { Effect } from "babylonjs/Materials/effect";
  54803. import { Matrix } from "babylonjs/Maths/math.vector";
  54804. import { Scene } from "babylonjs/scene";
  54805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54807. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54808. /**
  54809. * Block used to expose an input value
  54810. */
  54811. export class InputBlock extends NodeMaterialBlock {
  54812. private _mode;
  54813. private _associatedVariableName;
  54814. private _storedValue;
  54815. private _valueCallback;
  54816. private _type;
  54817. /** @hidden */
  54818. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54819. /**
  54820. * Gets or sets the connection point type (default is float)
  54821. */
  54822. readonly type: NodeMaterialBlockConnectionPointTypes;
  54823. /**
  54824. * Creates a new InputBlock
  54825. * @param name defines the block name
  54826. * @param target defines the target of that block (Vertex by default)
  54827. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54828. */
  54829. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54830. /**
  54831. * Gets the output component
  54832. */
  54833. readonly output: NodeMaterialConnectionPoint;
  54834. /**
  54835. * Set the source of this connection point to a vertex attribute
  54836. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54837. * @returns the current connection point
  54838. */
  54839. setAsAttribute(attributeName?: string): InputBlock;
  54840. /**
  54841. * Set the source of this connection point to a well known value
  54842. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54843. * @returns the current connection point
  54844. */
  54845. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54846. /**
  54847. * Gets or sets the value of that point.
  54848. * Please note that this value will be ignored if valueCallback is defined
  54849. */
  54850. value: any;
  54851. /**
  54852. * Gets or sets a callback used to get the value of that point.
  54853. * Please note that setting this value will force the connection point to ignore the value property
  54854. */
  54855. valueCallback: () => any;
  54856. /**
  54857. * Gets or sets the associated variable name in the shader
  54858. */
  54859. associatedVariableName: string;
  54860. /**
  54861. * Gets a boolean indicating that this connection point not defined yet
  54862. */
  54863. readonly isUndefined: boolean;
  54864. /**
  54865. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54866. * In this case the connection point name must be the name of the uniform to use.
  54867. * Can only be set on inputs
  54868. */
  54869. isUniform: boolean;
  54870. /**
  54871. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54872. * In this case the connection point name must be the name of the attribute to use
  54873. * Can only be set on inputs
  54874. */
  54875. isAttribute: boolean;
  54876. /**
  54877. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54878. * Can only be set on exit points
  54879. */
  54880. isVarying: boolean;
  54881. /**
  54882. * Gets a boolean indicating that the current connection point is a well known value
  54883. */
  54884. readonly isWellKnownValue: boolean;
  54885. /**
  54886. * Gets or sets the current well known value or null if not defined as well know value
  54887. */
  54888. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54889. /**
  54890. * Gets the current class name
  54891. * @returns the class name
  54892. */
  54893. getClassName(): string;
  54894. private _emitDefine;
  54895. /**
  54896. * Set the input block to its default value (based on its type)
  54897. */
  54898. setDefaultValue(): void;
  54899. private _emit;
  54900. /** @hidden */
  54901. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54902. /** @hidden */
  54903. _transmit(effect: Effect, scene: Scene): void;
  54904. protected _buildBlock(state: NodeMaterialBuildState): void;
  54905. serialize(): any;
  54906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54907. }
  54908. }
  54909. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54910. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54911. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54912. import { Nullable } from "babylonjs/types";
  54913. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54915. /**
  54916. * Defines a connection point for a block
  54917. */
  54918. export class NodeMaterialConnectionPoint {
  54919. /** @hidden */
  54920. _ownerBlock: NodeMaterialBlock;
  54921. /** @hidden */
  54922. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54923. private _endpoints;
  54924. private _associatedVariableName;
  54925. /** @hidden */
  54926. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54927. private _type;
  54928. /** @hidden */
  54929. _enforceAssociatedVariableName: boolean;
  54930. /**
  54931. * Gets or sets the additional types supported byt this connection point
  54932. */
  54933. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54934. /**
  54935. * Gets or sets the associated variable name in the shader
  54936. */
  54937. associatedVariableName: string;
  54938. /**
  54939. * Gets or sets the connection point type (default is float)
  54940. */
  54941. type: NodeMaterialBlockConnectionPointTypes;
  54942. /**
  54943. * Gets or sets the connection point name
  54944. */
  54945. name: string;
  54946. /**
  54947. * Gets or sets a boolean indicating that this connection point can be omitted
  54948. */
  54949. isOptional: boolean;
  54950. /**
  54951. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54952. */
  54953. define: string;
  54954. /** Gets or sets the target of that connection point */
  54955. target: NodeMaterialBlockTargets;
  54956. /**
  54957. * Gets a boolean indicating that the current point is connected
  54958. */
  54959. readonly isConnected: boolean;
  54960. /**
  54961. * Gets a boolean indicating that the current point is connected to an input block
  54962. */
  54963. readonly isConnectedToInput: boolean;
  54964. /**
  54965. * Gets a the connected input block (if any)
  54966. */
  54967. readonly connectInputBlock: Nullable<InputBlock>;
  54968. /** Get the other side of the connection (if any) */
  54969. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54970. /** Get the block that owns this connection point */
  54971. readonly ownerBlock: NodeMaterialBlock;
  54972. /** Get the block connected on the other side of this connection (if any) */
  54973. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54974. /** Get the block connected on the endpoints of this connection (if any) */
  54975. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54976. /** Gets the list of connected endpoints */
  54977. readonly endpoints: NodeMaterialConnectionPoint[];
  54978. /**
  54979. * Creates a new connection point
  54980. * @param name defines the connection point name
  54981. * @param ownerBlock defines the block hosting this connection point
  54982. */
  54983. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54984. /**
  54985. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54986. * @returns the class name
  54987. */
  54988. getClassName(): string;
  54989. /**
  54990. * Gets an boolean indicating if the current point can be connected to another point
  54991. * @param connectionPoint defines the other connection point
  54992. * @returns true if the connection is possible
  54993. */
  54994. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54995. /**
  54996. * Connect this point to another connection point
  54997. * @param connectionPoint defines the other connection point
  54998. * @returns the current connection point
  54999. */
  55000. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55001. /**
  55002. * Disconnect this point from one of his endpoint
  55003. * @param endpoint defines the other connection point
  55004. * @returns the current connection point
  55005. */
  55006. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55007. /**
  55008. * Serializes this point in a JSON representation
  55009. * @returns the serialized point object
  55010. */
  55011. serialize(): any;
  55012. }
  55013. }
  55014. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55018. import { Mesh } from "babylonjs/Meshes/mesh";
  55019. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55021. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55022. /**
  55023. * Block used to add support for vertex skinning (bones)
  55024. */
  55025. export class BonesBlock extends NodeMaterialBlock {
  55026. /**
  55027. * Creates a new BonesBlock
  55028. * @param name defines the block name
  55029. */
  55030. constructor(name: string);
  55031. /**
  55032. * Initialize the block and prepare the context for build
  55033. * @param state defines the state that will be used for the build
  55034. */
  55035. initialize(state: NodeMaterialBuildState): void;
  55036. /**
  55037. * Gets the current class name
  55038. * @returns the class name
  55039. */
  55040. getClassName(): string;
  55041. /**
  55042. * Gets the matrix indices input component
  55043. */
  55044. readonly matricesIndices: NodeMaterialConnectionPoint;
  55045. /**
  55046. * Gets the matrix weights input component
  55047. */
  55048. readonly matricesWeights: NodeMaterialConnectionPoint;
  55049. /**
  55050. * Gets the extra matrix indices input component
  55051. */
  55052. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55053. /**
  55054. * Gets the extra matrix weights input component
  55055. */
  55056. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55057. /**
  55058. * Gets the world input component
  55059. */
  55060. readonly world: NodeMaterialConnectionPoint;
  55061. /**
  55062. * Gets the output component
  55063. */
  55064. readonly output: NodeMaterialConnectionPoint;
  55065. autoConfigure(): void;
  55066. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55069. protected _buildBlock(state: NodeMaterialBuildState): this;
  55070. }
  55071. }
  55072. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55078. /**
  55079. * Block used to add support for instances
  55080. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55081. */
  55082. export class InstancesBlock extends NodeMaterialBlock {
  55083. /**
  55084. * Creates a new InstancesBlock
  55085. * @param name defines the block name
  55086. */
  55087. constructor(name: string);
  55088. /**
  55089. * Gets the current class name
  55090. * @returns the class name
  55091. */
  55092. getClassName(): string;
  55093. /**
  55094. * Gets the first world row input component
  55095. */
  55096. readonly world0: NodeMaterialConnectionPoint;
  55097. /**
  55098. * Gets the second world row input component
  55099. */
  55100. readonly world1: NodeMaterialConnectionPoint;
  55101. /**
  55102. * Gets the third world row input component
  55103. */
  55104. readonly world2: NodeMaterialConnectionPoint;
  55105. /**
  55106. * Gets the forth world row input component
  55107. */
  55108. readonly world3: NodeMaterialConnectionPoint;
  55109. /**
  55110. * Gets the world input component
  55111. */
  55112. readonly world: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the output component
  55115. */
  55116. readonly output: NodeMaterialConnectionPoint;
  55117. autoConfigure(): void;
  55118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55119. protected _buildBlock(state: NodeMaterialBuildState): this;
  55120. }
  55121. }
  55122. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55127. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55128. import { Effect } from "babylonjs/Materials/effect";
  55129. import { Mesh } from "babylonjs/Meshes/mesh";
  55130. /**
  55131. * Block used to add morph targets support to vertex shader
  55132. */
  55133. export class MorphTargetsBlock extends NodeMaterialBlock {
  55134. private _repeatableContentAnchor;
  55135. private _repeatebleContentGenerated;
  55136. /**
  55137. * Create a new MorphTargetsBlock
  55138. * @param name defines the block name
  55139. */
  55140. constructor(name: string);
  55141. /**
  55142. * Gets the current class name
  55143. * @returns the class name
  55144. */
  55145. getClassName(): string;
  55146. /**
  55147. * Gets the position input component
  55148. */
  55149. readonly position: NodeMaterialConnectionPoint;
  55150. /**
  55151. * Gets the normal input component
  55152. */
  55153. readonly normal: NodeMaterialConnectionPoint;
  55154. /**
  55155. * Gets the tangent input component
  55156. */
  55157. readonly tangent: NodeMaterialConnectionPoint;
  55158. /**
  55159. * Gets the tangent input component
  55160. */
  55161. readonly uv: NodeMaterialConnectionPoint;
  55162. /**
  55163. * Gets the position output component
  55164. */
  55165. readonly positionOutput: NodeMaterialConnectionPoint;
  55166. /**
  55167. * Gets the normal output component
  55168. */
  55169. readonly normalOutput: NodeMaterialConnectionPoint;
  55170. /**
  55171. * Gets the tangent output component
  55172. */
  55173. readonly tangentOutput: NodeMaterialConnectionPoint;
  55174. /**
  55175. * Gets the tangent output component
  55176. */
  55177. readonly uvOutput: NodeMaterialConnectionPoint;
  55178. initialize(state: NodeMaterialBuildState): void;
  55179. autoConfigure(): void;
  55180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55182. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55183. protected _buildBlock(state: NodeMaterialBuildState): this;
  55184. }
  55185. }
  55186. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55187. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55188. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55189. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55190. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55191. }
  55192. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55196. /**
  55197. * Block used to add an alpha test in the fragment shader
  55198. */
  55199. export class AlphaTestBlock extends NodeMaterialBlock {
  55200. /**
  55201. * Gets or sets the alpha value where alpha testing happens
  55202. */
  55203. alphaCutOff: number;
  55204. /**
  55205. * Create a new AlphaTestBlock
  55206. * @param name defines the block name
  55207. */
  55208. constructor(name: string);
  55209. /**
  55210. * Gets the current class name
  55211. * @returns the class name
  55212. */
  55213. getClassName(): string;
  55214. /**
  55215. * Gets the color input component
  55216. */
  55217. readonly color: NodeMaterialConnectionPoint;
  55218. /**
  55219. * Gets the alpha input component
  55220. */
  55221. readonly alpha: NodeMaterialConnectionPoint;
  55222. protected _buildBlock(state: NodeMaterialBuildState): this;
  55223. }
  55224. }
  55225. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  55226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55229. /**
  55230. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55231. */
  55232. export class ColorMergerBlock extends NodeMaterialBlock {
  55233. /**
  55234. * Create a new ColorMergerBlock
  55235. * @param name defines the block name
  55236. */
  55237. constructor(name: string);
  55238. /**
  55239. * Gets the current class name
  55240. * @returns the class name
  55241. */
  55242. getClassName(): string;
  55243. /**
  55244. * Gets the r component (input)
  55245. */
  55246. readonly r: NodeMaterialConnectionPoint;
  55247. /**
  55248. * Gets the g component (input)
  55249. */
  55250. readonly g: NodeMaterialConnectionPoint;
  55251. /**
  55252. * Gets the b component (input)
  55253. */
  55254. readonly b: NodeMaterialConnectionPoint;
  55255. /**
  55256. * Gets the a component (input)
  55257. */
  55258. readonly a: NodeMaterialConnectionPoint;
  55259. /**
  55260. * Gets the rgba component (output)
  55261. */
  55262. readonly rgba: NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the rgb component (output)
  55265. */
  55266. readonly rgb: NodeMaterialConnectionPoint;
  55267. protected _buildBlock(state: NodeMaterialBuildState): this;
  55268. }
  55269. }
  55270. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55274. /**
  55275. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55276. */
  55277. export class VectorMergerBlock extends NodeMaterialBlock {
  55278. /**
  55279. * Create a new VectorMergerBlock
  55280. * @param name defines the block name
  55281. */
  55282. constructor(name: string);
  55283. /**
  55284. * Gets the current class name
  55285. * @returns the class name
  55286. */
  55287. getClassName(): string;
  55288. /**
  55289. * Gets the x component (input)
  55290. */
  55291. readonly x: NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the y component (input)
  55294. */
  55295. readonly y: NodeMaterialConnectionPoint;
  55296. /**
  55297. * Gets the z component (input)
  55298. */
  55299. readonly z: NodeMaterialConnectionPoint;
  55300. /**
  55301. * Gets the w component (input)
  55302. */
  55303. readonly w: NodeMaterialConnectionPoint;
  55304. /**
  55305. * Gets the xyzw component (output)
  55306. */
  55307. readonly xyzw: NodeMaterialConnectionPoint;
  55308. /**
  55309. * Gets the xyz component (output)
  55310. */
  55311. readonly xyz: NodeMaterialConnectionPoint;
  55312. /**
  55313. * Gets the xy component (output)
  55314. */
  55315. readonly xy: NodeMaterialConnectionPoint;
  55316. protected _buildBlock(state: NodeMaterialBuildState): this;
  55317. }
  55318. }
  55319. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55323. /**
  55324. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55325. */
  55326. export class ColorSplitterBlock extends NodeMaterialBlock {
  55327. /**
  55328. * Create a new ColorSplitterBlock
  55329. * @param name defines the block name
  55330. */
  55331. constructor(name: string);
  55332. /**
  55333. * Gets the current class name
  55334. * @returns the class name
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Gets the rgba component (input)
  55339. */
  55340. readonly rgba: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the rgb component (input)
  55343. */
  55344. readonly rgbIn: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the rgb component (output)
  55347. */
  55348. readonly rgbOut: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the r component (output)
  55351. */
  55352. readonly r: NodeMaterialConnectionPoint;
  55353. /**
  55354. * Gets the g component (output)
  55355. */
  55356. readonly g: NodeMaterialConnectionPoint;
  55357. /**
  55358. * Gets the b component (output)
  55359. */
  55360. readonly b: NodeMaterialConnectionPoint;
  55361. /**
  55362. * Gets the a component (output)
  55363. */
  55364. readonly a: NodeMaterialConnectionPoint;
  55365. protected _buildBlock(state: NodeMaterialBuildState): this;
  55366. }
  55367. }
  55368. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55372. /**
  55373. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55374. */
  55375. export class VectorSplitterBlock extends NodeMaterialBlock {
  55376. /**
  55377. * Create a new VectorSplitterBlock
  55378. * @param name defines the block name
  55379. */
  55380. constructor(name: string);
  55381. /**
  55382. * Gets the current class name
  55383. * @returns the class name
  55384. */
  55385. getClassName(): string;
  55386. /**
  55387. * Gets the xyzw component (input)
  55388. */
  55389. readonly xyzw: NodeMaterialConnectionPoint;
  55390. /**
  55391. * Gets the xyz component (input)
  55392. */
  55393. readonly xyzIn: NodeMaterialConnectionPoint;
  55394. /**
  55395. * Gets the xyz component (output)
  55396. */
  55397. readonly xyzOut: NodeMaterialConnectionPoint;
  55398. /**
  55399. * Gets the xy component (output)
  55400. */
  55401. readonly xy: NodeMaterialConnectionPoint;
  55402. /**
  55403. * Gets the x component (output)
  55404. */
  55405. readonly x: NodeMaterialConnectionPoint;
  55406. /**
  55407. * Gets the y component (output)
  55408. */
  55409. readonly y: NodeMaterialConnectionPoint;
  55410. /**
  55411. * Gets the z component (output)
  55412. */
  55413. readonly z: NodeMaterialConnectionPoint;
  55414. /**
  55415. * Gets the w component (output)
  55416. */
  55417. readonly w: NodeMaterialConnectionPoint;
  55418. protected _buildBlock(state: NodeMaterialBuildState): this;
  55419. }
  55420. }
  55421. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55427. import { Effect } from "babylonjs/Materials/effect";
  55428. import { Mesh } from "babylonjs/Meshes/mesh";
  55429. /**
  55430. * Block used to add image processing support to fragment shader
  55431. */
  55432. export class ImageProcessingBlock extends NodeMaterialBlock {
  55433. /**
  55434. * Create a new ImageProcessingBlock
  55435. * @param name defines the block name
  55436. */
  55437. constructor(name: string);
  55438. /**
  55439. * Gets the current class name
  55440. * @returns the class name
  55441. */
  55442. getClassName(): string;
  55443. /**
  55444. * Gets the color input component
  55445. */
  55446. readonly color: NodeMaterialConnectionPoint;
  55447. /**
  55448. * Gets the output component
  55449. */
  55450. readonly output: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Initialize the block and prepare the context for build
  55453. * @param state defines the state that will be used for the build
  55454. */
  55455. initialize(state: NodeMaterialBuildState): void;
  55456. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55459. protected _buildBlock(state: NodeMaterialBuildState): this;
  55460. }
  55461. }
  55462. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55463. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55464. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55465. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55466. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55467. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55468. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55469. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55470. }
  55471. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55474. import { Mesh } from "babylonjs/Meshes/mesh";
  55475. import { Effect } from "babylonjs/Materials/effect";
  55476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55478. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55479. /**
  55480. * Block used to add support for scene fog
  55481. */
  55482. export class FogBlock extends NodeMaterialBlock {
  55483. private _fogDistanceName;
  55484. private _fogParameters;
  55485. /**
  55486. * Create a new FogBlock
  55487. * @param name defines the block name
  55488. */
  55489. constructor(name: string);
  55490. /**
  55491. * Gets the current class name
  55492. * @returns the class name
  55493. */
  55494. getClassName(): string;
  55495. /**
  55496. * Gets the world position input component
  55497. */
  55498. readonly worldPosition: NodeMaterialConnectionPoint;
  55499. /**
  55500. * Gets the view input component
  55501. */
  55502. readonly view: NodeMaterialConnectionPoint;
  55503. /**
  55504. * Gets the color input component
  55505. */
  55506. readonly color: NodeMaterialConnectionPoint;
  55507. /**
  55508. * Gets the fog color input component
  55509. */
  55510. readonly fogColor: NodeMaterialConnectionPoint;
  55511. /**
  55512. * Gets the output component
  55513. */
  55514. readonly output: NodeMaterialConnectionPoint;
  55515. autoConfigure(): void;
  55516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55518. protected _buildBlock(state: NodeMaterialBuildState): this;
  55519. }
  55520. }
  55521. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55527. import { Effect } from "babylonjs/Materials/effect";
  55528. import { Mesh } from "babylonjs/Meshes/mesh";
  55529. import { Light } from "babylonjs/Lights/light";
  55530. import { Nullable } from "babylonjs/types";
  55531. import { Scene } from "babylonjs/scene";
  55532. /**
  55533. * Block used to add light in the fragment shader
  55534. */
  55535. export class LightBlock extends NodeMaterialBlock {
  55536. private _lightId;
  55537. /**
  55538. * Gets or sets the light associated with this block
  55539. */
  55540. light: Nullable<Light>;
  55541. /**
  55542. * Create a new LightBlock
  55543. * @param name defines the block name
  55544. */
  55545. constructor(name: string);
  55546. /**
  55547. * Gets the current class name
  55548. * @returns the class name
  55549. */
  55550. getClassName(): string;
  55551. /**
  55552. * Gets the world position input component
  55553. */
  55554. readonly worldPosition: NodeMaterialConnectionPoint;
  55555. /**
  55556. * Gets the world normal input component
  55557. */
  55558. readonly worldNormal: NodeMaterialConnectionPoint;
  55559. /**
  55560. * Gets the camera (or eye) position component
  55561. */
  55562. readonly cameraPosition: NodeMaterialConnectionPoint;
  55563. /**
  55564. * Gets the diffuse output component
  55565. */
  55566. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55567. /**
  55568. * Gets the specular output component
  55569. */
  55570. readonly specularOutput: NodeMaterialConnectionPoint;
  55571. autoConfigure(): void;
  55572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55573. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55575. private _injectVertexCode;
  55576. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55577. serialize(): any;
  55578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55579. }
  55580. }
  55581. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55582. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55583. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55584. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55585. }
  55586. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55587. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55588. }
  55589. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55593. /**
  55594. * Block used to multiply 2 values
  55595. */
  55596. export class MultiplyBlock extends NodeMaterialBlock {
  55597. /**
  55598. * Creates a new MultiplyBlock
  55599. * @param name defines the block name
  55600. */
  55601. constructor(name: string);
  55602. /**
  55603. * Gets the current class name
  55604. * @returns the class name
  55605. */
  55606. getClassName(): string;
  55607. /**
  55608. * Gets the left operand input component
  55609. */
  55610. readonly left: NodeMaterialConnectionPoint;
  55611. /**
  55612. * Gets the right operand input component
  55613. */
  55614. readonly right: NodeMaterialConnectionPoint;
  55615. /**
  55616. * Gets the output component
  55617. */
  55618. readonly output: NodeMaterialConnectionPoint;
  55619. protected _buildBlock(state: NodeMaterialBuildState): this;
  55620. }
  55621. }
  55622. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55626. /**
  55627. * Block used to add 2 vectors
  55628. */
  55629. export class AddBlock extends NodeMaterialBlock {
  55630. /**
  55631. * Creates a new AddBlock
  55632. * @param name defines the block name
  55633. */
  55634. constructor(name: string);
  55635. /**
  55636. * Gets the current class name
  55637. * @returns the class name
  55638. */
  55639. getClassName(): string;
  55640. /**
  55641. * Gets the left operand input component
  55642. */
  55643. readonly left: NodeMaterialConnectionPoint;
  55644. /**
  55645. * Gets the right operand input component
  55646. */
  55647. readonly right: NodeMaterialConnectionPoint;
  55648. /**
  55649. * Gets the output component
  55650. */
  55651. readonly output: NodeMaterialConnectionPoint;
  55652. protected _buildBlock(state: NodeMaterialBuildState): this;
  55653. }
  55654. }
  55655. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55659. /**
  55660. * Block used to clamp a float
  55661. */
  55662. export class ClampBlock extends NodeMaterialBlock {
  55663. /** Gets or sets the minimum range */
  55664. minimum: number;
  55665. /** Gets or sets the maximum range */
  55666. maximum: number;
  55667. /**
  55668. * Creates a new ClampBlock
  55669. * @param name defines the block name
  55670. */
  55671. constructor(name: string);
  55672. /**
  55673. * Gets the current class name
  55674. * @returns the class name
  55675. */
  55676. getClassName(): string;
  55677. /**
  55678. * Gets the value input component
  55679. */
  55680. readonly value: NodeMaterialConnectionPoint;
  55681. /**
  55682. * Gets the output component
  55683. */
  55684. readonly output: NodeMaterialConnectionPoint;
  55685. protected _buildBlock(state: NodeMaterialBuildState): this;
  55686. }
  55687. }
  55688. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55692. /**
  55693. * Block used to apply a cross product between 2 vectors
  55694. */
  55695. export class CrossBlock extends NodeMaterialBlock {
  55696. /**
  55697. * Creates a new CrossBlock
  55698. * @param name defines the block name
  55699. */
  55700. constructor(name: string);
  55701. /**
  55702. * Gets the current class name
  55703. * @returns the class name
  55704. */
  55705. getClassName(): string;
  55706. /**
  55707. * Gets the left operand input component
  55708. */
  55709. readonly left: NodeMaterialConnectionPoint;
  55710. /**
  55711. * Gets the right operand input component
  55712. */
  55713. readonly right: NodeMaterialConnectionPoint;
  55714. /**
  55715. * Gets the output component
  55716. */
  55717. readonly output: NodeMaterialConnectionPoint;
  55718. protected _buildBlock(state: NodeMaterialBuildState): this;
  55719. }
  55720. }
  55721. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55725. /**
  55726. * Block used to apply a dot product between 2 vectors
  55727. */
  55728. export class DotBlock extends NodeMaterialBlock {
  55729. /**
  55730. * Creates a new DotBlock
  55731. * @param name defines the block name
  55732. */
  55733. constructor(name: string);
  55734. /**
  55735. * Gets the current class name
  55736. * @returns the class name
  55737. */
  55738. getClassName(): string;
  55739. /**
  55740. * Gets the left operand input component
  55741. */
  55742. readonly left: NodeMaterialConnectionPoint;
  55743. /**
  55744. * Gets the right operand input component
  55745. */
  55746. readonly right: NodeMaterialConnectionPoint;
  55747. /**
  55748. * Gets the output component
  55749. */
  55750. readonly output: NodeMaterialConnectionPoint;
  55751. protected _buildBlock(state: NodeMaterialBuildState): this;
  55752. }
  55753. }
  55754. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55758. import { Vector2 } from "babylonjs/Maths/math.vector";
  55759. /**
  55760. * Block used to remap a float from a range to a new one
  55761. */
  55762. export class RemapBlock extends NodeMaterialBlock {
  55763. /**
  55764. * Gets or sets the source range
  55765. */
  55766. sourceRange: Vector2;
  55767. /**
  55768. * Gets or sets the target range
  55769. */
  55770. targetRange: Vector2;
  55771. /**
  55772. * Creates a new RemapBlock
  55773. * @param name defines the block name
  55774. */
  55775. constructor(name: string);
  55776. /**
  55777. * Gets the current class name
  55778. * @returns the class name
  55779. */
  55780. getClassName(): string;
  55781. /**
  55782. * Gets the input component
  55783. */
  55784. readonly input: NodeMaterialConnectionPoint;
  55785. /**
  55786. * Gets the output component
  55787. */
  55788. readonly output: NodeMaterialConnectionPoint;
  55789. protected _buildBlock(state: NodeMaterialBuildState): this;
  55790. }
  55791. }
  55792. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55796. /**
  55797. * Block used to normalize a vector
  55798. */
  55799. export class NormalizeBlock extends NodeMaterialBlock {
  55800. /**
  55801. * Creates a new NormalizeBlock
  55802. * @param name defines the block name
  55803. */
  55804. constructor(name: string);
  55805. /**
  55806. * Gets the current class name
  55807. * @returns the class name
  55808. */
  55809. getClassName(): string;
  55810. /**
  55811. * Gets the input component
  55812. */
  55813. readonly input: NodeMaterialConnectionPoint;
  55814. /**
  55815. * Gets the output component
  55816. */
  55817. readonly output: NodeMaterialConnectionPoint;
  55818. protected _buildBlock(state: NodeMaterialBuildState): this;
  55819. }
  55820. }
  55821. declare module "babylonjs/Materials/Node/Blocks/index" {
  55822. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55823. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55824. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55825. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55826. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55827. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55828. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55829. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55830. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55831. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55832. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  55833. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  55834. }
  55835. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55836. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55837. }
  55838. declare module "babylonjs/Materials/Node/index" {
  55839. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55840. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55841. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55842. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55843. export * from "babylonjs/Materials/Node/nodeMaterial";
  55844. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55845. export * from "babylonjs/Materials/Node/Blocks/index";
  55846. export * from "babylonjs/Materials/Node/Optimizers/index";
  55847. }
  55848. declare module "babylonjs/Materials/effectRenderer" {
  55849. import { Nullable } from "babylonjs/types";
  55850. import { Texture } from "babylonjs/Materials/Textures/texture";
  55851. import { Engine } from "babylonjs/Engines/engine";
  55852. import { Viewport } from "babylonjs/Maths/math.viewport";
  55853. import { Observable } from "babylonjs/Misc/observable";
  55854. import { Effect } from "babylonjs/Materials/effect";
  55855. import "babylonjs/Shaders/postprocess.vertex";
  55856. /**
  55857. * Effect Render Options
  55858. */
  55859. export interface IEffectRendererOptions {
  55860. /**
  55861. * Defines the vertices positions.
  55862. */
  55863. positions?: number[];
  55864. /**
  55865. * Defines the indices.
  55866. */
  55867. indices?: number[];
  55868. }
  55869. /**
  55870. * Helper class to render one or more effects
  55871. */
  55872. export class EffectRenderer {
  55873. private engine;
  55874. private static _DefaultOptions;
  55875. private _vertexBuffers;
  55876. private _indexBuffer;
  55877. private _ringBufferIndex;
  55878. private _ringScreenBuffer;
  55879. private _fullscreenViewport;
  55880. private _getNextFrameBuffer;
  55881. /**
  55882. * Creates an effect renderer
  55883. * @param engine the engine to use for rendering
  55884. * @param options defines the options of the effect renderer
  55885. */
  55886. constructor(engine: Engine, options?: IEffectRendererOptions);
  55887. /**
  55888. * Sets the current viewport in normalized coordinates 0-1
  55889. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55890. */
  55891. setViewport(viewport?: Viewport): void;
  55892. /**
  55893. * Sets the current effect wrapper to use during draw.
  55894. * The effect needs to be ready before calling this api.
  55895. * This also sets the default full screen position attribute.
  55896. * @param effectWrapper Defines the effect to draw with
  55897. */
  55898. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55899. /**
  55900. * Draws a full screen quad.
  55901. */
  55902. draw(): void;
  55903. /**
  55904. * renders one or more effects to a specified texture
  55905. * @param effectWrappers list of effects to renderer
  55906. * @param outputTexture texture to draw to, if null it will render to the screen
  55907. */
  55908. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55909. /**
  55910. * Disposes of the effect renderer
  55911. */
  55912. dispose(): void;
  55913. }
  55914. /**
  55915. * Options to create an EffectWrapper
  55916. */
  55917. interface EffectWrapperCreationOptions {
  55918. /**
  55919. * Engine to use to create the effect
  55920. */
  55921. engine: Engine;
  55922. /**
  55923. * Fragment shader for the effect
  55924. */
  55925. fragmentShader: string;
  55926. /**
  55927. * Vertex shader for the effect
  55928. */
  55929. vertexShader?: string;
  55930. /**
  55931. * Attributes to use in the shader
  55932. */
  55933. attributeNames?: Array<string>;
  55934. /**
  55935. * Uniforms to use in the shader
  55936. */
  55937. uniformNames?: Array<string>;
  55938. /**
  55939. * Texture sampler names to use in the shader
  55940. */
  55941. samplerNames?: Array<string>;
  55942. /**
  55943. * The friendly name of the effect displayed in Spector.
  55944. */
  55945. name?: string;
  55946. }
  55947. /**
  55948. * Wraps an effect to be used for rendering
  55949. */
  55950. export class EffectWrapper {
  55951. /**
  55952. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55953. */
  55954. onApplyObservable: Observable<{}>;
  55955. /**
  55956. * The underlying effect
  55957. */
  55958. effect: Effect;
  55959. /**
  55960. * Creates an effect to be renderer
  55961. * @param creationOptions options to create the effect
  55962. */
  55963. constructor(creationOptions: EffectWrapperCreationOptions);
  55964. /**
  55965. * Disposes of the effect wrapper
  55966. */
  55967. dispose(): void;
  55968. }
  55969. }
  55970. declare module "babylonjs/Materials/index" {
  55971. export * from "babylonjs/Materials/Background/index";
  55972. export * from "babylonjs/Materials/colorCurves";
  55973. export * from "babylonjs/Materials/effect";
  55974. export * from "babylonjs/Materials/fresnelParameters";
  55975. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55976. export * from "babylonjs/Materials/material";
  55977. export * from "babylonjs/Materials/materialDefines";
  55978. export * from "babylonjs/Materials/materialHelper";
  55979. export * from "babylonjs/Materials/multiMaterial";
  55980. export * from "babylonjs/Materials/PBR/index";
  55981. export * from "babylonjs/Materials/pushMaterial";
  55982. export * from "babylonjs/Materials/shaderMaterial";
  55983. export * from "babylonjs/Materials/standardMaterial";
  55984. export * from "babylonjs/Materials/Textures/index";
  55985. export * from "babylonjs/Materials/uniformBuffer";
  55986. export * from "babylonjs/Materials/materialFlags";
  55987. export * from "babylonjs/Materials/Node/index";
  55988. export * from "babylonjs/Materials/effectRenderer";
  55989. }
  55990. declare module "babylonjs/Maths/index" {
  55991. export * from "babylonjs/Maths/math.scalar";
  55992. export * from "babylonjs/Maths/math";
  55993. export * from "babylonjs/Maths/sphericalPolynomial";
  55994. }
  55995. declare module "babylonjs/Misc/workerPool" {
  55996. import { IDisposable } from "babylonjs/scene";
  55997. /**
  55998. * Helper class to push actions to a pool of workers.
  55999. */
  56000. export class WorkerPool implements IDisposable {
  56001. private _workerInfos;
  56002. private _pendingActions;
  56003. /**
  56004. * Constructor
  56005. * @param workers Array of workers to use for actions
  56006. */
  56007. constructor(workers: Array<Worker>);
  56008. /**
  56009. * Terminates all workers and clears any pending actions.
  56010. */
  56011. dispose(): void;
  56012. /**
  56013. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56014. * pended until a worker has completed its action.
  56015. * @param action The action to perform. Call onComplete when the action is complete.
  56016. */
  56017. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56018. private _execute;
  56019. }
  56020. }
  56021. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56022. import { IDisposable } from "babylonjs/scene";
  56023. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56024. /**
  56025. * Configuration for Draco compression
  56026. */
  56027. export interface IDracoCompressionConfiguration {
  56028. /**
  56029. * Configuration for the decoder.
  56030. */
  56031. decoder: {
  56032. /**
  56033. * The url to the WebAssembly module.
  56034. */
  56035. wasmUrl?: string;
  56036. /**
  56037. * The url to the WebAssembly binary.
  56038. */
  56039. wasmBinaryUrl?: string;
  56040. /**
  56041. * The url to the fallback JavaScript module.
  56042. */
  56043. fallbackUrl?: string;
  56044. };
  56045. }
  56046. /**
  56047. * Draco compression (https://google.github.io/draco/)
  56048. *
  56049. * This class wraps the Draco module.
  56050. *
  56051. * **Encoder**
  56052. *
  56053. * The encoder is not currently implemented.
  56054. *
  56055. * **Decoder**
  56056. *
  56057. * 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.
  56058. *
  56059. * To update the configuration, use the following code:
  56060. * ```javascript
  56061. * DracoCompression.Configuration = {
  56062. * decoder: {
  56063. * wasmUrl: "<url to the WebAssembly library>",
  56064. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56065. * fallbackUrl: "<url to the fallback JavaScript library>",
  56066. * }
  56067. * };
  56068. * ```
  56069. *
  56070. * 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.
  56071. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56072. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56073. *
  56074. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56075. * ```javascript
  56076. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56077. * ```
  56078. *
  56079. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56080. */
  56081. export class DracoCompression implements IDisposable {
  56082. private _workerPoolPromise?;
  56083. private _decoderModulePromise?;
  56084. /**
  56085. * The configuration. Defaults to the following urls:
  56086. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56087. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56088. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56089. */
  56090. static Configuration: IDracoCompressionConfiguration;
  56091. /**
  56092. * Returns true if the decoder configuration is available.
  56093. */
  56094. static readonly DecoderAvailable: boolean;
  56095. /**
  56096. * Default number of workers to create when creating the draco compression object.
  56097. */
  56098. static DefaultNumWorkers: number;
  56099. private static GetDefaultNumWorkers;
  56100. private static _Default;
  56101. /**
  56102. * Default instance for the draco compression object.
  56103. */
  56104. static readonly Default: DracoCompression;
  56105. /**
  56106. * Constructor
  56107. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56108. */
  56109. constructor(numWorkers?: number);
  56110. /**
  56111. * Stop all async operations and release resources.
  56112. */
  56113. dispose(): void;
  56114. /**
  56115. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56116. * @returns a promise that resolves when ready
  56117. */
  56118. whenReadyAsync(): Promise<void>;
  56119. /**
  56120. * Decode Draco compressed mesh data to vertex data.
  56121. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56122. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56123. * @returns A promise that resolves with the decoded vertex data
  56124. */
  56125. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56126. [kind: string]: number;
  56127. }): Promise<VertexData>;
  56128. }
  56129. }
  56130. declare module "babylonjs/Meshes/Compression/index" {
  56131. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56132. }
  56133. declare module "babylonjs/Meshes/csg" {
  56134. import { Nullable } from "babylonjs/types";
  56135. import { Scene } from "babylonjs/scene";
  56136. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56137. import { Mesh } from "babylonjs/Meshes/mesh";
  56138. import { Material } from "babylonjs/Materials/material";
  56139. /**
  56140. * Class for building Constructive Solid Geometry
  56141. */
  56142. export class CSG {
  56143. private polygons;
  56144. /**
  56145. * The world matrix
  56146. */
  56147. matrix: Matrix;
  56148. /**
  56149. * Stores the position
  56150. */
  56151. position: Vector3;
  56152. /**
  56153. * Stores the rotation
  56154. */
  56155. rotation: Vector3;
  56156. /**
  56157. * Stores the rotation quaternion
  56158. */
  56159. rotationQuaternion: Nullable<Quaternion>;
  56160. /**
  56161. * Stores the scaling vector
  56162. */
  56163. scaling: Vector3;
  56164. /**
  56165. * Convert the Mesh to CSG
  56166. * @param mesh The Mesh to convert to CSG
  56167. * @returns A new CSG from the Mesh
  56168. */
  56169. static FromMesh(mesh: Mesh): CSG;
  56170. /**
  56171. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56172. * @param polygons Polygons used to construct a CSG solid
  56173. */
  56174. private static FromPolygons;
  56175. /**
  56176. * Clones, or makes a deep copy, of the CSG
  56177. * @returns A new CSG
  56178. */
  56179. clone(): CSG;
  56180. /**
  56181. * Unions this CSG with another CSG
  56182. * @param csg The CSG to union against this CSG
  56183. * @returns The unioned CSG
  56184. */
  56185. union(csg: CSG): CSG;
  56186. /**
  56187. * Unions this CSG with another CSG in place
  56188. * @param csg The CSG to union against this CSG
  56189. */
  56190. unionInPlace(csg: CSG): void;
  56191. /**
  56192. * Subtracts this CSG with another CSG
  56193. * @param csg The CSG to subtract against this CSG
  56194. * @returns A new CSG
  56195. */
  56196. subtract(csg: CSG): CSG;
  56197. /**
  56198. * Subtracts this CSG with another CSG in place
  56199. * @param csg The CSG to subtact against this CSG
  56200. */
  56201. subtractInPlace(csg: CSG): void;
  56202. /**
  56203. * Intersect this CSG with another CSG
  56204. * @param csg The CSG to intersect against this CSG
  56205. * @returns A new CSG
  56206. */
  56207. intersect(csg: CSG): CSG;
  56208. /**
  56209. * Intersects this CSG with another CSG in place
  56210. * @param csg The CSG to intersect against this CSG
  56211. */
  56212. intersectInPlace(csg: CSG): void;
  56213. /**
  56214. * Return a new CSG solid with solid and empty space switched. This solid is
  56215. * not modified.
  56216. * @returns A new CSG solid with solid and empty space switched
  56217. */
  56218. inverse(): CSG;
  56219. /**
  56220. * Inverses the CSG in place
  56221. */
  56222. inverseInPlace(): void;
  56223. /**
  56224. * This is used to keep meshes transformations so they can be restored
  56225. * when we build back a Babylon Mesh
  56226. * NB : All CSG operations are performed in world coordinates
  56227. * @param csg The CSG to copy the transform attributes from
  56228. * @returns This CSG
  56229. */
  56230. copyTransformAttributes(csg: CSG): CSG;
  56231. /**
  56232. * Build Raw mesh from CSG
  56233. * Coordinates here are in world space
  56234. * @param name The name of the mesh geometry
  56235. * @param scene The Scene
  56236. * @param keepSubMeshes Specifies if the submeshes should be kept
  56237. * @returns A new Mesh
  56238. */
  56239. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56240. /**
  56241. * Build Mesh from CSG taking material and transforms into account
  56242. * @param name The name of the Mesh
  56243. * @param material The material of the Mesh
  56244. * @param scene The Scene
  56245. * @param keepSubMeshes Specifies if submeshes should be kept
  56246. * @returns The new Mesh
  56247. */
  56248. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56249. }
  56250. }
  56251. declare module "babylonjs/Meshes/trailMesh" {
  56252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56253. import { Mesh } from "babylonjs/Meshes/mesh";
  56254. import { Scene } from "babylonjs/scene";
  56255. /**
  56256. * Class used to create a trail following a mesh
  56257. */
  56258. export class TrailMesh extends Mesh {
  56259. private _generator;
  56260. private _autoStart;
  56261. private _running;
  56262. private _diameter;
  56263. private _length;
  56264. private _sectionPolygonPointsCount;
  56265. private _sectionVectors;
  56266. private _sectionNormalVectors;
  56267. private _beforeRenderObserver;
  56268. /**
  56269. * @constructor
  56270. * @param name The value used by scene.getMeshByName() to do a lookup.
  56271. * @param generator The mesh to generate a trail.
  56272. * @param scene The scene to add this mesh to.
  56273. * @param diameter Diameter of trailing mesh. Default is 1.
  56274. * @param length Length of trailing mesh. Default is 60.
  56275. * @param autoStart Automatically start trailing mesh. Default true.
  56276. */
  56277. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56278. /**
  56279. * "TrailMesh"
  56280. * @returns "TrailMesh"
  56281. */
  56282. getClassName(): string;
  56283. private _createMesh;
  56284. /**
  56285. * Start trailing mesh.
  56286. */
  56287. start(): void;
  56288. /**
  56289. * Stop trailing mesh.
  56290. */
  56291. stop(): void;
  56292. /**
  56293. * Update trailing mesh geometry.
  56294. */
  56295. update(): void;
  56296. /**
  56297. * Returns a new TrailMesh object.
  56298. * @param name is a string, the name given to the new mesh
  56299. * @param newGenerator use new generator object for cloned trail mesh
  56300. * @returns a new mesh
  56301. */
  56302. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56303. /**
  56304. * Serializes this trail mesh
  56305. * @param serializationObject object to write serialization to
  56306. */
  56307. serialize(serializationObject: any): void;
  56308. /**
  56309. * Parses a serialized trail mesh
  56310. * @param parsedMesh the serialized mesh
  56311. * @param scene the scene to create the trail mesh in
  56312. * @returns the created trail mesh
  56313. */
  56314. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56315. }
  56316. }
  56317. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56318. import { Nullable } from "babylonjs/types";
  56319. import { Scene } from "babylonjs/scene";
  56320. import { Vector4 } from "babylonjs/Maths/math.vector";
  56321. import { Color4 } from "babylonjs/Maths/math.color";
  56322. import { Mesh } from "babylonjs/Meshes/mesh";
  56323. /**
  56324. * Class containing static functions to help procedurally build meshes
  56325. */
  56326. export class TiledBoxBuilder {
  56327. /**
  56328. * Creates a box mesh
  56329. * 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)
  56330. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56334. * @param name defines the name of the mesh
  56335. * @param options defines the options used to create the mesh
  56336. * @param scene defines the hosting scene
  56337. * @returns the box mesh
  56338. */
  56339. static CreateTiledBox(name: string, options: {
  56340. pattern?: number;
  56341. width?: number;
  56342. height?: number;
  56343. depth?: number;
  56344. tileSize?: number;
  56345. tileWidth?: number;
  56346. tileHeight?: number;
  56347. alignHorizontal?: number;
  56348. alignVertical?: number;
  56349. faceUV?: Vector4[];
  56350. faceColors?: Color4[];
  56351. sideOrientation?: number;
  56352. updatable?: boolean;
  56353. }, scene?: Nullable<Scene>): Mesh;
  56354. }
  56355. }
  56356. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56357. import { Vector4 } from "babylonjs/Maths/math.vector";
  56358. import { Mesh } from "babylonjs/Meshes/mesh";
  56359. /**
  56360. * Class containing static functions to help procedurally build meshes
  56361. */
  56362. export class TorusKnotBuilder {
  56363. /**
  56364. * Creates a torus knot mesh
  56365. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56366. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56367. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56368. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56372. * @param name defines the name of the mesh
  56373. * @param options defines the options used to create the mesh
  56374. * @param scene defines the hosting scene
  56375. * @returns the torus knot mesh
  56376. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56377. */
  56378. static CreateTorusKnot(name: string, options: {
  56379. radius?: number;
  56380. tube?: number;
  56381. radialSegments?: number;
  56382. tubularSegments?: number;
  56383. p?: number;
  56384. q?: number;
  56385. updatable?: boolean;
  56386. sideOrientation?: number;
  56387. frontUVs?: Vector4;
  56388. backUVs?: Vector4;
  56389. }, scene: any): Mesh;
  56390. }
  56391. }
  56392. declare module "babylonjs/Meshes/polygonMesh" {
  56393. import { Scene } from "babylonjs/scene";
  56394. import { Vector2 } from "babylonjs/Maths/math.vector";
  56395. import { Mesh } from "babylonjs/Meshes/mesh";
  56396. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56397. import { Path2 } from "babylonjs/Maths/math.path";
  56398. /**
  56399. * Polygon
  56400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56401. */
  56402. export class Polygon {
  56403. /**
  56404. * Creates a rectangle
  56405. * @param xmin bottom X coord
  56406. * @param ymin bottom Y coord
  56407. * @param xmax top X coord
  56408. * @param ymax top Y coord
  56409. * @returns points that make the resulting rectation
  56410. */
  56411. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56412. /**
  56413. * Creates a circle
  56414. * @param radius radius of circle
  56415. * @param cx scale in x
  56416. * @param cy scale in y
  56417. * @param numberOfSides number of sides that make up the circle
  56418. * @returns points that make the resulting circle
  56419. */
  56420. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56421. /**
  56422. * Creates a polygon from input string
  56423. * @param input Input polygon data
  56424. * @returns the parsed points
  56425. */
  56426. static Parse(input: string): Vector2[];
  56427. /**
  56428. * Starts building a polygon from x and y coordinates
  56429. * @param x x coordinate
  56430. * @param y y coordinate
  56431. * @returns the started path2
  56432. */
  56433. static StartingAt(x: number, y: number): Path2;
  56434. }
  56435. /**
  56436. * Builds a polygon
  56437. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56438. */
  56439. export class PolygonMeshBuilder {
  56440. private _points;
  56441. private _outlinepoints;
  56442. private _holes;
  56443. private _name;
  56444. private _scene;
  56445. private _epoints;
  56446. private _eholes;
  56447. private _addToepoint;
  56448. /**
  56449. * Babylon reference to the earcut plugin.
  56450. */
  56451. bjsEarcut: any;
  56452. /**
  56453. * Creates a PolygonMeshBuilder
  56454. * @param name name of the builder
  56455. * @param contours Path of the polygon
  56456. * @param scene scene to add to when creating the mesh
  56457. * @param earcutInjection can be used to inject your own earcut reference
  56458. */
  56459. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56460. /**
  56461. * Adds a whole within the polygon
  56462. * @param hole Array of points defining the hole
  56463. * @returns this
  56464. */
  56465. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56466. /**
  56467. * Creates the polygon
  56468. * @param updatable If the mesh should be updatable
  56469. * @param depth The depth of the mesh created
  56470. * @returns the created mesh
  56471. */
  56472. build(updatable?: boolean, depth?: number): Mesh;
  56473. /**
  56474. * Creates the polygon
  56475. * @param depth The depth of the mesh created
  56476. * @returns the created VertexData
  56477. */
  56478. buildVertexData(depth?: number): VertexData;
  56479. /**
  56480. * Adds a side to the polygon
  56481. * @param positions points that make the polygon
  56482. * @param normals normals of the polygon
  56483. * @param uvs uvs of the polygon
  56484. * @param indices indices of the polygon
  56485. * @param bounds bounds of the polygon
  56486. * @param points points of the polygon
  56487. * @param depth depth of the polygon
  56488. * @param flip flip of the polygon
  56489. */
  56490. private addSide;
  56491. }
  56492. }
  56493. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56494. import { Scene } from "babylonjs/scene";
  56495. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56496. import { Color4 } from "babylonjs/Maths/math.color";
  56497. import { Mesh } from "babylonjs/Meshes/mesh";
  56498. import { Nullable } from "babylonjs/types";
  56499. /**
  56500. * Class containing static functions to help procedurally build meshes
  56501. */
  56502. export class PolygonBuilder {
  56503. /**
  56504. * Creates a polygon mesh
  56505. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56506. * * 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
  56507. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56510. * * Remember you can only change the shape positions, not their number when updating a polygon
  56511. * @param name defines the name of the mesh
  56512. * @param options defines the options used to create the mesh
  56513. * @param scene defines the hosting scene
  56514. * @param earcutInjection can be used to inject your own earcut reference
  56515. * @returns the polygon mesh
  56516. */
  56517. static CreatePolygon(name: string, options: {
  56518. shape: Vector3[];
  56519. holes?: Vector3[][];
  56520. depth?: number;
  56521. faceUV?: Vector4[];
  56522. faceColors?: Color4[];
  56523. updatable?: boolean;
  56524. sideOrientation?: number;
  56525. frontUVs?: Vector4;
  56526. backUVs?: Vector4;
  56527. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56528. /**
  56529. * Creates an extruded polygon mesh, with depth in the Y direction.
  56530. * * 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)
  56531. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56532. * @param name defines the name of the mesh
  56533. * @param options defines the options used to create the mesh
  56534. * @param scene defines the hosting scene
  56535. * @param earcutInjection can be used to inject your own earcut reference
  56536. * @returns the polygon mesh
  56537. */
  56538. static ExtrudePolygon(name: string, options: {
  56539. shape: Vector3[];
  56540. holes?: Vector3[][];
  56541. depth?: number;
  56542. faceUV?: Vector4[];
  56543. faceColors?: Color4[];
  56544. updatable?: boolean;
  56545. sideOrientation?: number;
  56546. frontUVs?: Vector4;
  56547. backUVs?: Vector4;
  56548. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56549. }
  56550. }
  56551. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56552. import { Scene } from "babylonjs/scene";
  56553. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56554. import { Mesh } from "babylonjs/Meshes/mesh";
  56555. import { Nullable } from "babylonjs/types";
  56556. /**
  56557. * Class containing static functions to help procedurally build meshes
  56558. */
  56559. export class LatheBuilder {
  56560. /**
  56561. * Creates lathe mesh.
  56562. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56563. * * 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
  56564. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56565. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56566. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56567. * * 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
  56568. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56569. * * 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
  56570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56574. * @param name defines the name of the mesh
  56575. * @param options defines the options used to create the mesh
  56576. * @param scene defines the hosting scene
  56577. * @returns the lathe mesh
  56578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56579. */
  56580. static CreateLathe(name: string, options: {
  56581. shape: Vector3[];
  56582. radius?: number;
  56583. tessellation?: number;
  56584. clip?: number;
  56585. arc?: number;
  56586. closed?: boolean;
  56587. updatable?: boolean;
  56588. sideOrientation?: number;
  56589. frontUVs?: Vector4;
  56590. backUVs?: Vector4;
  56591. cap?: number;
  56592. invertUV?: boolean;
  56593. }, scene?: Nullable<Scene>): Mesh;
  56594. }
  56595. }
  56596. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56597. import { Nullable } from "babylonjs/types";
  56598. import { Scene } from "babylonjs/scene";
  56599. import { Vector4 } from "babylonjs/Maths/math.vector";
  56600. import { Mesh } from "babylonjs/Meshes/mesh";
  56601. /**
  56602. * Class containing static functions to help procedurally build meshes
  56603. */
  56604. export class TiledPlaneBuilder {
  56605. /**
  56606. * Creates a tiled plane mesh
  56607. * * The parameter `pattern` will, depending on value, do nothing or
  56608. * * * flip (reflect about central vertical) alternate tiles across and up
  56609. * * * flip every tile on alternate rows
  56610. * * * rotate (180 degs) alternate tiles across and up
  56611. * * * rotate every tile on alternate rows
  56612. * * * flip and rotate alternate tiles across and up
  56613. * * * flip and rotate every tile on alternate rows
  56614. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56615. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56617. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56618. * * 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)
  56619. * * 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)
  56620. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56621. * @param name defines the name of the mesh
  56622. * @param options defines the options used to create the mesh
  56623. * @param scene defines the hosting scene
  56624. * @returns the box mesh
  56625. */
  56626. static CreateTiledPlane(name: string, options: {
  56627. pattern?: number;
  56628. tileSize?: number;
  56629. tileWidth?: number;
  56630. tileHeight?: number;
  56631. size?: number;
  56632. width?: number;
  56633. height?: number;
  56634. alignHorizontal?: number;
  56635. alignVertical?: number;
  56636. sideOrientation?: number;
  56637. frontUVs?: Vector4;
  56638. backUVs?: Vector4;
  56639. updatable?: boolean;
  56640. }, scene?: Nullable<Scene>): Mesh;
  56641. }
  56642. }
  56643. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56644. import { Nullable } from "babylonjs/types";
  56645. import { Scene } from "babylonjs/scene";
  56646. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56647. import { Mesh } from "babylonjs/Meshes/mesh";
  56648. /**
  56649. * Class containing static functions to help procedurally build meshes
  56650. */
  56651. export class TubeBuilder {
  56652. /**
  56653. * Creates a tube mesh.
  56654. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56655. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56656. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56657. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56658. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56659. * * 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)
  56660. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56661. * * 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
  56662. * * 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
  56663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56667. * @param name defines the name of the mesh
  56668. * @param options defines the options used to create the mesh
  56669. * @param scene defines the hosting scene
  56670. * @returns the tube mesh
  56671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56672. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56673. */
  56674. static CreateTube(name: string, options: {
  56675. path: Vector3[];
  56676. radius?: number;
  56677. tessellation?: number;
  56678. radiusFunction?: {
  56679. (i: number, distance: number): number;
  56680. };
  56681. cap?: number;
  56682. arc?: number;
  56683. updatable?: boolean;
  56684. sideOrientation?: number;
  56685. frontUVs?: Vector4;
  56686. backUVs?: Vector4;
  56687. instance?: Mesh;
  56688. invertUV?: boolean;
  56689. }, scene?: Nullable<Scene>): Mesh;
  56690. }
  56691. }
  56692. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56693. import { Scene } from "babylonjs/scene";
  56694. import { Vector4 } from "babylonjs/Maths/math.vector";
  56695. import { Mesh } from "babylonjs/Meshes/mesh";
  56696. import { Nullable } from "babylonjs/types";
  56697. /**
  56698. * Class containing static functions to help procedurally build meshes
  56699. */
  56700. export class IcoSphereBuilder {
  56701. /**
  56702. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56703. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56704. * * 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`)
  56705. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56706. * * 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
  56707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56710. * @param name defines the name of the mesh
  56711. * @param options defines the options used to create the mesh
  56712. * @param scene defines the hosting scene
  56713. * @returns the icosahedron mesh
  56714. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56715. */
  56716. static CreateIcoSphere(name: string, options: {
  56717. radius?: number;
  56718. radiusX?: number;
  56719. radiusY?: number;
  56720. radiusZ?: number;
  56721. flat?: boolean;
  56722. subdivisions?: number;
  56723. sideOrientation?: number;
  56724. frontUVs?: Vector4;
  56725. backUVs?: Vector4;
  56726. updatable?: boolean;
  56727. }, scene?: Nullable<Scene>): Mesh;
  56728. }
  56729. }
  56730. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56731. import { Vector3 } from "babylonjs/Maths/math.vector";
  56732. import { Mesh } from "babylonjs/Meshes/mesh";
  56733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56734. /**
  56735. * Class containing static functions to help procedurally build meshes
  56736. */
  56737. export class DecalBuilder {
  56738. /**
  56739. * Creates a decal mesh.
  56740. * 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
  56741. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56742. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56743. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56744. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56745. * @param name defines the name of the mesh
  56746. * @param sourceMesh defines the mesh where the decal must be applied
  56747. * @param options defines the options used to create the mesh
  56748. * @param scene defines the hosting scene
  56749. * @returns the decal mesh
  56750. * @see https://doc.babylonjs.com/how_to/decals
  56751. */
  56752. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56753. position?: Vector3;
  56754. normal?: Vector3;
  56755. size?: Vector3;
  56756. angle?: number;
  56757. }): Mesh;
  56758. }
  56759. }
  56760. declare module "babylonjs/Meshes/meshBuilder" {
  56761. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56762. import { Nullable } from "babylonjs/types";
  56763. import { Scene } from "babylonjs/scene";
  56764. import { Mesh } from "babylonjs/Meshes/mesh";
  56765. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56766. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56768. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56769. import { Plane } from "babylonjs/Maths/math.plane";
  56770. /**
  56771. * Class containing static functions to help procedurally build meshes
  56772. */
  56773. export class MeshBuilder {
  56774. /**
  56775. * Creates a box mesh
  56776. * * The parameter `size` sets the size (float) of each box side (default 1)
  56777. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56778. * * 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)
  56779. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56783. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56784. * @param name defines the name of the mesh
  56785. * @param options defines the options used to create the mesh
  56786. * @param scene defines the hosting scene
  56787. * @returns the box mesh
  56788. */
  56789. static CreateBox(name: string, options: {
  56790. size?: number;
  56791. width?: number;
  56792. height?: number;
  56793. depth?: number;
  56794. faceUV?: Vector4[];
  56795. faceColors?: Color4[];
  56796. sideOrientation?: number;
  56797. frontUVs?: Vector4;
  56798. backUVs?: Vector4;
  56799. updatable?: boolean;
  56800. }, scene?: Nullable<Scene>): Mesh;
  56801. /**
  56802. * Creates a tiled box mesh
  56803. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56805. * @param name defines the name of the mesh
  56806. * @param options defines the options used to create the mesh
  56807. * @param scene defines the hosting scene
  56808. * @returns the tiled box mesh
  56809. */
  56810. static CreateTiledBox(name: string, options: {
  56811. pattern?: number;
  56812. size?: number;
  56813. width?: number;
  56814. height?: number;
  56815. depth: number;
  56816. tileSize?: number;
  56817. tileWidth?: number;
  56818. tileHeight?: number;
  56819. faceUV?: Vector4[];
  56820. faceColors?: Color4[];
  56821. alignHorizontal?: number;
  56822. alignVertical?: number;
  56823. sideOrientation?: number;
  56824. updatable?: boolean;
  56825. }, scene?: Nullable<Scene>): Mesh;
  56826. /**
  56827. * Creates a sphere mesh
  56828. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56829. * * 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`)
  56830. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56831. * * 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
  56832. * * 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)
  56833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56836. * @param name defines the name of the mesh
  56837. * @param options defines the options used to create the mesh
  56838. * @param scene defines the hosting scene
  56839. * @returns the sphere mesh
  56840. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56841. */
  56842. static CreateSphere(name: string, options: {
  56843. segments?: number;
  56844. diameter?: number;
  56845. diameterX?: number;
  56846. diameterY?: number;
  56847. diameterZ?: number;
  56848. arc?: number;
  56849. slice?: number;
  56850. sideOrientation?: number;
  56851. frontUVs?: Vector4;
  56852. backUVs?: Vector4;
  56853. updatable?: boolean;
  56854. }, scene?: Nullable<Scene>): Mesh;
  56855. /**
  56856. * Creates a plane polygonal mesh. By default, this is a disc
  56857. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56858. * * 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
  56859. * * 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
  56860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56863. * @param name defines the name of the mesh
  56864. * @param options defines the options used to create the mesh
  56865. * @param scene defines the hosting scene
  56866. * @returns the plane polygonal mesh
  56867. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56868. */
  56869. static CreateDisc(name: string, options: {
  56870. radius?: number;
  56871. tessellation?: number;
  56872. arc?: number;
  56873. updatable?: boolean;
  56874. sideOrientation?: number;
  56875. frontUVs?: Vector4;
  56876. backUVs?: Vector4;
  56877. }, scene?: Nullable<Scene>): Mesh;
  56878. /**
  56879. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56880. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56881. * * 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`)
  56882. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56883. * * 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
  56884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56887. * @param name defines the name of the mesh
  56888. * @param options defines the options used to create the mesh
  56889. * @param scene defines the hosting scene
  56890. * @returns the icosahedron mesh
  56891. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56892. */
  56893. static CreateIcoSphere(name: string, options: {
  56894. radius?: number;
  56895. radiusX?: number;
  56896. radiusY?: number;
  56897. radiusZ?: number;
  56898. flat?: boolean;
  56899. subdivisions?: number;
  56900. sideOrientation?: number;
  56901. frontUVs?: Vector4;
  56902. backUVs?: Vector4;
  56903. updatable?: boolean;
  56904. }, scene?: Nullable<Scene>): Mesh;
  56905. /**
  56906. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56907. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56908. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56909. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56910. * * 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
  56911. * * 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
  56912. * * 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
  56913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56916. * * 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
  56917. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56918. * * 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
  56919. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56921. * @param name defines the name of the mesh
  56922. * @param options defines the options used to create the mesh
  56923. * @param scene defines the hosting scene
  56924. * @returns the ribbon mesh
  56925. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56927. */
  56928. static CreateRibbon(name: string, options: {
  56929. pathArray: Vector3[][];
  56930. closeArray?: boolean;
  56931. closePath?: boolean;
  56932. offset?: number;
  56933. updatable?: boolean;
  56934. sideOrientation?: number;
  56935. frontUVs?: Vector4;
  56936. backUVs?: Vector4;
  56937. instance?: Mesh;
  56938. invertUV?: boolean;
  56939. uvs?: Vector2[];
  56940. colors?: Color4[];
  56941. }, scene?: Nullable<Scene>): Mesh;
  56942. /**
  56943. * Creates a cylinder or a cone mesh
  56944. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56945. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56946. * * 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.
  56947. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56948. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56949. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56950. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56951. * * 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).
  56952. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56953. * * 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).
  56954. * * 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
  56955. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56956. * * 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
  56957. * * 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.
  56958. * * If `enclose` is false, a ring surface is one element.
  56959. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56960. * * 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
  56961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56964. * @param name defines the name of the mesh
  56965. * @param options defines the options used to create the mesh
  56966. * @param scene defines the hosting scene
  56967. * @returns the cylinder mesh
  56968. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56969. */
  56970. static CreateCylinder(name: string, options: {
  56971. height?: number;
  56972. diameterTop?: number;
  56973. diameterBottom?: number;
  56974. diameter?: number;
  56975. tessellation?: number;
  56976. subdivisions?: number;
  56977. arc?: number;
  56978. faceColors?: Color4[];
  56979. faceUV?: Vector4[];
  56980. updatable?: boolean;
  56981. hasRings?: boolean;
  56982. enclose?: boolean;
  56983. cap?: number;
  56984. sideOrientation?: number;
  56985. frontUVs?: Vector4;
  56986. backUVs?: Vector4;
  56987. }, scene?: Nullable<Scene>): Mesh;
  56988. /**
  56989. * Creates a torus mesh
  56990. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56991. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56992. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56996. * @param name defines the name of the mesh
  56997. * @param options defines the options used to create the mesh
  56998. * @param scene defines the hosting scene
  56999. * @returns the torus mesh
  57000. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57001. */
  57002. static CreateTorus(name: string, options: {
  57003. diameter?: number;
  57004. thickness?: number;
  57005. tessellation?: number;
  57006. updatable?: boolean;
  57007. sideOrientation?: number;
  57008. frontUVs?: Vector4;
  57009. backUVs?: Vector4;
  57010. }, scene?: Nullable<Scene>): Mesh;
  57011. /**
  57012. * Creates a torus knot mesh
  57013. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57014. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57015. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57016. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57020. * @param name defines the name of the mesh
  57021. * @param options defines the options used to create the mesh
  57022. * @param scene defines the hosting scene
  57023. * @returns the torus knot mesh
  57024. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57025. */
  57026. static CreateTorusKnot(name: string, options: {
  57027. radius?: number;
  57028. tube?: number;
  57029. radialSegments?: number;
  57030. tubularSegments?: number;
  57031. p?: number;
  57032. q?: number;
  57033. updatable?: boolean;
  57034. sideOrientation?: number;
  57035. frontUVs?: Vector4;
  57036. backUVs?: Vector4;
  57037. }, scene?: Nullable<Scene>): Mesh;
  57038. /**
  57039. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57040. * * 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
  57041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57042. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57043. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57044. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57045. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57046. * * 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
  57047. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57050. * @param name defines the name of the new line system
  57051. * @param options defines the options used to create the line system
  57052. * @param scene defines the hosting scene
  57053. * @returns a new line system mesh
  57054. */
  57055. static CreateLineSystem(name: string, options: {
  57056. lines: Vector3[][];
  57057. updatable?: boolean;
  57058. instance?: Nullable<LinesMesh>;
  57059. colors?: Nullable<Color4[][]>;
  57060. useVertexAlpha?: boolean;
  57061. }, scene: Nullable<Scene>): LinesMesh;
  57062. /**
  57063. * Creates a line mesh
  57064. * 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
  57065. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57066. * * The parameter `points` is an array successive Vector3
  57067. * * 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
  57068. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57069. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57070. * * When updating an instance, remember that only point positions can change, not the number of points
  57071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57073. * @param name defines the name of the new line system
  57074. * @param options defines the options used to create the line system
  57075. * @param scene defines the hosting scene
  57076. * @returns a new line mesh
  57077. */
  57078. static CreateLines(name: string, options: {
  57079. points: Vector3[];
  57080. updatable?: boolean;
  57081. instance?: Nullable<LinesMesh>;
  57082. colors?: Color4[];
  57083. useVertexAlpha?: boolean;
  57084. }, scene?: Nullable<Scene>): LinesMesh;
  57085. /**
  57086. * Creates a dashed line mesh
  57087. * * 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
  57088. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57089. * * The parameter `points` is an array successive Vector3
  57090. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57091. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57092. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57093. * * 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
  57094. * * When updating an instance, remember that only point positions can change, not the number of points
  57095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57096. * @param name defines the name of the mesh
  57097. * @param options defines the options used to create the mesh
  57098. * @param scene defines the hosting scene
  57099. * @returns the dashed line mesh
  57100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57101. */
  57102. static CreateDashedLines(name: string, options: {
  57103. points: Vector3[];
  57104. dashSize?: number;
  57105. gapSize?: number;
  57106. dashNb?: number;
  57107. updatable?: boolean;
  57108. instance?: LinesMesh;
  57109. }, scene?: Nullable<Scene>): LinesMesh;
  57110. /**
  57111. * 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.
  57112. * * 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.
  57113. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57114. * * 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.
  57115. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57116. * * 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
  57117. * * 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
  57118. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57123. * @param name defines the name of the mesh
  57124. * @param options defines the options used to create the mesh
  57125. * @param scene defines the hosting scene
  57126. * @returns the extruded shape mesh
  57127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57129. */
  57130. static ExtrudeShape(name: string, options: {
  57131. shape: Vector3[];
  57132. path: Vector3[];
  57133. scale?: number;
  57134. rotation?: number;
  57135. cap?: number;
  57136. updatable?: boolean;
  57137. sideOrientation?: number;
  57138. frontUVs?: Vector4;
  57139. backUVs?: Vector4;
  57140. instance?: Mesh;
  57141. invertUV?: boolean;
  57142. }, scene?: Nullable<Scene>): Mesh;
  57143. /**
  57144. * Creates an custom extruded shape mesh.
  57145. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57146. * * 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.
  57147. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57148. * * 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
  57149. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57150. * * 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
  57151. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57152. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57153. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57154. * * 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
  57155. * * 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
  57156. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57161. * @param name defines the name of the mesh
  57162. * @param options defines the options used to create the mesh
  57163. * @param scene defines the hosting scene
  57164. * @returns the custom extruded shape mesh
  57165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57168. */
  57169. static ExtrudeShapeCustom(name: string, options: {
  57170. shape: Vector3[];
  57171. path: Vector3[];
  57172. scaleFunction?: any;
  57173. rotationFunction?: any;
  57174. ribbonCloseArray?: boolean;
  57175. ribbonClosePath?: boolean;
  57176. cap?: number;
  57177. updatable?: boolean;
  57178. sideOrientation?: number;
  57179. frontUVs?: Vector4;
  57180. backUVs?: Vector4;
  57181. instance?: Mesh;
  57182. invertUV?: boolean;
  57183. }, scene?: Nullable<Scene>): Mesh;
  57184. /**
  57185. * Creates lathe mesh.
  57186. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57187. * * 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
  57188. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57189. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57190. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57191. * * 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
  57192. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57193. * * 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
  57194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57198. * @param name defines the name of the mesh
  57199. * @param options defines the options used to create the mesh
  57200. * @param scene defines the hosting scene
  57201. * @returns the lathe mesh
  57202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57203. */
  57204. static CreateLathe(name: string, options: {
  57205. shape: Vector3[];
  57206. radius?: number;
  57207. tessellation?: number;
  57208. clip?: number;
  57209. arc?: number;
  57210. closed?: boolean;
  57211. updatable?: boolean;
  57212. sideOrientation?: number;
  57213. frontUVs?: Vector4;
  57214. backUVs?: Vector4;
  57215. cap?: number;
  57216. invertUV?: boolean;
  57217. }, scene?: Nullable<Scene>): Mesh;
  57218. /**
  57219. * Creates a tiled plane mesh
  57220. * * You can set a limited pattern arrangement with the tiles
  57221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57224. * @param name defines the name of the mesh
  57225. * @param options defines the options used to create the mesh
  57226. * @param scene defines the hosting scene
  57227. * @returns the plane mesh
  57228. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57229. */
  57230. static CreateTiledPlane(name: string, options: {
  57231. pattern?: number;
  57232. tileSize?: number;
  57233. tileWidth?: number;
  57234. tileHeight?: number;
  57235. size?: number;
  57236. width?: number;
  57237. height?: number;
  57238. alignHorizontal?: number;
  57239. alignVertical?: number;
  57240. sideOrientation?: number;
  57241. frontUVs?: Vector4;
  57242. backUVs?: Vector4;
  57243. updatable?: boolean;
  57244. }, scene?: Nullable<Scene>): Mesh;
  57245. /**
  57246. * Creates a plane mesh
  57247. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57248. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57249. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57253. * @param name defines the name of the mesh
  57254. * @param options defines the options used to create the mesh
  57255. * @param scene defines the hosting scene
  57256. * @returns the plane mesh
  57257. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57258. */
  57259. static CreatePlane(name: string, options: {
  57260. size?: number;
  57261. width?: number;
  57262. height?: number;
  57263. sideOrientation?: number;
  57264. frontUVs?: Vector4;
  57265. backUVs?: Vector4;
  57266. updatable?: boolean;
  57267. sourcePlane?: Plane;
  57268. }, scene?: Nullable<Scene>): Mesh;
  57269. /**
  57270. * Creates a ground mesh
  57271. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57272. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57274. * @param name defines the name of the mesh
  57275. * @param options defines the options used to create the mesh
  57276. * @param scene defines the hosting scene
  57277. * @returns the ground mesh
  57278. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57279. */
  57280. static CreateGround(name: string, options: {
  57281. width?: number;
  57282. height?: number;
  57283. subdivisions?: number;
  57284. subdivisionsX?: number;
  57285. subdivisionsY?: number;
  57286. updatable?: boolean;
  57287. }, scene?: Nullable<Scene>): Mesh;
  57288. /**
  57289. * Creates a tiled ground mesh
  57290. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57291. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57292. * * 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
  57293. * * 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
  57294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57295. * @param name defines the name of the mesh
  57296. * @param options defines the options used to create the mesh
  57297. * @param scene defines the hosting scene
  57298. * @returns the tiled ground mesh
  57299. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57300. */
  57301. static CreateTiledGround(name: string, options: {
  57302. xmin: number;
  57303. zmin: number;
  57304. xmax: number;
  57305. zmax: number;
  57306. subdivisions?: {
  57307. w: number;
  57308. h: number;
  57309. };
  57310. precision?: {
  57311. w: number;
  57312. h: number;
  57313. };
  57314. updatable?: boolean;
  57315. }, scene?: Nullable<Scene>): Mesh;
  57316. /**
  57317. * Creates a ground mesh from a height map
  57318. * * The parameter `url` sets the URL of the height map image resource.
  57319. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57320. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57321. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57322. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57323. * * 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.
  57324. * * 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).
  57325. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57327. * @param name defines the name of the mesh
  57328. * @param url defines the url to the height map
  57329. * @param options defines the options used to create the mesh
  57330. * @param scene defines the hosting scene
  57331. * @returns the ground mesh
  57332. * @see https://doc.babylonjs.com/babylon101/height_map
  57333. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57334. */
  57335. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57336. width?: number;
  57337. height?: number;
  57338. subdivisions?: number;
  57339. minHeight?: number;
  57340. maxHeight?: number;
  57341. colorFilter?: Color3;
  57342. alphaFilter?: number;
  57343. updatable?: boolean;
  57344. onReady?: (mesh: GroundMesh) => void;
  57345. }, scene?: Nullable<Scene>): GroundMesh;
  57346. /**
  57347. * Creates a polygon mesh
  57348. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57349. * * 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
  57350. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57353. * * Remember you can only change the shape positions, not their number when updating a polygon
  57354. * @param name defines the name of the mesh
  57355. * @param options defines the options used to create the mesh
  57356. * @param scene defines the hosting scene
  57357. * @param earcutInjection can be used to inject your own earcut reference
  57358. * @returns the polygon mesh
  57359. */
  57360. static CreatePolygon(name: string, options: {
  57361. shape: Vector3[];
  57362. holes?: Vector3[][];
  57363. depth?: number;
  57364. faceUV?: Vector4[];
  57365. faceColors?: Color4[];
  57366. updatable?: boolean;
  57367. sideOrientation?: number;
  57368. frontUVs?: Vector4;
  57369. backUVs?: Vector4;
  57370. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57371. /**
  57372. * Creates an extruded polygon mesh, with depth in the Y direction.
  57373. * * 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)
  57374. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57375. * @param name defines the name of the mesh
  57376. * @param options defines the options used to create the mesh
  57377. * @param scene defines the hosting scene
  57378. * @param earcutInjection can be used to inject your own earcut reference
  57379. * @returns the polygon mesh
  57380. */
  57381. static ExtrudePolygon(name: string, options: {
  57382. shape: Vector3[];
  57383. holes?: Vector3[][];
  57384. depth?: number;
  57385. faceUV?: Vector4[];
  57386. faceColors?: Color4[];
  57387. updatable?: boolean;
  57388. sideOrientation?: number;
  57389. frontUVs?: Vector4;
  57390. backUVs?: Vector4;
  57391. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57392. /**
  57393. * Creates a tube mesh.
  57394. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57395. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57396. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57397. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57398. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57399. * * 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)
  57400. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57401. * * 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
  57402. * * 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
  57403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57407. * @param name defines the name of the mesh
  57408. * @param options defines the options used to create the mesh
  57409. * @param scene defines the hosting scene
  57410. * @returns the tube mesh
  57411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57412. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57413. */
  57414. static CreateTube(name: string, options: {
  57415. path: Vector3[];
  57416. radius?: number;
  57417. tessellation?: number;
  57418. radiusFunction?: {
  57419. (i: number, distance: number): number;
  57420. };
  57421. cap?: number;
  57422. arc?: number;
  57423. updatable?: boolean;
  57424. sideOrientation?: number;
  57425. frontUVs?: Vector4;
  57426. backUVs?: Vector4;
  57427. instance?: Mesh;
  57428. invertUV?: boolean;
  57429. }, scene?: Nullable<Scene>): Mesh;
  57430. /**
  57431. * Creates a polyhedron mesh
  57432. * * 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
  57433. * * The parameter `size` (positive float, default 1) sets the polygon size
  57434. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57435. * * 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`
  57436. * * 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
  57437. * * 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)`)
  57438. * * 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
  57439. * * 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
  57440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57443. * @param name defines the name of the mesh
  57444. * @param options defines the options used to create the mesh
  57445. * @param scene defines the hosting scene
  57446. * @returns the polyhedron mesh
  57447. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57448. */
  57449. static CreatePolyhedron(name: string, options: {
  57450. type?: number;
  57451. size?: number;
  57452. sizeX?: number;
  57453. sizeY?: number;
  57454. sizeZ?: number;
  57455. custom?: any;
  57456. faceUV?: Vector4[];
  57457. faceColors?: Color4[];
  57458. flat?: boolean;
  57459. updatable?: boolean;
  57460. sideOrientation?: number;
  57461. frontUVs?: Vector4;
  57462. backUVs?: Vector4;
  57463. }, scene?: Nullable<Scene>): Mesh;
  57464. /**
  57465. * Creates a decal mesh.
  57466. * 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
  57467. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57468. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57469. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57470. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57471. * @param name defines the name of the mesh
  57472. * @param sourceMesh defines the mesh where the decal must be applied
  57473. * @param options defines the options used to create the mesh
  57474. * @param scene defines the hosting scene
  57475. * @returns the decal mesh
  57476. * @see https://doc.babylonjs.com/how_to/decals
  57477. */
  57478. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57479. position?: Vector3;
  57480. normal?: Vector3;
  57481. size?: Vector3;
  57482. angle?: number;
  57483. }): Mesh;
  57484. }
  57485. }
  57486. declare module "babylonjs/Meshes/meshSimplification" {
  57487. import { Mesh } from "babylonjs/Meshes/mesh";
  57488. /**
  57489. * A simplifier interface for future simplification implementations
  57490. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57491. */
  57492. export interface ISimplifier {
  57493. /**
  57494. * Simplification of a given mesh according to the given settings.
  57495. * Since this requires computation, it is assumed that the function runs async.
  57496. * @param settings The settings of the simplification, including quality and distance
  57497. * @param successCallback A callback that will be called after the mesh was simplified.
  57498. * @param errorCallback in case of an error, this callback will be called. optional.
  57499. */
  57500. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57501. }
  57502. /**
  57503. * Expected simplification settings.
  57504. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57506. */
  57507. export interface ISimplificationSettings {
  57508. /**
  57509. * Gets or sets the expected quality
  57510. */
  57511. quality: number;
  57512. /**
  57513. * Gets or sets the distance when this optimized version should be used
  57514. */
  57515. distance: number;
  57516. /**
  57517. * Gets an already optimized mesh
  57518. */
  57519. optimizeMesh?: boolean;
  57520. }
  57521. /**
  57522. * Class used to specify simplification options
  57523. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57524. */
  57525. export class SimplificationSettings implements ISimplificationSettings {
  57526. /** expected quality */
  57527. quality: number;
  57528. /** distance when this optimized version should be used */
  57529. distance: number;
  57530. /** already optimized mesh */
  57531. optimizeMesh?: boolean | undefined;
  57532. /**
  57533. * Creates a SimplificationSettings
  57534. * @param quality expected quality
  57535. * @param distance distance when this optimized version should be used
  57536. * @param optimizeMesh already optimized mesh
  57537. */
  57538. constructor(
  57539. /** expected quality */
  57540. quality: number,
  57541. /** distance when this optimized version should be used */
  57542. distance: number,
  57543. /** already optimized mesh */
  57544. optimizeMesh?: boolean | undefined);
  57545. }
  57546. /**
  57547. * Interface used to define a simplification task
  57548. */
  57549. export interface ISimplificationTask {
  57550. /**
  57551. * Array of settings
  57552. */
  57553. settings: Array<ISimplificationSettings>;
  57554. /**
  57555. * Simplification type
  57556. */
  57557. simplificationType: SimplificationType;
  57558. /**
  57559. * Mesh to simplify
  57560. */
  57561. mesh: Mesh;
  57562. /**
  57563. * Callback called on success
  57564. */
  57565. successCallback?: () => void;
  57566. /**
  57567. * Defines if parallel processing can be used
  57568. */
  57569. parallelProcessing: boolean;
  57570. }
  57571. /**
  57572. * Queue used to order the simplification tasks
  57573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57574. */
  57575. export class SimplificationQueue {
  57576. private _simplificationArray;
  57577. /**
  57578. * Gets a boolean indicating that the process is still running
  57579. */
  57580. running: boolean;
  57581. /**
  57582. * Creates a new queue
  57583. */
  57584. constructor();
  57585. /**
  57586. * Adds a new simplification task
  57587. * @param task defines a task to add
  57588. */
  57589. addTask(task: ISimplificationTask): void;
  57590. /**
  57591. * Execute next task
  57592. */
  57593. executeNext(): void;
  57594. /**
  57595. * Execute a simplification task
  57596. * @param task defines the task to run
  57597. */
  57598. runSimplification(task: ISimplificationTask): void;
  57599. private getSimplifier;
  57600. }
  57601. /**
  57602. * The implemented types of simplification
  57603. * At the moment only Quadratic Error Decimation is implemented
  57604. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57605. */
  57606. export enum SimplificationType {
  57607. /** Quadratic error decimation */
  57608. QUADRATIC = 0
  57609. }
  57610. }
  57611. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57612. import { Scene } from "babylonjs/scene";
  57613. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57614. import { ISceneComponent } from "babylonjs/sceneComponent";
  57615. module "babylonjs/scene" {
  57616. interface Scene {
  57617. /** @hidden (Backing field) */
  57618. _simplificationQueue: SimplificationQueue;
  57619. /**
  57620. * Gets or sets the simplification queue attached to the scene
  57621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57622. */
  57623. simplificationQueue: SimplificationQueue;
  57624. }
  57625. }
  57626. module "babylonjs/Meshes/mesh" {
  57627. interface Mesh {
  57628. /**
  57629. * Simplify the mesh according to the given array of settings.
  57630. * Function will return immediately and will simplify async
  57631. * @param settings a collection of simplification settings
  57632. * @param parallelProcessing should all levels calculate parallel or one after the other
  57633. * @param simplificationType the type of simplification to run
  57634. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57635. * @returns the current mesh
  57636. */
  57637. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57638. }
  57639. }
  57640. /**
  57641. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57642. * created in a scene
  57643. */
  57644. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57645. /**
  57646. * The component name helpfull to identify the component in the list of scene components.
  57647. */
  57648. readonly name: string;
  57649. /**
  57650. * The scene the component belongs to.
  57651. */
  57652. scene: Scene;
  57653. /**
  57654. * Creates a new instance of the component for the given scene
  57655. * @param scene Defines the scene to register the component in
  57656. */
  57657. constructor(scene: Scene);
  57658. /**
  57659. * Registers the component in a given scene
  57660. */
  57661. register(): void;
  57662. /**
  57663. * Rebuilds the elements related to this component in case of
  57664. * context lost for instance.
  57665. */
  57666. rebuild(): void;
  57667. /**
  57668. * Disposes the component and the associated ressources
  57669. */
  57670. dispose(): void;
  57671. private _beforeCameraUpdate;
  57672. }
  57673. }
  57674. declare module "babylonjs/Meshes/Builders/index" {
  57675. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57676. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57677. export * from "babylonjs/Meshes/Builders/discBuilder";
  57678. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57679. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57680. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57681. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57682. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57683. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57684. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57685. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57686. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57687. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57688. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57689. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57690. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57691. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57692. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57693. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57694. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57695. }
  57696. declare module "babylonjs/Meshes/index" {
  57697. export * from "babylonjs/Meshes/abstractMesh";
  57698. export * from "babylonjs/Meshes/buffer";
  57699. export * from "babylonjs/Meshes/Compression/index";
  57700. export * from "babylonjs/Meshes/csg";
  57701. export * from "babylonjs/Meshes/geometry";
  57702. export * from "babylonjs/Meshes/groundMesh";
  57703. export * from "babylonjs/Meshes/trailMesh";
  57704. export * from "babylonjs/Meshes/instancedMesh";
  57705. export * from "babylonjs/Meshes/linesMesh";
  57706. export * from "babylonjs/Meshes/mesh";
  57707. export * from "babylonjs/Meshes/mesh.vertexData";
  57708. export * from "babylonjs/Meshes/meshBuilder";
  57709. export * from "babylonjs/Meshes/meshSimplification";
  57710. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57711. export * from "babylonjs/Meshes/polygonMesh";
  57712. export * from "babylonjs/Meshes/subMesh";
  57713. export * from "babylonjs/Meshes/meshLODLevel";
  57714. export * from "babylonjs/Meshes/transformNode";
  57715. export * from "babylonjs/Meshes/Builders/index";
  57716. export * from "babylonjs/Meshes/dataBuffer";
  57717. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57718. }
  57719. declare module "babylonjs/Morph/index" {
  57720. export * from "babylonjs/Morph/morphTarget";
  57721. export * from "babylonjs/Morph/morphTargetManager";
  57722. }
  57723. declare module "babylonjs/Navigation/INavigationEngine" {
  57724. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57725. import { Vector3 } from "babylonjs/Maths/math";
  57726. import { Mesh } from "babylonjs/Meshes/mesh";
  57727. import { Scene } from "babylonjs/scene";
  57728. /**
  57729. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57730. */
  57731. export interface INavigationEnginePlugin {
  57732. /**
  57733. * plugin name
  57734. */
  57735. name: string;
  57736. /**
  57737. * Creates a navigation mesh
  57738. * @param meshes array of all the geometry used to compute the navigatio mesh
  57739. * @param parameters bunch of parameters used to filter geometry
  57740. */
  57741. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57742. /**
  57743. * Create a navigation mesh debug mesh
  57744. * @param scene is where the mesh will be added
  57745. * @returns debug display mesh
  57746. */
  57747. createDebugNavMesh(scene: Scene): Mesh;
  57748. /**
  57749. * Get a navigation mesh constrained position, closest to the parameter position
  57750. * @param position world position
  57751. * @returns the closest point to position constrained by the navigation mesh
  57752. */
  57753. getClosestPoint(position: Vector3): Vector3;
  57754. /**
  57755. * Get a navigation mesh constrained position, within a particular radius
  57756. * @param position world position
  57757. * @param maxRadius the maximum distance to the constrained world position
  57758. * @returns the closest point to position constrained by the navigation mesh
  57759. */
  57760. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57761. /**
  57762. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57763. * @param start world position
  57764. * @param end world position
  57765. * @returns array containing world position composing the path
  57766. */
  57767. computePath(start: Vector3, end: Vector3): Vector3[];
  57768. /**
  57769. * If this plugin is supported
  57770. * @returns true if plugin is supported
  57771. */
  57772. isSupported(): boolean;
  57773. /**
  57774. * Create a new Crowd so you can add agents
  57775. * @param maxAgents the maximum agent count in the crowd
  57776. * @param maxAgentRadius the maximum radius an agent can have
  57777. * @param scene to attach the crowd to
  57778. * @returns the crowd you can add agents to
  57779. */
  57780. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57781. /**
  57782. * Release all resources
  57783. */
  57784. dispose(): void;
  57785. }
  57786. /**
  57787. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57788. */
  57789. export interface ICrowd {
  57790. /**
  57791. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57792. * You can attach anything to that node. The node position is updated in the scene update tick.
  57793. * @param pos world position that will be constrained by the navigation mesh
  57794. * @param parameters agent parameters
  57795. * @param transform hooked to the agent that will be update by the scene
  57796. * @returns agent index
  57797. */
  57798. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57799. /**
  57800. * Returns the agent position in world space
  57801. * @param index agent index returned by addAgent
  57802. * @returns world space position
  57803. */
  57804. getAgentPosition(index: number): Vector3;
  57805. /**
  57806. * Gets the agent velocity in world space
  57807. * @param index agent index returned by addAgent
  57808. * @returns world space velocity
  57809. */
  57810. getAgentVelocity(index: number): Vector3;
  57811. /**
  57812. * remove a particular agent previously created
  57813. * @param index agent index returned by addAgent
  57814. */
  57815. removeAgent(index: number): void;
  57816. /**
  57817. * get the list of all agents attached to this crowd
  57818. * @returns list of agent indices
  57819. */
  57820. getAgents(): number[];
  57821. /**
  57822. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57823. * @param deltaTime in seconds
  57824. */
  57825. update(deltaTime: number): void;
  57826. /**
  57827. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57828. * @param index agent index returned by addAgent
  57829. * @param destination targeted world position
  57830. */
  57831. agentGoto(index: number, destination: Vector3): void;
  57832. /**
  57833. * Release all resources
  57834. */
  57835. dispose(): void;
  57836. }
  57837. /**
  57838. * Configures an agent
  57839. */
  57840. export interface IAgentParameters {
  57841. /**
  57842. * Agent radius. [Limit: >= 0]
  57843. */
  57844. radius: number;
  57845. /**
  57846. * Agent height. [Limit: > 0]
  57847. */
  57848. height: number;
  57849. /**
  57850. * Maximum allowed acceleration. [Limit: >= 0]
  57851. */
  57852. maxAcceleration: number;
  57853. /**
  57854. * Maximum allowed speed. [Limit: >= 0]
  57855. */
  57856. maxSpeed: number;
  57857. /**
  57858. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57859. */
  57860. collisionQueryRange: number;
  57861. /**
  57862. * The path visibility optimization range. [Limit: > 0]
  57863. */
  57864. pathOptimizationRange: number;
  57865. /**
  57866. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57867. */
  57868. separationWeight: number;
  57869. }
  57870. /**
  57871. * Configures the navigation mesh creation
  57872. */
  57873. export interface INavMeshParameters {
  57874. /**
  57875. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57876. */
  57877. cs: number;
  57878. /**
  57879. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57880. */
  57881. ch: number;
  57882. /**
  57883. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57884. */
  57885. walkableSlopeAngle: number;
  57886. /**
  57887. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57888. * be considered walkable. [Limit: >= 3] [Units: vx]
  57889. */
  57890. walkableHeight: number;
  57891. /**
  57892. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57893. */
  57894. walkableClimb: number;
  57895. /**
  57896. * The distance to erode/shrink the walkable area of the heightfield away from
  57897. * obstructions. [Limit: >=0] [Units: vx]
  57898. */
  57899. walkableRadius: number;
  57900. /**
  57901. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57902. */
  57903. maxEdgeLen: number;
  57904. /**
  57905. * The maximum distance a simplfied contour's border edges should deviate
  57906. * the original raw contour. [Limit: >=0] [Units: vx]
  57907. */
  57908. maxSimplificationError: number;
  57909. /**
  57910. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57911. */
  57912. minRegionArea: number;
  57913. /**
  57914. * Any regions with a span count smaller than this value will, if possible,
  57915. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57916. */
  57917. mergeRegionArea: number;
  57918. /**
  57919. * The maximum number of vertices allowed for polygons generated during the
  57920. * contour to polygon conversion process. [Limit: >= 3]
  57921. */
  57922. maxVertsPerPoly: number;
  57923. /**
  57924. * Sets the sampling distance to use when generating the detail mesh.
  57925. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57926. */
  57927. detailSampleDist: number;
  57928. /**
  57929. * The maximum distance the detail mesh surface should deviate from heightfield
  57930. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57931. */
  57932. detailSampleMaxError: number;
  57933. }
  57934. }
  57935. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57936. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57937. import { Mesh } from "babylonjs/Meshes/mesh";
  57938. import { Scene } from "babylonjs/scene";
  57939. import { Vector3 } from "babylonjs/Maths/math";
  57940. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57941. /**
  57942. * RecastJS navigation plugin
  57943. */
  57944. export class RecastJSPlugin implements INavigationEnginePlugin {
  57945. /**
  57946. * Reference to the Recast library
  57947. */
  57948. bjsRECAST: any;
  57949. /**
  57950. * plugin name
  57951. */
  57952. name: string;
  57953. /**
  57954. * the first navmesh created. We might extend this to support multiple navmeshes
  57955. */
  57956. navMesh: any;
  57957. /**
  57958. * Initializes the recastJS plugin
  57959. * @param recastInjection can be used to inject your own recast reference
  57960. */
  57961. constructor(recastInjection?: any);
  57962. /**
  57963. * Creates a navigation mesh
  57964. * @param meshes array of all the geometry used to compute the navigatio mesh
  57965. * @param parameters bunch of parameters used to filter geometry
  57966. */
  57967. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57968. /**
  57969. * Create a navigation mesh debug mesh
  57970. * @param scene is where the mesh will be added
  57971. * @returns debug display mesh
  57972. */
  57973. createDebugNavMesh(scene: Scene): Mesh;
  57974. /**
  57975. * Get a navigation mesh constrained position, closest to the parameter position
  57976. * @param position world position
  57977. * @returns the closest point to position constrained by the navigation mesh
  57978. */
  57979. getClosestPoint(position: Vector3): Vector3;
  57980. /**
  57981. * Get a navigation mesh constrained position, within a particular radius
  57982. * @param position world position
  57983. * @param maxRadius the maximum distance to the constrained world position
  57984. * @returns the closest point to position constrained by the navigation mesh
  57985. */
  57986. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57987. /**
  57988. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57989. * @param start world position
  57990. * @param end world position
  57991. * @returns array containing world position composing the path
  57992. */
  57993. computePath(start: Vector3, end: Vector3): Vector3[];
  57994. /**
  57995. * Create a new Crowd so you can add agents
  57996. * @param maxAgents the maximum agent count in the crowd
  57997. * @param maxAgentRadius the maximum radius an agent can have
  57998. * @param scene to attach the crowd to
  57999. * @returns the crowd you can add agents to
  58000. */
  58001. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58002. /**
  58003. * Disposes
  58004. */
  58005. dispose(): void;
  58006. /**
  58007. * If this plugin is supported
  58008. * @returns true if plugin is supported
  58009. */
  58010. isSupported(): boolean;
  58011. }
  58012. /**
  58013. * Recast detour crowd implementation
  58014. */
  58015. export class RecastJSCrowd implements ICrowd {
  58016. /**
  58017. * Recast/detour plugin
  58018. */
  58019. bjsRECASTPlugin: RecastJSPlugin;
  58020. /**
  58021. * Link to the detour crowd
  58022. */
  58023. recastCrowd: any;
  58024. /**
  58025. * One transform per agent
  58026. */
  58027. transforms: TransformNode[];
  58028. /**
  58029. * All agents created
  58030. */
  58031. agents: number[];
  58032. /**
  58033. * Link to the scene is kept to unregister the crowd from the scene
  58034. */
  58035. private _scene;
  58036. /**
  58037. * Observer for crowd updates
  58038. */
  58039. private _onBeforeAnimationsObserver;
  58040. /**
  58041. * Constructor
  58042. * @param plugin recastJS plugin
  58043. * @param maxAgents the maximum agent count in the crowd
  58044. * @param maxAgentRadius the maximum radius an agent can have
  58045. * @param scene to attach the crowd to
  58046. * @returns the crowd you can add agents to
  58047. */
  58048. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58049. /**
  58050. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58051. * You can attach anything to that node. The node position is updated in the scene update tick.
  58052. * @param pos world position that will be constrained by the navigation mesh
  58053. * @param parameters agent parameters
  58054. * @param transform hooked to the agent that will be update by the scene
  58055. * @returns agent index
  58056. */
  58057. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58058. /**
  58059. * Returns the agent position in world space
  58060. * @param index agent index returned by addAgent
  58061. * @returns world space position
  58062. */
  58063. getAgentPosition(index: number): Vector3;
  58064. /**
  58065. * Returns the agent velocity in world space
  58066. * @param index agent index returned by addAgent
  58067. * @returns world space velocity
  58068. */
  58069. getAgentVelocity(index: number): Vector3;
  58070. /**
  58071. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58072. * @param index agent index returned by addAgent
  58073. * @param destination targeted world position
  58074. */
  58075. agentGoto(index: number, destination: Vector3): void;
  58076. /**
  58077. * remove a particular agent previously created
  58078. * @param index agent index returned by addAgent
  58079. */
  58080. removeAgent(index: number): void;
  58081. /**
  58082. * get the list of all agents attached to this crowd
  58083. * @returns list of agent indices
  58084. */
  58085. getAgents(): number[];
  58086. /**
  58087. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58088. * @param deltaTime in seconds
  58089. */
  58090. update(deltaTime: number): void;
  58091. /**
  58092. * Release all resources
  58093. */
  58094. dispose(): void;
  58095. }
  58096. }
  58097. declare module "babylonjs/Navigation/Plugins/index" {
  58098. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58099. }
  58100. declare module "babylonjs/Navigation/index" {
  58101. export * from "babylonjs/Navigation/INavigationEngine";
  58102. export * from "babylonjs/Navigation/Plugins/index";
  58103. }
  58104. declare module "babylonjs/Offline/database" {
  58105. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58106. /**
  58107. * Class used to enable access to IndexedDB
  58108. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58109. */
  58110. export class Database implements IOfflineProvider {
  58111. private _callbackManifestChecked;
  58112. private _currentSceneUrl;
  58113. private _db;
  58114. private _enableSceneOffline;
  58115. private _enableTexturesOffline;
  58116. private _manifestVersionFound;
  58117. private _mustUpdateRessources;
  58118. private _hasReachedQuota;
  58119. private _isSupported;
  58120. private _idbFactory;
  58121. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58122. private static IsUASupportingBlobStorage;
  58123. /**
  58124. * Gets a boolean indicating if Database storate is enabled (off by default)
  58125. */
  58126. static IDBStorageEnabled: boolean;
  58127. /**
  58128. * Gets a boolean indicating if scene must be saved in the database
  58129. */
  58130. readonly enableSceneOffline: boolean;
  58131. /**
  58132. * Gets a boolean indicating if textures must be saved in the database
  58133. */
  58134. readonly enableTexturesOffline: boolean;
  58135. /**
  58136. * Creates a new Database
  58137. * @param urlToScene defines the url to load the scene
  58138. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58139. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58140. */
  58141. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58142. private static _ParseURL;
  58143. private static _ReturnFullUrlLocation;
  58144. private _checkManifestFile;
  58145. /**
  58146. * Open the database and make it available
  58147. * @param successCallback defines the callback to call on success
  58148. * @param errorCallback defines the callback to call on error
  58149. */
  58150. open(successCallback: () => void, errorCallback: () => void): void;
  58151. /**
  58152. * Loads an image from the database
  58153. * @param url defines the url to load from
  58154. * @param image defines the target DOM image
  58155. */
  58156. loadImage(url: string, image: HTMLImageElement): void;
  58157. private _loadImageFromDBAsync;
  58158. private _saveImageIntoDBAsync;
  58159. private _checkVersionFromDB;
  58160. private _loadVersionFromDBAsync;
  58161. private _saveVersionIntoDBAsync;
  58162. /**
  58163. * Loads a file from database
  58164. * @param url defines the URL to load from
  58165. * @param sceneLoaded defines a callback to call on success
  58166. * @param progressCallBack defines a callback to call when progress changed
  58167. * @param errorCallback defines a callback to call on error
  58168. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58169. */
  58170. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58171. private _loadFileAsync;
  58172. private _saveFileAsync;
  58173. /**
  58174. * Validates if xhr data is correct
  58175. * @param xhr defines the request to validate
  58176. * @param dataType defines the expected data type
  58177. * @returns true if data is correct
  58178. */
  58179. private static _ValidateXHRData;
  58180. }
  58181. }
  58182. declare module "babylonjs/Offline/index" {
  58183. export * from "babylonjs/Offline/database";
  58184. export * from "babylonjs/Offline/IOfflineProvider";
  58185. }
  58186. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58187. /** @hidden */
  58188. export var gpuUpdateParticlesPixelShader: {
  58189. name: string;
  58190. shader: string;
  58191. };
  58192. }
  58193. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58194. /** @hidden */
  58195. export var gpuUpdateParticlesVertexShader: {
  58196. name: string;
  58197. shader: string;
  58198. };
  58199. }
  58200. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58201. /** @hidden */
  58202. export var clipPlaneFragmentDeclaration2: {
  58203. name: string;
  58204. shader: string;
  58205. };
  58206. }
  58207. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58208. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58209. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58211. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58212. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58213. /** @hidden */
  58214. export var gpuRenderParticlesPixelShader: {
  58215. name: string;
  58216. shader: string;
  58217. };
  58218. }
  58219. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58220. /** @hidden */
  58221. export var clipPlaneVertexDeclaration2: {
  58222. name: string;
  58223. shader: string;
  58224. };
  58225. }
  58226. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58227. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58228. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58229. /** @hidden */
  58230. export var gpuRenderParticlesVertexShader: {
  58231. name: string;
  58232. shader: string;
  58233. };
  58234. }
  58235. declare module "babylonjs/Particles/gpuParticleSystem" {
  58236. import { Nullable } from "babylonjs/types";
  58237. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58238. import { Observable } from "babylonjs/Misc/observable";
  58239. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58240. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58241. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58242. import { Scene, IDisposable } from "babylonjs/scene";
  58243. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58245. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58246. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58247. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58248. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58249. /**
  58250. * This represents a GPU particle system in Babylon
  58251. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58252. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58253. */
  58254. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58255. /**
  58256. * The layer mask we are rendering the particles through.
  58257. */
  58258. layerMask: number;
  58259. private _capacity;
  58260. private _activeCount;
  58261. private _currentActiveCount;
  58262. private _accumulatedCount;
  58263. private _renderEffect;
  58264. private _updateEffect;
  58265. private _buffer0;
  58266. private _buffer1;
  58267. private _spriteBuffer;
  58268. private _updateVAO;
  58269. private _renderVAO;
  58270. private _targetIndex;
  58271. private _sourceBuffer;
  58272. private _targetBuffer;
  58273. private _engine;
  58274. private _currentRenderId;
  58275. private _started;
  58276. private _stopped;
  58277. private _timeDelta;
  58278. private _randomTexture;
  58279. private _randomTexture2;
  58280. private _attributesStrideSize;
  58281. private _updateEffectOptions;
  58282. private _randomTextureSize;
  58283. private _actualFrame;
  58284. private readonly _rawTextureWidth;
  58285. /**
  58286. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58287. */
  58288. static readonly IsSupported: boolean;
  58289. /**
  58290. * An event triggered when the system is disposed.
  58291. */
  58292. onDisposeObservable: Observable<GPUParticleSystem>;
  58293. /**
  58294. * Gets the maximum number of particles active at the same time.
  58295. * @returns The max number of active particles.
  58296. */
  58297. getCapacity(): number;
  58298. /**
  58299. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58300. * to override the particles.
  58301. */
  58302. forceDepthWrite: boolean;
  58303. /**
  58304. * Gets or set the number of active particles
  58305. */
  58306. activeParticleCount: number;
  58307. private _preWarmDone;
  58308. /**
  58309. * Is this system ready to be used/rendered
  58310. * @return true if the system is ready
  58311. */
  58312. isReady(): boolean;
  58313. /**
  58314. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58315. * @returns True if it has been started, otherwise false.
  58316. */
  58317. isStarted(): boolean;
  58318. /**
  58319. * Starts the particle system and begins to emit
  58320. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58321. */
  58322. start(delay?: number): void;
  58323. /**
  58324. * Stops the particle system.
  58325. */
  58326. stop(): void;
  58327. /**
  58328. * Remove all active particles
  58329. */
  58330. reset(): void;
  58331. /**
  58332. * Returns the string "GPUParticleSystem"
  58333. * @returns a string containing the class name
  58334. */
  58335. getClassName(): string;
  58336. private _colorGradientsTexture;
  58337. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58338. /**
  58339. * Adds a new color gradient
  58340. * @param gradient defines the gradient to use (between 0 and 1)
  58341. * @param color1 defines the color to affect to the specified gradient
  58342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58343. * @returns the current particle system
  58344. */
  58345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58346. /**
  58347. * Remove a specific color gradient
  58348. * @param gradient defines the gradient to remove
  58349. * @returns the current particle system
  58350. */
  58351. removeColorGradient(gradient: number): GPUParticleSystem;
  58352. private _angularSpeedGradientsTexture;
  58353. private _sizeGradientsTexture;
  58354. private _velocityGradientsTexture;
  58355. private _limitVelocityGradientsTexture;
  58356. private _dragGradientsTexture;
  58357. private _addFactorGradient;
  58358. /**
  58359. * Adds a new size gradient
  58360. * @param gradient defines the gradient to use (between 0 and 1)
  58361. * @param factor defines the size factor to affect to the specified gradient
  58362. * @returns the current particle system
  58363. */
  58364. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58365. /**
  58366. * Remove a specific size gradient
  58367. * @param gradient defines the gradient to remove
  58368. * @returns the current particle system
  58369. */
  58370. removeSizeGradient(gradient: number): GPUParticleSystem;
  58371. /**
  58372. * Adds a new angular speed gradient
  58373. * @param gradient defines the gradient to use (between 0 and 1)
  58374. * @param factor defines the angular speed to affect to the specified gradient
  58375. * @returns the current particle system
  58376. */
  58377. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58378. /**
  58379. * Remove a specific angular speed gradient
  58380. * @param gradient defines the gradient to remove
  58381. * @returns the current particle system
  58382. */
  58383. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58384. /**
  58385. * Adds a new velocity gradient
  58386. * @param gradient defines the gradient to use (between 0 and 1)
  58387. * @param factor defines the velocity to affect to the specified gradient
  58388. * @returns the current particle system
  58389. */
  58390. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58391. /**
  58392. * Remove a specific velocity gradient
  58393. * @param gradient defines the gradient to remove
  58394. * @returns the current particle system
  58395. */
  58396. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58397. /**
  58398. * Adds a new limit velocity gradient
  58399. * @param gradient defines the gradient to use (between 0 and 1)
  58400. * @param factor defines the limit velocity value to affect to the specified gradient
  58401. * @returns the current particle system
  58402. */
  58403. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58404. /**
  58405. * Remove a specific limit velocity gradient
  58406. * @param gradient defines the gradient to remove
  58407. * @returns the current particle system
  58408. */
  58409. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58410. /**
  58411. * Adds a new drag gradient
  58412. * @param gradient defines the gradient to use (between 0 and 1)
  58413. * @param factor defines the drag value to affect to the specified gradient
  58414. * @returns the current particle system
  58415. */
  58416. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58417. /**
  58418. * Remove a specific drag gradient
  58419. * @param gradient defines the gradient to remove
  58420. * @returns the current particle system
  58421. */
  58422. removeDragGradient(gradient: number): GPUParticleSystem;
  58423. /**
  58424. * Not supported by GPUParticleSystem
  58425. * @param gradient defines the gradient to use (between 0 and 1)
  58426. * @param factor defines the emit rate value to affect to the specified gradient
  58427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58428. * @returns the current particle system
  58429. */
  58430. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58431. /**
  58432. * Not supported by GPUParticleSystem
  58433. * @param gradient defines the gradient to remove
  58434. * @returns the current particle system
  58435. */
  58436. removeEmitRateGradient(gradient: number): IParticleSystem;
  58437. /**
  58438. * Not supported by GPUParticleSystem
  58439. * @param gradient defines the gradient to use (between 0 and 1)
  58440. * @param factor defines the start size value to affect to the specified gradient
  58441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58442. * @returns the current particle system
  58443. */
  58444. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58445. /**
  58446. * Not supported by GPUParticleSystem
  58447. * @param gradient defines the gradient to remove
  58448. * @returns the current particle system
  58449. */
  58450. removeStartSizeGradient(gradient: number): IParticleSystem;
  58451. /**
  58452. * Not supported by GPUParticleSystem
  58453. * @param gradient defines the gradient to use (between 0 and 1)
  58454. * @param min defines the color remap minimal range
  58455. * @param max defines the color remap maximal range
  58456. * @returns the current particle system
  58457. */
  58458. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58459. /**
  58460. * Not supported by GPUParticleSystem
  58461. * @param gradient defines the gradient to remove
  58462. * @returns the current particle system
  58463. */
  58464. removeColorRemapGradient(): IParticleSystem;
  58465. /**
  58466. * Not supported by GPUParticleSystem
  58467. * @param gradient defines the gradient to use (between 0 and 1)
  58468. * @param min defines the alpha remap minimal range
  58469. * @param max defines the alpha remap maximal range
  58470. * @returns the current particle system
  58471. */
  58472. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58473. /**
  58474. * Not supported by GPUParticleSystem
  58475. * @param gradient defines the gradient to remove
  58476. * @returns the current particle system
  58477. */
  58478. removeAlphaRemapGradient(): IParticleSystem;
  58479. /**
  58480. * Not supported by GPUParticleSystem
  58481. * @param gradient defines the gradient to use (between 0 and 1)
  58482. * @param color defines the color to affect to the specified gradient
  58483. * @returns the current particle system
  58484. */
  58485. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58486. /**
  58487. * Not supported by GPUParticleSystem
  58488. * @param gradient defines the gradient to remove
  58489. * @returns the current particle system
  58490. */
  58491. removeRampGradient(): IParticleSystem;
  58492. /**
  58493. * Not supported by GPUParticleSystem
  58494. * @returns the list of ramp gradients
  58495. */
  58496. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58497. /**
  58498. * Not supported by GPUParticleSystem
  58499. * Gets or sets a boolean indicating that ramp gradients must be used
  58500. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58501. */
  58502. useRampGradients: boolean;
  58503. /**
  58504. * Not supported by GPUParticleSystem
  58505. * @param gradient defines the gradient to use (between 0 and 1)
  58506. * @param factor defines the life time factor to affect to the specified gradient
  58507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58508. * @returns the current particle system
  58509. */
  58510. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58511. /**
  58512. * Not supported by GPUParticleSystem
  58513. * @param gradient defines the gradient to remove
  58514. * @returns the current particle system
  58515. */
  58516. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58517. /**
  58518. * Instantiates a GPU particle system.
  58519. * 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.
  58520. * @param name The name of the particle system
  58521. * @param options The options used to create the system
  58522. * @param scene The scene the particle system belongs to
  58523. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58524. */
  58525. constructor(name: string, options: Partial<{
  58526. capacity: number;
  58527. randomTextureSize: number;
  58528. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58529. protected _reset(): void;
  58530. private _createUpdateVAO;
  58531. private _createRenderVAO;
  58532. private _initialize;
  58533. /** @hidden */
  58534. _recreateUpdateEffect(): void;
  58535. /** @hidden */
  58536. _recreateRenderEffect(): void;
  58537. /**
  58538. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58539. * @param preWarm defines if we are in the pre-warmimg phase
  58540. */
  58541. animate(preWarm?: boolean): void;
  58542. private _createFactorGradientTexture;
  58543. private _createSizeGradientTexture;
  58544. private _createAngularSpeedGradientTexture;
  58545. private _createVelocityGradientTexture;
  58546. private _createLimitVelocityGradientTexture;
  58547. private _createDragGradientTexture;
  58548. private _createColorGradientTexture;
  58549. /**
  58550. * Renders the particle system in its current state
  58551. * @param preWarm defines if the system should only update the particles but not render them
  58552. * @returns the current number of particles
  58553. */
  58554. render(preWarm?: boolean): number;
  58555. /**
  58556. * Rebuilds the particle system
  58557. */
  58558. rebuild(): void;
  58559. private _releaseBuffers;
  58560. private _releaseVAOs;
  58561. /**
  58562. * Disposes the particle system and free the associated resources
  58563. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58564. */
  58565. dispose(disposeTexture?: boolean): void;
  58566. /**
  58567. * Clones the particle system.
  58568. * @param name The name of the cloned object
  58569. * @param newEmitter The new emitter to use
  58570. * @returns the cloned particle system
  58571. */
  58572. clone(name: string, newEmitter: any): GPUParticleSystem;
  58573. /**
  58574. * Serializes the particle system to a JSON object.
  58575. * @returns the JSON object
  58576. */
  58577. serialize(): any;
  58578. /**
  58579. * Parses a JSON object to create a GPU particle system.
  58580. * @param parsedParticleSystem The JSON object to parse
  58581. * @param scene The scene to create the particle system in
  58582. * @param rootUrl The root url to use to load external dependencies like texture
  58583. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58584. * @returns the parsed GPU particle system
  58585. */
  58586. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58587. }
  58588. }
  58589. declare module "babylonjs/Particles/particleSystemSet" {
  58590. import { Nullable } from "babylonjs/types";
  58591. import { Color3 } from "babylonjs/Maths/math.color";
  58592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58595. import { Scene, IDisposable } from "babylonjs/scene";
  58596. /**
  58597. * Represents a set of particle systems working together to create a specific effect
  58598. */
  58599. export class ParticleSystemSet implements IDisposable {
  58600. private _emitterCreationOptions;
  58601. private _emitterNode;
  58602. /**
  58603. * Gets the particle system list
  58604. */
  58605. systems: IParticleSystem[];
  58606. /**
  58607. * Gets the emitter node used with this set
  58608. */
  58609. readonly emitterNode: Nullable<TransformNode>;
  58610. /**
  58611. * Creates a new emitter mesh as a sphere
  58612. * @param options defines the options used to create the sphere
  58613. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58614. * @param scene defines the hosting scene
  58615. */
  58616. setEmitterAsSphere(options: {
  58617. diameter: number;
  58618. segments: number;
  58619. color: Color3;
  58620. }, renderingGroupId: number, scene: Scene): void;
  58621. /**
  58622. * Starts all particle systems of the set
  58623. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58624. */
  58625. start(emitter?: AbstractMesh): void;
  58626. /**
  58627. * Release all associated resources
  58628. */
  58629. dispose(): void;
  58630. /**
  58631. * Serialize the set into a JSON compatible object
  58632. * @returns a JSON compatible representation of the set
  58633. */
  58634. serialize(): any;
  58635. /**
  58636. * Parse a new ParticleSystemSet from a serialized source
  58637. * @param data defines a JSON compatible representation of the set
  58638. * @param scene defines the hosting scene
  58639. * @param gpu defines if we want GPU particles or CPU particles
  58640. * @returns a new ParticleSystemSet
  58641. */
  58642. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58643. }
  58644. }
  58645. declare module "babylonjs/Particles/particleHelper" {
  58646. import { Nullable } from "babylonjs/types";
  58647. import { Scene } from "babylonjs/scene";
  58648. import { Vector3 } from "babylonjs/Maths/math.vector";
  58649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58650. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58651. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58652. /**
  58653. * This class is made for on one-liner static method to help creating particle system set.
  58654. */
  58655. export class ParticleHelper {
  58656. /**
  58657. * Gets or sets base Assets URL
  58658. */
  58659. static BaseAssetsUrl: string;
  58660. /**
  58661. * Create a default particle system that you can tweak
  58662. * @param emitter defines the emitter to use
  58663. * @param capacity defines the system capacity (default is 500 particles)
  58664. * @param scene defines the hosting scene
  58665. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58666. * @returns the new Particle system
  58667. */
  58668. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58669. /**
  58670. * This is the main static method (one-liner) of this helper to create different particle systems
  58671. * @param type This string represents the type to the particle system to create
  58672. * @param scene The scene where the particle system should live
  58673. * @param gpu If the system will use gpu
  58674. * @returns the ParticleSystemSet created
  58675. */
  58676. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58677. /**
  58678. * Static function used to export a particle system to a ParticleSystemSet variable.
  58679. * Please note that the emitter shape is not exported
  58680. * @param systems defines the particle systems to export
  58681. * @returns the created particle system set
  58682. */
  58683. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58684. }
  58685. }
  58686. declare module "babylonjs/Particles/particleSystemComponent" {
  58687. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58688. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58689. import "babylonjs/Shaders/particles.vertex";
  58690. module "babylonjs/Engines/engine" {
  58691. interface Engine {
  58692. /**
  58693. * Create an effect to use with particle systems.
  58694. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58695. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58696. * @param uniformsNames defines a list of attribute names
  58697. * @param samplers defines an array of string used to represent textures
  58698. * @param defines defines the string containing the defines to use to compile the shaders
  58699. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58700. * @param onCompiled defines a function to call when the effect creation is successful
  58701. * @param onError defines a function to call when the effect creation has failed
  58702. * @returns the new Effect
  58703. */
  58704. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58705. }
  58706. }
  58707. module "babylonjs/Meshes/mesh" {
  58708. interface Mesh {
  58709. /**
  58710. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58711. * @returns an array of IParticleSystem
  58712. */
  58713. getEmittedParticleSystems(): IParticleSystem[];
  58714. /**
  58715. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58716. * @returns an array of IParticleSystem
  58717. */
  58718. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58719. }
  58720. }
  58721. /**
  58722. * @hidden
  58723. */
  58724. export var _IDoNeedToBeInTheBuild: number;
  58725. }
  58726. declare module "babylonjs/Particles/index" {
  58727. export * from "babylonjs/Particles/baseParticleSystem";
  58728. export * from "babylonjs/Particles/EmitterTypes/index";
  58729. export * from "babylonjs/Particles/gpuParticleSystem";
  58730. export * from "babylonjs/Particles/IParticleSystem";
  58731. export * from "babylonjs/Particles/particle";
  58732. export * from "babylonjs/Particles/particleHelper";
  58733. export * from "babylonjs/Particles/particleSystem";
  58734. export * from "babylonjs/Particles/particleSystemComponent";
  58735. export * from "babylonjs/Particles/particleSystemSet";
  58736. export * from "babylonjs/Particles/solidParticle";
  58737. export * from "babylonjs/Particles/solidParticleSystem";
  58738. export * from "babylonjs/Particles/subEmitter";
  58739. }
  58740. declare module "babylonjs/Physics/physicsEngineComponent" {
  58741. import { Nullable } from "babylonjs/types";
  58742. import { Observable, Observer } from "babylonjs/Misc/observable";
  58743. import { Vector3 } from "babylonjs/Maths/math.vector";
  58744. import { Mesh } from "babylonjs/Meshes/mesh";
  58745. import { ISceneComponent } from "babylonjs/sceneComponent";
  58746. import { Scene } from "babylonjs/scene";
  58747. import { Node } from "babylonjs/node";
  58748. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58749. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58750. module "babylonjs/scene" {
  58751. interface Scene {
  58752. /** @hidden (Backing field) */
  58753. _physicsEngine: Nullable<IPhysicsEngine>;
  58754. /**
  58755. * Gets the current physics engine
  58756. * @returns a IPhysicsEngine or null if none attached
  58757. */
  58758. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58759. /**
  58760. * Enables physics to the current scene
  58761. * @param gravity defines the scene's gravity for the physics engine
  58762. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58763. * @return a boolean indicating if the physics engine was initialized
  58764. */
  58765. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58766. /**
  58767. * Disables and disposes the physics engine associated with the scene
  58768. */
  58769. disablePhysicsEngine(): void;
  58770. /**
  58771. * Gets a boolean indicating if there is an active physics engine
  58772. * @returns a boolean indicating if there is an active physics engine
  58773. */
  58774. isPhysicsEnabled(): boolean;
  58775. /**
  58776. * Deletes a physics compound impostor
  58777. * @param compound defines the compound to delete
  58778. */
  58779. deleteCompoundImpostor(compound: any): void;
  58780. /**
  58781. * An event triggered when physic simulation is about to be run
  58782. */
  58783. onBeforePhysicsObservable: Observable<Scene>;
  58784. /**
  58785. * An event triggered when physic simulation has been done
  58786. */
  58787. onAfterPhysicsObservable: Observable<Scene>;
  58788. }
  58789. }
  58790. module "babylonjs/Meshes/abstractMesh" {
  58791. interface AbstractMesh {
  58792. /** @hidden */
  58793. _physicsImpostor: Nullable<PhysicsImpostor>;
  58794. /**
  58795. * Gets or sets impostor used for physic simulation
  58796. * @see http://doc.babylonjs.com/features/physics_engine
  58797. */
  58798. physicsImpostor: Nullable<PhysicsImpostor>;
  58799. /**
  58800. * Gets the current physics impostor
  58801. * @see http://doc.babylonjs.com/features/physics_engine
  58802. * @returns a physics impostor or null
  58803. */
  58804. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58805. /** Apply a physic impulse to the mesh
  58806. * @param force defines the force to apply
  58807. * @param contactPoint defines where to apply the force
  58808. * @returns the current mesh
  58809. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58810. */
  58811. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58812. /**
  58813. * Creates a physic joint between two meshes
  58814. * @param otherMesh defines the other mesh to use
  58815. * @param pivot1 defines the pivot to use on this mesh
  58816. * @param pivot2 defines the pivot to use on the other mesh
  58817. * @param options defines additional options (can be plugin dependent)
  58818. * @returns the current mesh
  58819. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58820. */
  58821. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58822. /** @hidden */
  58823. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58824. }
  58825. }
  58826. /**
  58827. * Defines the physics engine scene component responsible to manage a physics engine
  58828. */
  58829. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58830. /**
  58831. * The component name helpful to identify the component in the list of scene components.
  58832. */
  58833. readonly name: string;
  58834. /**
  58835. * The scene the component belongs to.
  58836. */
  58837. scene: Scene;
  58838. /**
  58839. * Creates a new instance of the component for the given scene
  58840. * @param scene Defines the scene to register the component in
  58841. */
  58842. constructor(scene: Scene);
  58843. /**
  58844. * Registers the component in a given scene
  58845. */
  58846. register(): void;
  58847. /**
  58848. * Rebuilds the elements related to this component in case of
  58849. * context lost for instance.
  58850. */
  58851. rebuild(): void;
  58852. /**
  58853. * Disposes the component and the associated ressources
  58854. */
  58855. dispose(): void;
  58856. }
  58857. }
  58858. declare module "babylonjs/Physics/physicsHelper" {
  58859. import { Nullable } from "babylonjs/types";
  58860. import { Vector3 } from "babylonjs/Maths/math.vector";
  58861. import { Mesh } from "babylonjs/Meshes/mesh";
  58862. import { Scene } from "babylonjs/scene";
  58863. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58864. /**
  58865. * A helper for physics simulations
  58866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58867. */
  58868. export class PhysicsHelper {
  58869. private _scene;
  58870. private _physicsEngine;
  58871. /**
  58872. * Initializes the Physics helper
  58873. * @param scene Babylon.js scene
  58874. */
  58875. constructor(scene: Scene);
  58876. /**
  58877. * Applies a radial explosion impulse
  58878. * @param origin the origin of the explosion
  58879. * @param radiusOrEventOptions the radius or the options of radial explosion
  58880. * @param strength the explosion strength
  58881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58882. * @returns A physics radial explosion event, or null
  58883. */
  58884. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58885. /**
  58886. * Applies a radial explosion force
  58887. * @param origin the origin of the explosion
  58888. * @param radiusOrEventOptions the radius or the options of radial explosion
  58889. * @param strength the explosion strength
  58890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58891. * @returns A physics radial explosion event, or null
  58892. */
  58893. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58894. /**
  58895. * Creates a gravitational field
  58896. * @param origin the origin of the explosion
  58897. * @param radiusOrEventOptions the radius or the options of radial explosion
  58898. * @param strength the explosion strength
  58899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58900. * @returns A physics gravitational field event, or null
  58901. */
  58902. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58903. /**
  58904. * Creates a physics updraft event
  58905. * @param origin the origin of the updraft
  58906. * @param radiusOrEventOptions the radius or the options of the updraft
  58907. * @param strength the strength of the updraft
  58908. * @param height the height of the updraft
  58909. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58910. * @returns A physics updraft event, or null
  58911. */
  58912. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58913. /**
  58914. * Creates a physics vortex event
  58915. * @param origin the of the vortex
  58916. * @param radiusOrEventOptions the radius or the options of the vortex
  58917. * @param strength the strength of the vortex
  58918. * @param height the height of the vortex
  58919. * @returns a Physics vortex event, or null
  58920. * A physics vortex event or null
  58921. */
  58922. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58923. }
  58924. /**
  58925. * Represents a physics radial explosion event
  58926. */
  58927. class PhysicsRadialExplosionEvent {
  58928. private _scene;
  58929. private _options;
  58930. private _sphere;
  58931. private _dataFetched;
  58932. /**
  58933. * Initializes a radial explosioin event
  58934. * @param _scene BabylonJS scene
  58935. * @param _options The options for the vortex event
  58936. */
  58937. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58938. /**
  58939. * Returns the data related to the radial explosion event (sphere).
  58940. * @returns The radial explosion event data
  58941. */
  58942. getData(): PhysicsRadialExplosionEventData;
  58943. /**
  58944. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58945. * @param impostor A physics imposter
  58946. * @param origin the origin of the explosion
  58947. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58948. */
  58949. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58950. /**
  58951. * Triggers affecterd impostors callbacks
  58952. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58953. */
  58954. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58955. /**
  58956. * Disposes the sphere.
  58957. * @param force Specifies if the sphere should be disposed by force
  58958. */
  58959. dispose(force?: boolean): void;
  58960. /*** Helpers ***/
  58961. private _prepareSphere;
  58962. private _intersectsWithSphere;
  58963. }
  58964. /**
  58965. * Represents a gravitational field event
  58966. */
  58967. class PhysicsGravitationalFieldEvent {
  58968. private _physicsHelper;
  58969. private _scene;
  58970. private _origin;
  58971. private _options;
  58972. private _tickCallback;
  58973. private _sphere;
  58974. private _dataFetched;
  58975. /**
  58976. * Initializes the physics gravitational field event
  58977. * @param _physicsHelper A physics helper
  58978. * @param _scene BabylonJS scene
  58979. * @param _origin The origin position of the gravitational field event
  58980. * @param _options The options for the vortex event
  58981. */
  58982. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58983. /**
  58984. * Returns the data related to the gravitational field event (sphere).
  58985. * @returns A gravitational field event
  58986. */
  58987. getData(): PhysicsGravitationalFieldEventData;
  58988. /**
  58989. * Enables the gravitational field.
  58990. */
  58991. enable(): void;
  58992. /**
  58993. * Disables the gravitational field.
  58994. */
  58995. disable(): void;
  58996. /**
  58997. * Disposes the sphere.
  58998. * @param force The force to dispose from the gravitational field event
  58999. */
  59000. dispose(force?: boolean): void;
  59001. private _tick;
  59002. }
  59003. /**
  59004. * Represents a physics updraft event
  59005. */
  59006. class PhysicsUpdraftEvent {
  59007. private _scene;
  59008. private _origin;
  59009. private _options;
  59010. private _physicsEngine;
  59011. private _originTop;
  59012. private _originDirection;
  59013. private _tickCallback;
  59014. private _cylinder;
  59015. private _cylinderPosition;
  59016. private _dataFetched;
  59017. /**
  59018. * Initializes the physics updraft event
  59019. * @param _scene BabylonJS scene
  59020. * @param _origin The origin position of the updraft
  59021. * @param _options The options for the updraft event
  59022. */
  59023. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59024. /**
  59025. * Returns the data related to the updraft event (cylinder).
  59026. * @returns A physics updraft event
  59027. */
  59028. getData(): PhysicsUpdraftEventData;
  59029. /**
  59030. * Enables the updraft.
  59031. */
  59032. enable(): void;
  59033. /**
  59034. * Disables the updraft.
  59035. */
  59036. disable(): void;
  59037. /**
  59038. * Disposes the cylinder.
  59039. * @param force Specifies if the updraft should be disposed by force
  59040. */
  59041. dispose(force?: boolean): void;
  59042. private getImpostorHitData;
  59043. private _tick;
  59044. /*** Helpers ***/
  59045. private _prepareCylinder;
  59046. private _intersectsWithCylinder;
  59047. }
  59048. /**
  59049. * Represents a physics vortex event
  59050. */
  59051. class PhysicsVortexEvent {
  59052. private _scene;
  59053. private _origin;
  59054. private _options;
  59055. private _physicsEngine;
  59056. private _originTop;
  59057. private _tickCallback;
  59058. private _cylinder;
  59059. private _cylinderPosition;
  59060. private _dataFetched;
  59061. /**
  59062. * Initializes the physics vortex event
  59063. * @param _scene The BabylonJS scene
  59064. * @param _origin The origin position of the vortex
  59065. * @param _options The options for the vortex event
  59066. */
  59067. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59068. /**
  59069. * Returns the data related to the vortex event (cylinder).
  59070. * @returns The physics vortex event data
  59071. */
  59072. getData(): PhysicsVortexEventData;
  59073. /**
  59074. * Enables the vortex.
  59075. */
  59076. enable(): void;
  59077. /**
  59078. * Disables the cortex.
  59079. */
  59080. disable(): void;
  59081. /**
  59082. * Disposes the sphere.
  59083. * @param force
  59084. */
  59085. dispose(force?: boolean): void;
  59086. private getImpostorHitData;
  59087. private _tick;
  59088. /*** Helpers ***/
  59089. private _prepareCylinder;
  59090. private _intersectsWithCylinder;
  59091. }
  59092. /**
  59093. * Options fot the radial explosion event
  59094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59095. */
  59096. export class PhysicsRadialExplosionEventOptions {
  59097. /**
  59098. * The radius of the sphere for the radial explosion.
  59099. */
  59100. radius: number;
  59101. /**
  59102. * The strenth of the explosion.
  59103. */
  59104. strength: number;
  59105. /**
  59106. * The strenght of the force in correspondence to the distance of the affected object
  59107. */
  59108. falloff: PhysicsRadialImpulseFalloff;
  59109. /**
  59110. * Sphere options for the radial explosion.
  59111. */
  59112. sphere: {
  59113. segments: number;
  59114. diameter: number;
  59115. };
  59116. /**
  59117. * Sphere options for the radial explosion.
  59118. */
  59119. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59120. }
  59121. /**
  59122. * Options fot the updraft event
  59123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59124. */
  59125. export class PhysicsUpdraftEventOptions {
  59126. /**
  59127. * The radius of the cylinder for the vortex
  59128. */
  59129. radius: number;
  59130. /**
  59131. * The strenth of the updraft.
  59132. */
  59133. strength: number;
  59134. /**
  59135. * The height of the cylinder for the updraft.
  59136. */
  59137. height: number;
  59138. /**
  59139. * The mode for the the updraft.
  59140. */
  59141. updraftMode: PhysicsUpdraftMode;
  59142. }
  59143. /**
  59144. * Options fot the vortex event
  59145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59146. */
  59147. export class PhysicsVortexEventOptions {
  59148. /**
  59149. * The radius of the cylinder for the vortex
  59150. */
  59151. radius: number;
  59152. /**
  59153. * The strenth of the vortex.
  59154. */
  59155. strength: number;
  59156. /**
  59157. * The height of the cylinder for the vortex.
  59158. */
  59159. height: number;
  59160. /**
  59161. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59162. */
  59163. centripetalForceThreshold: number;
  59164. /**
  59165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59166. */
  59167. centripetalForceMultiplier: number;
  59168. /**
  59169. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59170. */
  59171. centrifugalForceMultiplier: number;
  59172. /**
  59173. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59174. */
  59175. updraftForceMultiplier: number;
  59176. }
  59177. /**
  59178. * The strenght of the force in correspondence to the distance of the affected object
  59179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59180. */
  59181. export enum PhysicsRadialImpulseFalloff {
  59182. /** Defines that impulse is constant in strength across it's whole radius */
  59183. Constant = 0,
  59184. /** Defines that impulse gets weaker if it's further from the origin */
  59185. Linear = 1
  59186. }
  59187. /**
  59188. * The strength of the force in correspondence to the distance of the affected object
  59189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59190. */
  59191. export enum PhysicsUpdraftMode {
  59192. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59193. Center = 0,
  59194. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59195. Perpendicular = 1
  59196. }
  59197. /**
  59198. * Interface for a physics hit data
  59199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59200. */
  59201. export interface PhysicsHitData {
  59202. /**
  59203. * The force applied at the contact point
  59204. */
  59205. force: Vector3;
  59206. /**
  59207. * The contact point
  59208. */
  59209. contactPoint: Vector3;
  59210. /**
  59211. * The distance from the origin to the contact point
  59212. */
  59213. distanceFromOrigin: number;
  59214. }
  59215. /**
  59216. * Interface for radial explosion event data
  59217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59218. */
  59219. export interface PhysicsRadialExplosionEventData {
  59220. /**
  59221. * A sphere used for the radial explosion event
  59222. */
  59223. sphere: Mesh;
  59224. }
  59225. /**
  59226. * Interface for gravitational field event data
  59227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59228. */
  59229. export interface PhysicsGravitationalFieldEventData {
  59230. /**
  59231. * A sphere mesh used for the gravitational field event
  59232. */
  59233. sphere: Mesh;
  59234. }
  59235. /**
  59236. * Interface for updraft event data
  59237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59238. */
  59239. export interface PhysicsUpdraftEventData {
  59240. /**
  59241. * A cylinder used for the updraft event
  59242. */
  59243. cylinder: Mesh;
  59244. }
  59245. /**
  59246. * Interface for vortex event data
  59247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59248. */
  59249. export interface PhysicsVortexEventData {
  59250. /**
  59251. * A cylinder used for the vortex event
  59252. */
  59253. cylinder: Mesh;
  59254. }
  59255. /**
  59256. * Interface for an affected physics impostor
  59257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59258. */
  59259. export interface PhysicsAffectedImpostorWithData {
  59260. /**
  59261. * The impostor affected by the effect
  59262. */
  59263. impostor: PhysicsImpostor;
  59264. /**
  59265. * The data about the hit/horce from the explosion
  59266. */
  59267. hitData: PhysicsHitData;
  59268. }
  59269. }
  59270. declare module "babylonjs/Physics/Plugins/index" {
  59271. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59272. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59273. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59274. }
  59275. declare module "babylonjs/Physics/index" {
  59276. export * from "babylonjs/Physics/IPhysicsEngine";
  59277. export * from "babylonjs/Physics/physicsEngine";
  59278. export * from "babylonjs/Physics/physicsEngineComponent";
  59279. export * from "babylonjs/Physics/physicsHelper";
  59280. export * from "babylonjs/Physics/physicsImpostor";
  59281. export * from "babylonjs/Physics/physicsJoint";
  59282. export * from "babylonjs/Physics/Plugins/index";
  59283. }
  59284. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59285. /** @hidden */
  59286. export var blackAndWhitePixelShader: {
  59287. name: string;
  59288. shader: string;
  59289. };
  59290. }
  59291. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59292. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59293. import { Camera } from "babylonjs/Cameras/camera";
  59294. import { Engine } from "babylonjs/Engines/engine";
  59295. import "babylonjs/Shaders/blackAndWhite.fragment";
  59296. /**
  59297. * Post process used to render in black and white
  59298. */
  59299. export class BlackAndWhitePostProcess extends PostProcess {
  59300. /**
  59301. * Linear about to convert he result to black and white (default: 1)
  59302. */
  59303. degree: number;
  59304. /**
  59305. * Creates a black and white post process
  59306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59307. * @param name The name of the effect.
  59308. * @param options The required width/height ratio to downsize to before computing the render pass.
  59309. * @param camera The camera to apply the render pass to.
  59310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59311. * @param engine The engine which the post process will be applied. (default: current engine)
  59312. * @param reusable If the post process can be reused on the same frame. (default: false)
  59313. */
  59314. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59315. }
  59316. }
  59317. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59318. import { Nullable } from "babylonjs/types";
  59319. import { Camera } from "babylonjs/Cameras/camera";
  59320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59321. import { Engine } from "babylonjs/Engines/engine";
  59322. /**
  59323. * This represents a set of one or more post processes in Babylon.
  59324. * A post process can be used to apply a shader to a texture after it is rendered.
  59325. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59326. */
  59327. export class PostProcessRenderEffect {
  59328. private _postProcesses;
  59329. private _getPostProcesses;
  59330. private _singleInstance;
  59331. private _cameras;
  59332. private _indicesForCamera;
  59333. /**
  59334. * Name of the effect
  59335. * @hidden
  59336. */
  59337. _name: string;
  59338. /**
  59339. * Instantiates a post process render effect.
  59340. * A post process can be used to apply a shader to a texture after it is rendered.
  59341. * @param engine The engine the effect is tied to
  59342. * @param name The name of the effect
  59343. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59344. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59345. */
  59346. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59347. /**
  59348. * Checks if all the post processes in the effect are supported.
  59349. */
  59350. readonly isSupported: boolean;
  59351. /**
  59352. * Updates the current state of the effect
  59353. * @hidden
  59354. */
  59355. _update(): void;
  59356. /**
  59357. * Attaches the effect on cameras
  59358. * @param cameras The camera to attach to.
  59359. * @hidden
  59360. */
  59361. _attachCameras(cameras: Camera): void;
  59362. /**
  59363. * Attaches the effect on cameras
  59364. * @param cameras The camera to attach to.
  59365. * @hidden
  59366. */
  59367. _attachCameras(cameras: Camera[]): void;
  59368. /**
  59369. * Detaches the effect on cameras
  59370. * @param cameras The camera to detatch from.
  59371. * @hidden
  59372. */
  59373. _detachCameras(cameras: Camera): void;
  59374. /**
  59375. * Detatches the effect on cameras
  59376. * @param cameras The camera to detatch from.
  59377. * @hidden
  59378. */
  59379. _detachCameras(cameras: Camera[]): void;
  59380. /**
  59381. * Enables the effect on given cameras
  59382. * @param cameras The camera to enable.
  59383. * @hidden
  59384. */
  59385. _enable(cameras: Camera): void;
  59386. /**
  59387. * Enables the effect on given cameras
  59388. * @param cameras The camera to enable.
  59389. * @hidden
  59390. */
  59391. _enable(cameras: Nullable<Camera[]>): void;
  59392. /**
  59393. * Disables the effect on the given cameras
  59394. * @param cameras The camera to disable.
  59395. * @hidden
  59396. */
  59397. _disable(cameras: Camera): void;
  59398. /**
  59399. * Disables the effect on the given cameras
  59400. * @param cameras The camera to disable.
  59401. * @hidden
  59402. */
  59403. _disable(cameras: Nullable<Camera[]>): void;
  59404. /**
  59405. * Gets a list of the post processes contained in the effect.
  59406. * @param camera The camera to get the post processes on.
  59407. * @returns The list of the post processes in the effect.
  59408. */
  59409. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59410. }
  59411. }
  59412. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59413. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59414. /** @hidden */
  59415. export var extractHighlightsPixelShader: {
  59416. name: string;
  59417. shader: string;
  59418. };
  59419. }
  59420. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59421. import { Nullable } from "babylonjs/types";
  59422. import { Camera } from "babylonjs/Cameras/camera";
  59423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59424. import { Engine } from "babylonjs/Engines/engine";
  59425. import "babylonjs/Shaders/extractHighlights.fragment";
  59426. /**
  59427. * 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.
  59428. */
  59429. export class ExtractHighlightsPostProcess extends PostProcess {
  59430. /**
  59431. * The luminance threshold, pixels below this value will be set to black.
  59432. */
  59433. threshold: number;
  59434. /** @hidden */
  59435. _exposure: number;
  59436. /**
  59437. * Post process which has the input texture to be used when performing highlight extraction
  59438. * @hidden
  59439. */
  59440. _inputPostProcess: Nullable<PostProcess>;
  59441. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59442. }
  59443. }
  59444. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59445. /** @hidden */
  59446. export var bloomMergePixelShader: {
  59447. name: string;
  59448. shader: string;
  59449. };
  59450. }
  59451. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59453. import { Nullable } from "babylonjs/types";
  59454. import { Engine } from "babylonjs/Engines/engine";
  59455. import { Camera } from "babylonjs/Cameras/camera";
  59456. import "babylonjs/Shaders/bloomMerge.fragment";
  59457. /**
  59458. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59459. */
  59460. export class BloomMergePostProcess extends PostProcess {
  59461. /** Weight of the bloom to be added to the original input. */
  59462. weight: number;
  59463. /**
  59464. * Creates a new instance of @see BloomMergePostProcess
  59465. * @param name The name of the effect.
  59466. * @param originalFromInput Post process which's input will be used for the merge.
  59467. * @param blurred Blurred highlights post process which's output will be used.
  59468. * @param weight Weight of the bloom to be added to the original input.
  59469. * @param options The required width/height ratio to downsize to before computing the render pass.
  59470. * @param camera The camera to apply the render pass to.
  59471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59472. * @param engine The engine which the post process will be applied. (default: current engine)
  59473. * @param reusable If the post process can be reused on the same frame. (default: false)
  59474. * @param textureType Type of textures used when performing the post process. (default: 0)
  59475. * @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)
  59476. */
  59477. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59478. /** Weight of the bloom to be added to the original input. */
  59479. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59480. }
  59481. }
  59482. declare module "babylonjs/PostProcesses/bloomEffect" {
  59483. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59484. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59485. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59486. import { Camera } from "babylonjs/Cameras/camera";
  59487. import { Scene } from "babylonjs/scene";
  59488. /**
  59489. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59490. */
  59491. export class BloomEffect extends PostProcessRenderEffect {
  59492. private bloomScale;
  59493. /**
  59494. * @hidden Internal
  59495. */
  59496. _effects: Array<PostProcess>;
  59497. /**
  59498. * @hidden Internal
  59499. */
  59500. _downscale: ExtractHighlightsPostProcess;
  59501. private _blurX;
  59502. private _blurY;
  59503. private _merge;
  59504. /**
  59505. * The luminance threshold to find bright areas of the image to bloom.
  59506. */
  59507. threshold: number;
  59508. /**
  59509. * The strength of the bloom.
  59510. */
  59511. weight: number;
  59512. /**
  59513. * Specifies the size of the bloom blur kernel, relative to the final output size
  59514. */
  59515. kernel: number;
  59516. /**
  59517. * Creates a new instance of @see BloomEffect
  59518. * @param scene The scene the effect belongs to.
  59519. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59520. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59521. * @param bloomWeight The the strength of bloom.
  59522. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59523. * @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)
  59524. */
  59525. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59526. /**
  59527. * Disposes each of the internal effects for a given camera.
  59528. * @param camera The camera to dispose the effect on.
  59529. */
  59530. disposeEffects(camera: Camera): void;
  59531. /**
  59532. * @hidden Internal
  59533. */
  59534. _updateEffects(): void;
  59535. /**
  59536. * Internal
  59537. * @returns if all the contained post processes are ready.
  59538. * @hidden
  59539. */
  59540. _isReady(): boolean;
  59541. }
  59542. }
  59543. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59544. /** @hidden */
  59545. export var chromaticAberrationPixelShader: {
  59546. name: string;
  59547. shader: string;
  59548. };
  59549. }
  59550. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59551. import { Vector2 } from "babylonjs/Maths/math.vector";
  59552. import { Nullable } from "babylonjs/types";
  59553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59554. import { Camera } from "babylonjs/Cameras/camera";
  59555. import { Engine } from "babylonjs/Engines/engine";
  59556. import "babylonjs/Shaders/chromaticAberration.fragment";
  59557. /**
  59558. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59559. */
  59560. export class ChromaticAberrationPostProcess extends PostProcess {
  59561. /**
  59562. * The amount of seperation of rgb channels (default: 30)
  59563. */
  59564. aberrationAmount: number;
  59565. /**
  59566. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59567. */
  59568. radialIntensity: number;
  59569. /**
  59570. * 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))
  59571. */
  59572. direction: Vector2;
  59573. /**
  59574. * 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))
  59575. */
  59576. centerPosition: Vector2;
  59577. /**
  59578. * Creates a new instance ChromaticAberrationPostProcess
  59579. * @param name The name of the effect.
  59580. * @param screenWidth The width of the screen to apply the effect on.
  59581. * @param screenHeight The height of the screen to apply the effect on.
  59582. * @param options The required width/height ratio to downsize to before computing the render pass.
  59583. * @param camera The camera to apply the render pass to.
  59584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59585. * @param engine The engine which the post process will be applied. (default: current engine)
  59586. * @param reusable If the post process can be reused on the same frame. (default: false)
  59587. * @param textureType Type of textures used when performing the post process. (default: 0)
  59588. * @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)
  59589. */
  59590. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59591. }
  59592. }
  59593. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59594. /** @hidden */
  59595. export var circleOfConfusionPixelShader: {
  59596. name: string;
  59597. shader: string;
  59598. };
  59599. }
  59600. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59601. import { Nullable } from "babylonjs/types";
  59602. import { Engine } from "babylonjs/Engines/engine";
  59603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59605. import { Camera } from "babylonjs/Cameras/camera";
  59606. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59607. /**
  59608. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59609. */
  59610. export class CircleOfConfusionPostProcess extends PostProcess {
  59611. /**
  59612. * 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.
  59613. */
  59614. lensSize: number;
  59615. /**
  59616. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59617. */
  59618. fStop: number;
  59619. /**
  59620. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59621. */
  59622. focusDistance: number;
  59623. /**
  59624. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59625. */
  59626. focalLength: number;
  59627. private _depthTexture;
  59628. /**
  59629. * Creates a new instance CircleOfConfusionPostProcess
  59630. * @param name The name of the effect.
  59631. * @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.
  59632. * @param options The required width/height ratio to downsize to before computing the render pass.
  59633. * @param camera The camera to apply the render pass to.
  59634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59635. * @param engine The engine which the post process will be applied. (default: current engine)
  59636. * @param reusable If the post process can be reused on the same frame. (default: false)
  59637. * @param textureType Type of textures used when performing the post process. (default: 0)
  59638. * @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)
  59639. */
  59640. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59641. /**
  59642. * 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.
  59643. */
  59644. depthTexture: RenderTargetTexture;
  59645. }
  59646. }
  59647. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59648. /** @hidden */
  59649. export var colorCorrectionPixelShader: {
  59650. name: string;
  59651. shader: string;
  59652. };
  59653. }
  59654. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59656. import { Engine } from "babylonjs/Engines/engine";
  59657. import { Camera } from "babylonjs/Cameras/camera";
  59658. import "babylonjs/Shaders/colorCorrection.fragment";
  59659. /**
  59660. *
  59661. * This post-process allows the modification of rendered colors by using
  59662. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59663. *
  59664. * The object needs to be provided an url to a texture containing the color
  59665. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59666. * Use an image editing software to tweak the LUT to match your needs.
  59667. *
  59668. * For an example of a color LUT, see here:
  59669. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59670. * For explanations on color grading, see here:
  59671. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59672. *
  59673. */
  59674. export class ColorCorrectionPostProcess extends PostProcess {
  59675. private _colorTableTexture;
  59676. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59677. }
  59678. }
  59679. declare module "babylonjs/Shaders/convolution.fragment" {
  59680. /** @hidden */
  59681. export var convolutionPixelShader: {
  59682. name: string;
  59683. shader: string;
  59684. };
  59685. }
  59686. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59688. import { Nullable } from "babylonjs/types";
  59689. import { Camera } from "babylonjs/Cameras/camera";
  59690. import { Engine } from "babylonjs/Engines/engine";
  59691. import "babylonjs/Shaders/convolution.fragment";
  59692. /**
  59693. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59694. * input texture to perform effects such as edge detection or sharpening
  59695. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59696. */
  59697. export class ConvolutionPostProcess extends PostProcess {
  59698. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59699. kernel: number[];
  59700. /**
  59701. * Creates a new instance ConvolutionPostProcess
  59702. * @param name The name of the effect.
  59703. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59704. * @param options The required width/height ratio to downsize to before computing the render pass.
  59705. * @param camera The camera to apply the render pass to.
  59706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59707. * @param engine The engine which the post process will be applied. (default: current engine)
  59708. * @param reusable If the post process can be reused on the same frame. (default: false)
  59709. * @param textureType Type of textures used when performing the post process. (default: 0)
  59710. */
  59711. constructor(name: string,
  59712. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59713. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59714. /**
  59715. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59716. */
  59717. static EdgeDetect0Kernel: number[];
  59718. /**
  59719. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59720. */
  59721. static EdgeDetect1Kernel: number[];
  59722. /**
  59723. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59724. */
  59725. static EdgeDetect2Kernel: number[];
  59726. /**
  59727. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59728. */
  59729. static SharpenKernel: number[];
  59730. /**
  59731. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59732. */
  59733. static EmbossKernel: number[];
  59734. /**
  59735. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59736. */
  59737. static GaussianKernel: number[];
  59738. }
  59739. }
  59740. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59741. import { Nullable } from "babylonjs/types";
  59742. import { Vector2 } from "babylonjs/Maths/math.vector";
  59743. import { Camera } from "babylonjs/Cameras/camera";
  59744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59745. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59746. import { Engine } from "babylonjs/Engines/engine";
  59747. import { Scene } from "babylonjs/scene";
  59748. /**
  59749. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59750. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59751. * based on samples that have a large difference in distance than the center pixel.
  59752. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59753. */
  59754. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59755. direction: Vector2;
  59756. /**
  59757. * Creates a new instance CircleOfConfusionPostProcess
  59758. * @param name The name of the effect.
  59759. * @param scene The scene the effect belongs to.
  59760. * @param direction The direction the blur should be applied.
  59761. * @param kernel The size of the kernel used to blur.
  59762. * @param options The required width/height ratio to downsize to before computing the render pass.
  59763. * @param camera The camera to apply the render pass to.
  59764. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59765. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59767. * @param engine The engine which the post process will be applied. (default: current engine)
  59768. * @param reusable If the post process can be reused on the same frame. (default: false)
  59769. * @param textureType Type of textures used when performing the post process. (default: 0)
  59770. * @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)
  59771. */
  59772. 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);
  59773. }
  59774. }
  59775. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59776. /** @hidden */
  59777. export var depthOfFieldMergePixelShader: {
  59778. name: string;
  59779. shader: string;
  59780. };
  59781. }
  59782. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59783. import { Nullable } from "babylonjs/types";
  59784. import { Camera } from "babylonjs/Cameras/camera";
  59785. import { Effect } from "babylonjs/Materials/effect";
  59786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59787. import { Engine } from "babylonjs/Engines/engine";
  59788. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59789. /**
  59790. * Options to be set when merging outputs from the default pipeline.
  59791. */
  59792. export class DepthOfFieldMergePostProcessOptions {
  59793. /**
  59794. * The original image to merge on top of
  59795. */
  59796. originalFromInput: PostProcess;
  59797. /**
  59798. * Parameters to perform the merge of the depth of field effect
  59799. */
  59800. depthOfField?: {
  59801. circleOfConfusion: PostProcess;
  59802. blurSteps: Array<PostProcess>;
  59803. };
  59804. /**
  59805. * Parameters to perform the merge of bloom effect
  59806. */
  59807. bloom?: {
  59808. blurred: PostProcess;
  59809. weight: number;
  59810. };
  59811. }
  59812. /**
  59813. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59814. */
  59815. export class DepthOfFieldMergePostProcess extends PostProcess {
  59816. private blurSteps;
  59817. /**
  59818. * Creates a new instance of DepthOfFieldMergePostProcess
  59819. * @param name The name of the effect.
  59820. * @param originalFromInput Post process which's input will be used for the merge.
  59821. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59822. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59823. * @param options The required width/height ratio to downsize to before computing the render pass.
  59824. * @param camera The camera to apply the render pass to.
  59825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59826. * @param engine The engine which the post process will be applied. (default: current engine)
  59827. * @param reusable If the post process can be reused on the same frame. (default: false)
  59828. * @param textureType Type of textures used when performing the post process. (default: 0)
  59829. * @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)
  59830. */
  59831. 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);
  59832. /**
  59833. * Updates the effect with the current post process compile time values and recompiles the shader.
  59834. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59835. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59836. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59837. * @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
  59838. * @param onCompiled Called when the shader has been compiled.
  59839. * @param onError Called if there is an error when compiling a shader.
  59840. */
  59841. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59842. }
  59843. }
  59844. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59845. import { Nullable } from "babylonjs/types";
  59846. import { Camera } from "babylonjs/Cameras/camera";
  59847. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59849. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59850. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59851. import { Scene } from "babylonjs/scene";
  59852. /**
  59853. * Specifies the level of max blur that should be applied when using the depth of field effect
  59854. */
  59855. export enum DepthOfFieldEffectBlurLevel {
  59856. /**
  59857. * Subtle blur
  59858. */
  59859. Low = 0,
  59860. /**
  59861. * Medium blur
  59862. */
  59863. Medium = 1,
  59864. /**
  59865. * Large blur
  59866. */
  59867. High = 2
  59868. }
  59869. /**
  59870. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59871. */
  59872. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59873. private _circleOfConfusion;
  59874. /**
  59875. * @hidden Internal, blurs from high to low
  59876. */
  59877. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59878. private _depthOfFieldBlurY;
  59879. private _dofMerge;
  59880. /**
  59881. * @hidden Internal post processes in depth of field effect
  59882. */
  59883. _effects: Array<PostProcess>;
  59884. /**
  59885. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59886. */
  59887. focalLength: number;
  59888. /**
  59889. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59890. */
  59891. fStop: number;
  59892. /**
  59893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59894. */
  59895. focusDistance: number;
  59896. /**
  59897. * 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.
  59898. */
  59899. lensSize: number;
  59900. /**
  59901. * Creates a new instance DepthOfFieldEffect
  59902. * @param scene The scene the effect belongs to.
  59903. * @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.
  59904. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59905. * @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)
  59906. */
  59907. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59908. /**
  59909. * Get the current class name of the current effet
  59910. * @returns "DepthOfFieldEffect"
  59911. */
  59912. getClassName(): string;
  59913. /**
  59914. * 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.
  59915. */
  59916. depthTexture: RenderTargetTexture;
  59917. /**
  59918. * Disposes each of the internal effects for a given camera.
  59919. * @param camera The camera to dispose the effect on.
  59920. */
  59921. disposeEffects(camera: Camera): void;
  59922. /**
  59923. * @hidden Internal
  59924. */
  59925. _updateEffects(): void;
  59926. /**
  59927. * Internal
  59928. * @returns if all the contained post processes are ready.
  59929. * @hidden
  59930. */
  59931. _isReady(): boolean;
  59932. }
  59933. }
  59934. declare module "babylonjs/Shaders/displayPass.fragment" {
  59935. /** @hidden */
  59936. export var displayPassPixelShader: {
  59937. name: string;
  59938. shader: string;
  59939. };
  59940. }
  59941. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59942. import { Nullable } from "babylonjs/types";
  59943. import { Camera } from "babylonjs/Cameras/camera";
  59944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59945. import { Engine } from "babylonjs/Engines/engine";
  59946. import "babylonjs/Shaders/displayPass.fragment";
  59947. /**
  59948. * DisplayPassPostProcess which produces an output the same as it's input
  59949. */
  59950. export class DisplayPassPostProcess extends PostProcess {
  59951. /**
  59952. * Creates the DisplayPassPostProcess
  59953. * @param name The name of the effect.
  59954. * @param options The required width/height ratio to downsize to before computing the render pass.
  59955. * @param camera The camera to apply the render pass to.
  59956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59957. * @param engine The engine which the post process will be applied. (default: current engine)
  59958. * @param reusable If the post process can be reused on the same frame. (default: false)
  59959. */
  59960. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59961. }
  59962. }
  59963. declare module "babylonjs/Shaders/filter.fragment" {
  59964. /** @hidden */
  59965. export var filterPixelShader: {
  59966. name: string;
  59967. shader: string;
  59968. };
  59969. }
  59970. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59971. import { Nullable } from "babylonjs/types";
  59972. import { Matrix } from "babylonjs/Maths/math.vector";
  59973. import { Camera } from "babylonjs/Cameras/camera";
  59974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59975. import { Engine } from "babylonjs/Engines/engine";
  59976. import "babylonjs/Shaders/filter.fragment";
  59977. /**
  59978. * Applies a kernel filter to the image
  59979. */
  59980. export class FilterPostProcess extends PostProcess {
  59981. /** The matrix to be applied to the image */
  59982. kernelMatrix: Matrix;
  59983. /**
  59984. *
  59985. * @param name The name of the effect.
  59986. * @param kernelMatrix The matrix to be applied to the image
  59987. * @param options The required width/height ratio to downsize to before computing the render pass.
  59988. * @param camera The camera to apply the render pass to.
  59989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59990. * @param engine The engine which the post process will be applied. (default: current engine)
  59991. * @param reusable If the post process can be reused on the same frame. (default: false)
  59992. */
  59993. constructor(name: string,
  59994. /** The matrix to be applied to the image */
  59995. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59996. }
  59997. }
  59998. declare module "babylonjs/Shaders/fxaa.fragment" {
  59999. /** @hidden */
  60000. export var fxaaPixelShader: {
  60001. name: string;
  60002. shader: string;
  60003. };
  60004. }
  60005. declare module "babylonjs/Shaders/fxaa.vertex" {
  60006. /** @hidden */
  60007. export var fxaaVertexShader: {
  60008. name: string;
  60009. shader: string;
  60010. };
  60011. }
  60012. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60013. import { Nullable } from "babylonjs/types";
  60014. import { Camera } from "babylonjs/Cameras/camera";
  60015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60016. import { Engine } from "babylonjs/Engines/engine";
  60017. import "babylonjs/Shaders/fxaa.fragment";
  60018. import "babylonjs/Shaders/fxaa.vertex";
  60019. /**
  60020. * Fxaa post process
  60021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60022. */
  60023. export class FxaaPostProcess extends PostProcess {
  60024. /** @hidden */
  60025. texelWidth: number;
  60026. /** @hidden */
  60027. texelHeight: number;
  60028. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60029. private _getDefines;
  60030. }
  60031. }
  60032. declare module "babylonjs/Shaders/grain.fragment" {
  60033. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60034. /** @hidden */
  60035. export var grainPixelShader: {
  60036. name: string;
  60037. shader: string;
  60038. };
  60039. }
  60040. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60041. import { Nullable } from "babylonjs/types";
  60042. import { Camera } from "babylonjs/Cameras/camera";
  60043. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60044. import { Engine } from "babylonjs/Engines/engine";
  60045. import "babylonjs/Shaders/grain.fragment";
  60046. /**
  60047. * The GrainPostProcess adds noise to the image at mid luminance levels
  60048. */
  60049. export class GrainPostProcess extends PostProcess {
  60050. /**
  60051. * The intensity of the grain added (default: 30)
  60052. */
  60053. intensity: number;
  60054. /**
  60055. * If the grain should be randomized on every frame
  60056. */
  60057. animated: boolean;
  60058. /**
  60059. * Creates a new instance of @see GrainPostProcess
  60060. * @param name The name of the effect.
  60061. * @param options The required width/height ratio to downsize to before computing the render pass.
  60062. * @param camera The camera to apply the render pass to.
  60063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60064. * @param engine The engine which the post process will be applied. (default: current engine)
  60065. * @param reusable If the post process can be reused on the same frame. (default: false)
  60066. * @param textureType Type of textures used when performing the post process. (default: 0)
  60067. * @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)
  60068. */
  60069. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60070. }
  60071. }
  60072. declare module "babylonjs/Shaders/highlights.fragment" {
  60073. /** @hidden */
  60074. export var highlightsPixelShader: {
  60075. name: string;
  60076. shader: string;
  60077. };
  60078. }
  60079. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60080. import { Nullable } from "babylonjs/types";
  60081. import { Camera } from "babylonjs/Cameras/camera";
  60082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60083. import { Engine } from "babylonjs/Engines/engine";
  60084. import "babylonjs/Shaders/highlights.fragment";
  60085. /**
  60086. * Extracts highlights from the image
  60087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60088. */
  60089. export class HighlightsPostProcess extends PostProcess {
  60090. /**
  60091. * Extracts highlights from the image
  60092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60093. * @param name The name of the effect.
  60094. * @param options The required width/height ratio to downsize to before computing the render pass.
  60095. * @param camera The camera to apply the render pass to.
  60096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60097. * @param engine The engine which the post process will be applied. (default: current engine)
  60098. * @param reusable If the post process can be reused on the same frame. (default: false)
  60099. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60100. */
  60101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60102. }
  60103. }
  60104. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60105. /** @hidden */
  60106. export var mrtFragmentDeclaration: {
  60107. name: string;
  60108. shader: string;
  60109. };
  60110. }
  60111. declare module "babylonjs/Shaders/geometry.fragment" {
  60112. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60113. /** @hidden */
  60114. export var geometryPixelShader: {
  60115. name: string;
  60116. shader: string;
  60117. };
  60118. }
  60119. declare module "babylonjs/Shaders/geometry.vertex" {
  60120. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60122. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60123. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60125. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60126. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60127. /** @hidden */
  60128. export var geometryVertexShader: {
  60129. name: string;
  60130. shader: string;
  60131. };
  60132. }
  60133. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60134. import { Matrix } from "babylonjs/Maths/math.vector";
  60135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60136. import { Mesh } from "babylonjs/Meshes/mesh";
  60137. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60138. import { Effect } from "babylonjs/Materials/effect";
  60139. import { Scene } from "babylonjs/scene";
  60140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60141. import "babylonjs/Shaders/geometry.fragment";
  60142. import "babylonjs/Shaders/geometry.vertex";
  60143. /** @hidden */
  60144. interface ISavedTransformationMatrix {
  60145. world: Matrix;
  60146. viewProjection: Matrix;
  60147. }
  60148. /**
  60149. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60150. */
  60151. export class GeometryBufferRenderer {
  60152. /**
  60153. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60154. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60155. */
  60156. static readonly POSITION_TEXTURE_TYPE: number;
  60157. /**
  60158. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60159. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60160. */
  60161. static readonly VELOCITY_TEXTURE_TYPE: number;
  60162. /**
  60163. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60164. * in order to compute objects velocities when enableVelocity is set to "true"
  60165. * @hidden
  60166. */
  60167. _previousTransformationMatrices: {
  60168. [index: number]: ISavedTransformationMatrix;
  60169. };
  60170. /**
  60171. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60172. * in order to compute objects velocities when enableVelocity is set to "true"
  60173. * @hidden
  60174. */
  60175. _previousBonesTransformationMatrices: {
  60176. [index: number]: Float32Array;
  60177. };
  60178. /**
  60179. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60180. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60181. */
  60182. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60183. private _scene;
  60184. private _multiRenderTarget;
  60185. private _ratio;
  60186. private _enablePosition;
  60187. private _enableVelocity;
  60188. private _positionIndex;
  60189. private _velocityIndex;
  60190. protected _effect: Effect;
  60191. protected _cachedDefines: string;
  60192. /**
  60193. * Set the render list (meshes to be rendered) used in the G buffer.
  60194. */
  60195. renderList: Mesh[];
  60196. /**
  60197. * Gets wether or not G buffer are supported by the running hardware.
  60198. * This requires draw buffer supports
  60199. */
  60200. readonly isSupported: boolean;
  60201. /**
  60202. * Returns the index of the given texture type in the G-Buffer textures array
  60203. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60204. * @returns the index of the given texture type in the G-Buffer textures array
  60205. */
  60206. getTextureIndex(textureType: number): number;
  60207. /**
  60208. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60209. */
  60210. /**
  60211. * Sets whether or not objects positions are enabled for the G buffer.
  60212. */
  60213. enablePosition: boolean;
  60214. /**
  60215. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60216. */
  60217. /**
  60218. * Sets wether or not objects velocities are enabled for the G buffer.
  60219. */
  60220. enableVelocity: boolean;
  60221. /**
  60222. * Gets the scene associated with the buffer.
  60223. */
  60224. readonly scene: Scene;
  60225. /**
  60226. * Gets the ratio used by the buffer during its creation.
  60227. * How big is the buffer related to the main canvas.
  60228. */
  60229. readonly ratio: number;
  60230. /** @hidden */
  60231. static _SceneComponentInitialization: (scene: Scene) => void;
  60232. /**
  60233. * Creates a new G Buffer for the scene
  60234. * @param scene The scene the buffer belongs to
  60235. * @param ratio How big is the buffer related to the main canvas.
  60236. */
  60237. constructor(scene: Scene, ratio?: number);
  60238. /**
  60239. * Checks wether everything is ready to render a submesh to the G buffer.
  60240. * @param subMesh the submesh to check readiness for
  60241. * @param useInstances is the mesh drawn using instance or not
  60242. * @returns true if ready otherwise false
  60243. */
  60244. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60245. /**
  60246. * Gets the current underlying G Buffer.
  60247. * @returns the buffer
  60248. */
  60249. getGBuffer(): MultiRenderTarget;
  60250. /**
  60251. * Gets the number of samples used to render the buffer (anti aliasing).
  60252. */
  60253. /**
  60254. * Sets the number of samples used to render the buffer (anti aliasing).
  60255. */
  60256. samples: number;
  60257. /**
  60258. * Disposes the renderer and frees up associated resources.
  60259. */
  60260. dispose(): void;
  60261. protected _createRenderTargets(): void;
  60262. private _copyBonesTransformationMatrices;
  60263. }
  60264. }
  60265. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60266. import { Nullable } from "babylonjs/types";
  60267. import { Scene } from "babylonjs/scene";
  60268. import { ISceneComponent } from "babylonjs/sceneComponent";
  60269. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60270. module "babylonjs/scene" {
  60271. interface Scene {
  60272. /** @hidden (Backing field) */
  60273. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60274. /**
  60275. * Gets or Sets the current geometry buffer associated to the scene.
  60276. */
  60277. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60278. /**
  60279. * Enables a GeometryBufferRender and associates it with the scene
  60280. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60281. * @returns the GeometryBufferRenderer
  60282. */
  60283. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60284. /**
  60285. * Disables the GeometryBufferRender associated with the scene
  60286. */
  60287. disableGeometryBufferRenderer(): void;
  60288. }
  60289. }
  60290. /**
  60291. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60292. * in several rendering techniques.
  60293. */
  60294. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60295. /**
  60296. * The component name helpful to identify the component in the list of scene components.
  60297. */
  60298. readonly name: string;
  60299. /**
  60300. * The scene the component belongs to.
  60301. */
  60302. scene: Scene;
  60303. /**
  60304. * Creates a new instance of the component for the given scene
  60305. * @param scene Defines the scene to register the component in
  60306. */
  60307. constructor(scene: Scene);
  60308. /**
  60309. * Registers the component in a given scene
  60310. */
  60311. register(): void;
  60312. /**
  60313. * Rebuilds the elements related to this component in case of
  60314. * context lost for instance.
  60315. */
  60316. rebuild(): void;
  60317. /**
  60318. * Disposes the component and the associated ressources
  60319. */
  60320. dispose(): void;
  60321. private _gatherRenderTargets;
  60322. }
  60323. }
  60324. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60325. /** @hidden */
  60326. export var motionBlurPixelShader: {
  60327. name: string;
  60328. shader: string;
  60329. };
  60330. }
  60331. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60332. import { Nullable } from "babylonjs/types";
  60333. import { Camera } from "babylonjs/Cameras/camera";
  60334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60335. import { Scene } from "babylonjs/scene";
  60336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60337. import "babylonjs/Animations/animatable";
  60338. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60339. import "babylonjs/Shaders/motionBlur.fragment";
  60340. import { Engine } from "babylonjs/Engines/engine";
  60341. /**
  60342. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60343. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60344. * As an example, all you have to do is to create the post-process:
  60345. * var mb = new BABYLON.MotionBlurPostProcess(
  60346. * 'mb', // The name of the effect.
  60347. * scene, // The scene containing the objects to blur according to their velocity.
  60348. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60349. * camera // The camera to apply the render pass to.
  60350. * );
  60351. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60352. */
  60353. export class MotionBlurPostProcess extends PostProcess {
  60354. /**
  60355. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60356. */
  60357. motionStrength: number;
  60358. /**
  60359. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60360. */
  60361. /**
  60362. * Sets the number of iterations to be used for motion blur quality
  60363. */
  60364. motionBlurSamples: number;
  60365. private _motionBlurSamples;
  60366. private _geometryBufferRenderer;
  60367. /**
  60368. * Creates a new instance MotionBlurPostProcess
  60369. * @param name The name of the effect.
  60370. * @param scene The scene containing the objects to blur according to their velocity.
  60371. * @param options The required width/height ratio to downsize to before computing the render pass.
  60372. * @param camera The camera to apply the render pass to.
  60373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60374. * @param engine The engine which the post process will be applied. (default: current engine)
  60375. * @param reusable If the post process can be reused on the same frame. (default: false)
  60376. * @param textureType Type of textures used when performing the post process. (default: 0)
  60377. * @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)
  60378. */
  60379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60380. /**
  60381. * Excludes the given skinned mesh from computing bones velocities.
  60382. * 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.
  60383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60384. */
  60385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60386. /**
  60387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60390. */
  60391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60392. /**
  60393. * Disposes the post process.
  60394. * @param camera The camera to dispose the post process on.
  60395. */
  60396. dispose(camera?: Camera): void;
  60397. }
  60398. }
  60399. declare module "babylonjs/Shaders/refraction.fragment" {
  60400. /** @hidden */
  60401. export var refractionPixelShader: {
  60402. name: string;
  60403. shader: string;
  60404. };
  60405. }
  60406. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60407. import { Color3 } from "babylonjs/Maths/math.color";
  60408. import { Camera } from "babylonjs/Cameras/camera";
  60409. import { Texture } from "babylonjs/Materials/Textures/texture";
  60410. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60411. import { Engine } from "babylonjs/Engines/engine";
  60412. import "babylonjs/Shaders/refraction.fragment";
  60413. /**
  60414. * Post process which applies a refractin texture
  60415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60416. */
  60417. export class RefractionPostProcess extends PostProcess {
  60418. /** the base color of the refraction (used to taint the rendering) */
  60419. color: Color3;
  60420. /** simulated refraction depth */
  60421. depth: number;
  60422. /** the coefficient of the base color (0 to remove base color tainting) */
  60423. colorLevel: number;
  60424. private _refTexture;
  60425. private _ownRefractionTexture;
  60426. /**
  60427. * Gets or sets the refraction texture
  60428. * Please note that you are responsible for disposing the texture if you set it manually
  60429. */
  60430. refractionTexture: Texture;
  60431. /**
  60432. * Initializes the RefractionPostProcess
  60433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60434. * @param name The name of the effect.
  60435. * @param refractionTextureUrl Url of the refraction texture to use
  60436. * @param color the base color of the refraction (used to taint the rendering)
  60437. * @param depth simulated refraction depth
  60438. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60439. * @param camera The camera to apply the render pass to.
  60440. * @param options The required width/height ratio to downsize to before computing the render pass.
  60441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60442. * @param engine The engine which the post process will be applied. (default: current engine)
  60443. * @param reusable If the post process can be reused on the same frame. (default: false)
  60444. */
  60445. constructor(name: string, refractionTextureUrl: string,
  60446. /** the base color of the refraction (used to taint the rendering) */
  60447. color: Color3,
  60448. /** simulated refraction depth */
  60449. depth: number,
  60450. /** the coefficient of the base color (0 to remove base color tainting) */
  60451. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60452. /**
  60453. * Disposes of the post process
  60454. * @param camera Camera to dispose post process on
  60455. */
  60456. dispose(camera: Camera): void;
  60457. }
  60458. }
  60459. declare module "babylonjs/Shaders/sharpen.fragment" {
  60460. /** @hidden */
  60461. export var sharpenPixelShader: {
  60462. name: string;
  60463. shader: string;
  60464. };
  60465. }
  60466. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60467. import { Nullable } from "babylonjs/types";
  60468. import { Camera } from "babylonjs/Cameras/camera";
  60469. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60470. import "babylonjs/Shaders/sharpen.fragment";
  60471. import { Engine } from "babylonjs/Engines/engine";
  60472. /**
  60473. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60474. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60475. */
  60476. export class SharpenPostProcess extends PostProcess {
  60477. /**
  60478. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60479. */
  60480. colorAmount: number;
  60481. /**
  60482. * How much sharpness should be applied (default: 0.3)
  60483. */
  60484. edgeAmount: number;
  60485. /**
  60486. * Creates a new instance ConvolutionPostProcess
  60487. * @param name The name of the effect.
  60488. * @param options The required width/height ratio to downsize to before computing the render pass.
  60489. * @param camera The camera to apply the render pass to.
  60490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60491. * @param engine The engine which the post process will be applied. (default: current engine)
  60492. * @param reusable If the post process can be reused on the same frame. (default: false)
  60493. * @param textureType Type of textures used when performing the post process. (default: 0)
  60494. * @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)
  60495. */
  60496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60497. }
  60498. }
  60499. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60500. import { Nullable } from "babylonjs/types";
  60501. import { Camera } from "babylonjs/Cameras/camera";
  60502. import { Engine } from "babylonjs/Engines/engine";
  60503. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60505. /**
  60506. * PostProcessRenderPipeline
  60507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60508. */
  60509. export class PostProcessRenderPipeline {
  60510. private engine;
  60511. private _renderEffects;
  60512. private _renderEffectsForIsolatedPass;
  60513. /**
  60514. * List of inspectable custom properties (used by the Inspector)
  60515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60516. */
  60517. inspectableCustomProperties: IInspectable[];
  60518. /**
  60519. * @hidden
  60520. */
  60521. protected _cameras: Camera[];
  60522. /** @hidden */
  60523. _name: string;
  60524. /**
  60525. * Gets pipeline name
  60526. */
  60527. readonly name: string;
  60528. /**
  60529. * Initializes a PostProcessRenderPipeline
  60530. * @param engine engine to add the pipeline to
  60531. * @param name name of the pipeline
  60532. */
  60533. constructor(engine: Engine, name: string);
  60534. /**
  60535. * Gets the class name
  60536. * @returns "PostProcessRenderPipeline"
  60537. */
  60538. getClassName(): string;
  60539. /**
  60540. * If all the render effects in the pipeline are supported
  60541. */
  60542. readonly isSupported: boolean;
  60543. /**
  60544. * Adds an effect to the pipeline
  60545. * @param renderEffect the effect to add
  60546. */
  60547. addEffect(renderEffect: PostProcessRenderEffect): void;
  60548. /** @hidden */
  60549. _rebuild(): void;
  60550. /** @hidden */
  60551. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60552. /** @hidden */
  60553. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60554. /** @hidden */
  60555. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60556. /** @hidden */
  60557. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60558. /** @hidden */
  60559. _attachCameras(cameras: Camera, unique: boolean): void;
  60560. /** @hidden */
  60561. _attachCameras(cameras: Camera[], unique: boolean): void;
  60562. /** @hidden */
  60563. _detachCameras(cameras: Camera): void;
  60564. /** @hidden */
  60565. _detachCameras(cameras: Nullable<Camera[]>): void;
  60566. /** @hidden */
  60567. _update(): void;
  60568. /** @hidden */
  60569. _reset(): void;
  60570. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60571. /**
  60572. * Disposes of the pipeline
  60573. */
  60574. dispose(): void;
  60575. }
  60576. }
  60577. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60578. import { Camera } from "babylonjs/Cameras/camera";
  60579. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60580. /**
  60581. * PostProcessRenderPipelineManager class
  60582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60583. */
  60584. export class PostProcessRenderPipelineManager {
  60585. private _renderPipelines;
  60586. /**
  60587. * Initializes a PostProcessRenderPipelineManager
  60588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60589. */
  60590. constructor();
  60591. /**
  60592. * Gets the list of supported render pipelines
  60593. */
  60594. readonly supportedPipelines: PostProcessRenderPipeline[];
  60595. /**
  60596. * Adds a pipeline to the manager
  60597. * @param renderPipeline The pipeline to add
  60598. */
  60599. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60600. /**
  60601. * Attaches a camera to the pipeline
  60602. * @param renderPipelineName The name of the pipeline to attach to
  60603. * @param cameras the camera to attach
  60604. * @param unique if the camera can be attached multiple times to the pipeline
  60605. */
  60606. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60607. /**
  60608. * Detaches a camera from the pipeline
  60609. * @param renderPipelineName The name of the pipeline to detach from
  60610. * @param cameras the camera to detach
  60611. */
  60612. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60613. /**
  60614. * Enables an effect by name on a pipeline
  60615. * @param renderPipelineName the name of the pipeline to enable the effect in
  60616. * @param renderEffectName the name of the effect to enable
  60617. * @param cameras the cameras that the effect should be enabled on
  60618. */
  60619. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60620. /**
  60621. * Disables an effect by name on a pipeline
  60622. * @param renderPipelineName the name of the pipeline to disable the effect in
  60623. * @param renderEffectName the name of the effect to disable
  60624. * @param cameras the cameras that the effect should be disabled on
  60625. */
  60626. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60627. /**
  60628. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60629. */
  60630. update(): void;
  60631. /** @hidden */
  60632. _rebuild(): void;
  60633. /**
  60634. * Disposes of the manager and pipelines
  60635. */
  60636. dispose(): void;
  60637. }
  60638. }
  60639. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60640. import { ISceneComponent } from "babylonjs/sceneComponent";
  60641. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60642. import { Scene } from "babylonjs/scene";
  60643. module "babylonjs/scene" {
  60644. interface Scene {
  60645. /** @hidden (Backing field) */
  60646. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60647. /**
  60648. * Gets the postprocess render pipeline manager
  60649. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60650. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60651. */
  60652. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60653. }
  60654. }
  60655. /**
  60656. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60657. */
  60658. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60659. /**
  60660. * The component name helpfull to identify the component in the list of scene components.
  60661. */
  60662. readonly name: string;
  60663. /**
  60664. * The scene the component belongs to.
  60665. */
  60666. scene: Scene;
  60667. /**
  60668. * Creates a new instance of the component for the given scene
  60669. * @param scene Defines the scene to register the component in
  60670. */
  60671. constructor(scene: Scene);
  60672. /**
  60673. * Registers the component in a given scene
  60674. */
  60675. register(): void;
  60676. /**
  60677. * Rebuilds the elements related to this component in case of
  60678. * context lost for instance.
  60679. */
  60680. rebuild(): void;
  60681. /**
  60682. * Disposes the component and the associated ressources
  60683. */
  60684. dispose(): void;
  60685. private _gatherRenderTargets;
  60686. }
  60687. }
  60688. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60689. import { Nullable } from "babylonjs/types";
  60690. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60691. import { Camera } from "babylonjs/Cameras/camera";
  60692. import { IDisposable } from "babylonjs/scene";
  60693. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60694. import { Scene } from "babylonjs/scene";
  60695. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60696. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60697. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60698. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60699. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60700. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60701. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60702. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60703. import { Animation } from "babylonjs/Animations/animation";
  60704. /**
  60705. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60706. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60707. */
  60708. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60709. private _scene;
  60710. private _camerasToBeAttached;
  60711. /**
  60712. * ID of the sharpen post process,
  60713. */
  60714. private readonly SharpenPostProcessId;
  60715. /**
  60716. * @ignore
  60717. * ID of the image processing post process;
  60718. */
  60719. readonly ImageProcessingPostProcessId: string;
  60720. /**
  60721. * @ignore
  60722. * ID of the Fast Approximate Anti-Aliasing post process;
  60723. */
  60724. readonly FxaaPostProcessId: string;
  60725. /**
  60726. * ID of the chromatic aberration post process,
  60727. */
  60728. private readonly ChromaticAberrationPostProcessId;
  60729. /**
  60730. * ID of the grain post process
  60731. */
  60732. private readonly GrainPostProcessId;
  60733. /**
  60734. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60735. */
  60736. sharpen: SharpenPostProcess;
  60737. private _sharpenEffect;
  60738. private bloom;
  60739. /**
  60740. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60741. */
  60742. depthOfField: DepthOfFieldEffect;
  60743. /**
  60744. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60745. */
  60746. fxaa: FxaaPostProcess;
  60747. /**
  60748. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60749. */
  60750. imageProcessing: ImageProcessingPostProcess;
  60751. /**
  60752. * Chromatic aberration post process which will shift rgb colors in the image
  60753. */
  60754. chromaticAberration: ChromaticAberrationPostProcess;
  60755. private _chromaticAberrationEffect;
  60756. /**
  60757. * Grain post process which add noise to the image
  60758. */
  60759. grain: GrainPostProcess;
  60760. private _grainEffect;
  60761. /**
  60762. * Glow post process which adds a glow to emissive areas of the image
  60763. */
  60764. private _glowLayer;
  60765. /**
  60766. * Animations which can be used to tweak settings over a period of time
  60767. */
  60768. animations: Animation[];
  60769. private _imageProcessingConfigurationObserver;
  60770. private _sharpenEnabled;
  60771. private _bloomEnabled;
  60772. private _depthOfFieldEnabled;
  60773. private _depthOfFieldBlurLevel;
  60774. private _fxaaEnabled;
  60775. private _imageProcessingEnabled;
  60776. private _defaultPipelineTextureType;
  60777. private _bloomScale;
  60778. private _chromaticAberrationEnabled;
  60779. private _grainEnabled;
  60780. private _buildAllowed;
  60781. /**
  60782. * Gets active scene
  60783. */
  60784. readonly scene: Scene;
  60785. /**
  60786. * Enable or disable the sharpen process from the pipeline
  60787. */
  60788. sharpenEnabled: boolean;
  60789. private _resizeObserver;
  60790. private _hardwareScaleLevel;
  60791. private _bloomKernel;
  60792. /**
  60793. * Specifies the size of the bloom blur kernel, relative to the final output size
  60794. */
  60795. bloomKernel: number;
  60796. /**
  60797. * Specifies the weight of the bloom in the final rendering
  60798. */
  60799. private _bloomWeight;
  60800. /**
  60801. * Specifies the luma threshold for the area that will be blurred by the bloom
  60802. */
  60803. private _bloomThreshold;
  60804. private _hdr;
  60805. /**
  60806. * The strength of the bloom.
  60807. */
  60808. bloomWeight: number;
  60809. /**
  60810. * The strength of the bloom.
  60811. */
  60812. bloomThreshold: number;
  60813. /**
  60814. * The scale of the bloom, lower value will provide better performance.
  60815. */
  60816. bloomScale: number;
  60817. /**
  60818. * Enable or disable the bloom from the pipeline
  60819. */
  60820. bloomEnabled: boolean;
  60821. private _rebuildBloom;
  60822. /**
  60823. * If the depth of field is enabled.
  60824. */
  60825. depthOfFieldEnabled: boolean;
  60826. /**
  60827. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60828. */
  60829. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60830. /**
  60831. * If the anti aliasing is enabled.
  60832. */
  60833. fxaaEnabled: boolean;
  60834. private _samples;
  60835. /**
  60836. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60837. */
  60838. samples: number;
  60839. /**
  60840. * If image processing is enabled.
  60841. */
  60842. imageProcessingEnabled: boolean;
  60843. /**
  60844. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60845. */
  60846. glowLayerEnabled: boolean;
  60847. /**
  60848. * Gets the glow layer (or null if not defined)
  60849. */
  60850. readonly glowLayer: Nullable<GlowLayer>;
  60851. /**
  60852. * Enable or disable the chromaticAberration process from the pipeline
  60853. */
  60854. chromaticAberrationEnabled: boolean;
  60855. /**
  60856. * Enable or disable the grain process from the pipeline
  60857. */
  60858. grainEnabled: boolean;
  60859. /**
  60860. * @constructor
  60861. * @param name - The rendering pipeline name (default: "")
  60862. * @param hdr - If high dynamic range textures should be used (default: true)
  60863. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60864. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60865. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60866. */
  60867. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60868. /**
  60869. * Get the class name
  60870. * @returns "DefaultRenderingPipeline"
  60871. */
  60872. getClassName(): string;
  60873. /**
  60874. * Force the compilation of the entire pipeline.
  60875. */
  60876. prepare(): void;
  60877. private _hasCleared;
  60878. private _prevPostProcess;
  60879. private _prevPrevPostProcess;
  60880. private _setAutoClearAndTextureSharing;
  60881. private _depthOfFieldSceneObserver;
  60882. private _buildPipeline;
  60883. private _disposePostProcesses;
  60884. /**
  60885. * Adds a camera to the pipeline
  60886. * @param camera the camera to be added
  60887. */
  60888. addCamera(camera: Camera): void;
  60889. /**
  60890. * Removes a camera from the pipeline
  60891. * @param camera the camera to remove
  60892. */
  60893. removeCamera(camera: Camera): void;
  60894. /**
  60895. * Dispose of the pipeline and stop all post processes
  60896. */
  60897. dispose(): void;
  60898. /**
  60899. * Serialize the rendering pipeline (Used when exporting)
  60900. * @returns the serialized object
  60901. */
  60902. serialize(): any;
  60903. /**
  60904. * Parse the serialized pipeline
  60905. * @param source Source pipeline.
  60906. * @param scene The scene to load the pipeline to.
  60907. * @param rootUrl The URL of the serialized pipeline.
  60908. * @returns An instantiated pipeline from the serialized object.
  60909. */
  60910. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60911. }
  60912. }
  60913. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60914. /** @hidden */
  60915. export var lensHighlightsPixelShader: {
  60916. name: string;
  60917. shader: string;
  60918. };
  60919. }
  60920. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60921. /** @hidden */
  60922. export var depthOfFieldPixelShader: {
  60923. name: string;
  60924. shader: string;
  60925. };
  60926. }
  60927. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60928. import { Camera } from "babylonjs/Cameras/camera";
  60929. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60930. import { Scene } from "babylonjs/scene";
  60931. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60932. import "babylonjs/Shaders/chromaticAberration.fragment";
  60933. import "babylonjs/Shaders/lensHighlights.fragment";
  60934. import "babylonjs/Shaders/depthOfField.fragment";
  60935. /**
  60936. * BABYLON.JS Chromatic Aberration GLSL Shader
  60937. * Author: Olivier Guyot
  60938. * Separates very slightly R, G and B colors on the edges of the screen
  60939. * Inspired by Francois Tarlier & Martins Upitis
  60940. */
  60941. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60942. /**
  60943. * @ignore
  60944. * The chromatic aberration PostProcess id in the pipeline
  60945. */
  60946. LensChromaticAberrationEffect: string;
  60947. /**
  60948. * @ignore
  60949. * The highlights enhancing PostProcess id in the pipeline
  60950. */
  60951. HighlightsEnhancingEffect: string;
  60952. /**
  60953. * @ignore
  60954. * The depth-of-field PostProcess id in the pipeline
  60955. */
  60956. LensDepthOfFieldEffect: string;
  60957. private _scene;
  60958. private _depthTexture;
  60959. private _grainTexture;
  60960. private _chromaticAberrationPostProcess;
  60961. private _highlightsPostProcess;
  60962. private _depthOfFieldPostProcess;
  60963. private _edgeBlur;
  60964. private _grainAmount;
  60965. private _chromaticAberration;
  60966. private _distortion;
  60967. private _highlightsGain;
  60968. private _highlightsThreshold;
  60969. private _dofDistance;
  60970. private _dofAperture;
  60971. private _dofDarken;
  60972. private _dofPentagon;
  60973. private _blurNoise;
  60974. /**
  60975. * @constructor
  60976. *
  60977. * Effect parameters are as follow:
  60978. * {
  60979. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60980. * edge_blur: number; // from 0 to x (1 for realism)
  60981. * distortion: number; // from 0 to x (1 for realism)
  60982. * grain_amount: number; // from 0 to 1
  60983. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60984. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60985. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60986. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60987. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60988. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60989. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60990. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60991. * }
  60992. * Note: if an effect parameter is unset, effect is disabled
  60993. *
  60994. * @param name The rendering pipeline name
  60995. * @param parameters - An object containing all parameters (see above)
  60996. * @param scene The scene linked to this pipeline
  60997. * @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)
  60998. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60999. */
  61000. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61001. /**
  61002. * Get the class name
  61003. * @returns "LensRenderingPipeline"
  61004. */
  61005. getClassName(): string;
  61006. /**
  61007. * Gets associated scene
  61008. */
  61009. readonly scene: Scene;
  61010. /**
  61011. * Gets or sets the edge blur
  61012. */
  61013. edgeBlur: number;
  61014. /**
  61015. * Gets or sets the grain amount
  61016. */
  61017. grainAmount: number;
  61018. /**
  61019. * Gets or sets the chromatic aberration amount
  61020. */
  61021. chromaticAberration: number;
  61022. /**
  61023. * Gets or sets the depth of field aperture
  61024. */
  61025. dofAperture: number;
  61026. /**
  61027. * Gets or sets the edge distortion
  61028. */
  61029. edgeDistortion: number;
  61030. /**
  61031. * Gets or sets the depth of field distortion
  61032. */
  61033. dofDistortion: number;
  61034. /**
  61035. * Gets or sets the darken out of focus amount
  61036. */
  61037. darkenOutOfFocus: number;
  61038. /**
  61039. * Gets or sets a boolean indicating if blur noise is enabled
  61040. */
  61041. blurNoise: boolean;
  61042. /**
  61043. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61044. */
  61045. pentagonBokeh: boolean;
  61046. /**
  61047. * Gets or sets the highlight grain amount
  61048. */
  61049. highlightsGain: number;
  61050. /**
  61051. * Gets or sets the highlight threshold
  61052. */
  61053. highlightsThreshold: number;
  61054. /**
  61055. * Sets the amount of blur at the edges
  61056. * @param amount blur amount
  61057. */
  61058. setEdgeBlur(amount: number): void;
  61059. /**
  61060. * Sets edge blur to 0
  61061. */
  61062. disableEdgeBlur(): void;
  61063. /**
  61064. * Sets the amout of grain
  61065. * @param amount Amount of grain
  61066. */
  61067. setGrainAmount(amount: number): void;
  61068. /**
  61069. * Set grain amount to 0
  61070. */
  61071. disableGrain(): void;
  61072. /**
  61073. * Sets the chromatic aberration amount
  61074. * @param amount amount of chromatic aberration
  61075. */
  61076. setChromaticAberration(amount: number): void;
  61077. /**
  61078. * Sets chromatic aberration amount to 0
  61079. */
  61080. disableChromaticAberration(): void;
  61081. /**
  61082. * Sets the EdgeDistortion amount
  61083. * @param amount amount of EdgeDistortion
  61084. */
  61085. setEdgeDistortion(amount: number): void;
  61086. /**
  61087. * Sets edge distortion to 0
  61088. */
  61089. disableEdgeDistortion(): void;
  61090. /**
  61091. * Sets the FocusDistance amount
  61092. * @param amount amount of FocusDistance
  61093. */
  61094. setFocusDistance(amount: number): void;
  61095. /**
  61096. * Disables depth of field
  61097. */
  61098. disableDepthOfField(): void;
  61099. /**
  61100. * Sets the Aperture amount
  61101. * @param amount amount of Aperture
  61102. */
  61103. setAperture(amount: number): void;
  61104. /**
  61105. * Sets the DarkenOutOfFocus amount
  61106. * @param amount amount of DarkenOutOfFocus
  61107. */
  61108. setDarkenOutOfFocus(amount: number): void;
  61109. private _pentagonBokehIsEnabled;
  61110. /**
  61111. * Creates a pentagon bokeh effect
  61112. */
  61113. enablePentagonBokeh(): void;
  61114. /**
  61115. * Disables the pentagon bokeh effect
  61116. */
  61117. disablePentagonBokeh(): void;
  61118. /**
  61119. * Enables noise blur
  61120. */
  61121. enableNoiseBlur(): void;
  61122. /**
  61123. * Disables noise blur
  61124. */
  61125. disableNoiseBlur(): void;
  61126. /**
  61127. * Sets the HighlightsGain amount
  61128. * @param amount amount of HighlightsGain
  61129. */
  61130. setHighlightsGain(amount: number): void;
  61131. /**
  61132. * Sets the HighlightsThreshold amount
  61133. * @param amount amount of HighlightsThreshold
  61134. */
  61135. setHighlightsThreshold(amount: number): void;
  61136. /**
  61137. * Disables highlights
  61138. */
  61139. disableHighlights(): void;
  61140. /**
  61141. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61142. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61143. */
  61144. dispose(disableDepthRender?: boolean): void;
  61145. private _createChromaticAberrationPostProcess;
  61146. private _createHighlightsPostProcess;
  61147. private _createDepthOfFieldPostProcess;
  61148. private _createGrainTexture;
  61149. }
  61150. }
  61151. declare module "babylonjs/Shaders/ssao2.fragment" {
  61152. /** @hidden */
  61153. export var ssao2PixelShader: {
  61154. name: string;
  61155. shader: string;
  61156. };
  61157. }
  61158. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61159. /** @hidden */
  61160. export var ssaoCombinePixelShader: {
  61161. name: string;
  61162. shader: string;
  61163. };
  61164. }
  61165. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61166. import { Camera } from "babylonjs/Cameras/camera";
  61167. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61168. import { Scene } from "babylonjs/scene";
  61169. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61170. import "babylonjs/Shaders/ssao2.fragment";
  61171. import "babylonjs/Shaders/ssaoCombine.fragment";
  61172. /**
  61173. * Render pipeline to produce ssao effect
  61174. */
  61175. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61176. /**
  61177. * @ignore
  61178. * The PassPostProcess id in the pipeline that contains the original scene color
  61179. */
  61180. SSAOOriginalSceneColorEffect: string;
  61181. /**
  61182. * @ignore
  61183. * The SSAO PostProcess id in the pipeline
  61184. */
  61185. SSAORenderEffect: string;
  61186. /**
  61187. * @ignore
  61188. * The horizontal blur PostProcess id in the pipeline
  61189. */
  61190. SSAOBlurHRenderEffect: string;
  61191. /**
  61192. * @ignore
  61193. * The vertical blur PostProcess id in the pipeline
  61194. */
  61195. SSAOBlurVRenderEffect: string;
  61196. /**
  61197. * @ignore
  61198. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61199. */
  61200. SSAOCombineRenderEffect: string;
  61201. /**
  61202. * The output strength of the SSAO post-process. Default value is 1.0.
  61203. */
  61204. totalStrength: number;
  61205. /**
  61206. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61207. */
  61208. maxZ: number;
  61209. /**
  61210. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61211. */
  61212. minZAspect: number;
  61213. private _samples;
  61214. /**
  61215. * Number of samples used for the SSAO calculations. Default value is 8
  61216. */
  61217. samples: number;
  61218. private _textureSamples;
  61219. /**
  61220. * Number of samples to use for antialiasing
  61221. */
  61222. textureSamples: number;
  61223. /**
  61224. * Ratio object used for SSAO ratio and blur ratio
  61225. */
  61226. private _ratio;
  61227. /**
  61228. * Dynamically generated sphere sampler.
  61229. */
  61230. private _sampleSphere;
  61231. /**
  61232. * Blur filter offsets
  61233. */
  61234. private _samplerOffsets;
  61235. private _expensiveBlur;
  61236. /**
  61237. * If bilateral blur should be used
  61238. */
  61239. expensiveBlur: boolean;
  61240. /**
  61241. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61242. */
  61243. radius: number;
  61244. /**
  61245. * The base color of the SSAO post-process
  61246. * The final result is "base + ssao" between [0, 1]
  61247. */
  61248. base: number;
  61249. /**
  61250. * Support test.
  61251. */
  61252. static readonly IsSupported: boolean;
  61253. private _scene;
  61254. private _depthTexture;
  61255. private _normalTexture;
  61256. private _randomTexture;
  61257. private _originalColorPostProcess;
  61258. private _ssaoPostProcess;
  61259. private _blurHPostProcess;
  61260. private _blurVPostProcess;
  61261. private _ssaoCombinePostProcess;
  61262. private _firstUpdate;
  61263. /**
  61264. * Gets active scene
  61265. */
  61266. readonly scene: Scene;
  61267. /**
  61268. * @constructor
  61269. * @param name The rendering pipeline name
  61270. * @param scene The scene linked to this pipeline
  61271. * @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 }
  61272. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61273. */
  61274. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61275. /**
  61276. * Get the class name
  61277. * @returns "SSAO2RenderingPipeline"
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61282. */
  61283. dispose(disableGeometryBufferRenderer?: boolean): void;
  61284. private _createBlurPostProcess;
  61285. /** @hidden */
  61286. _rebuild(): void;
  61287. private _bits;
  61288. private _radicalInverse_VdC;
  61289. private _hammersley;
  61290. private _hemisphereSample_uniform;
  61291. private _generateHemisphere;
  61292. private _createSSAOPostProcess;
  61293. private _createSSAOCombinePostProcess;
  61294. private _createRandomTexture;
  61295. /**
  61296. * Serialize the rendering pipeline (Used when exporting)
  61297. * @returns the serialized object
  61298. */
  61299. serialize(): any;
  61300. /**
  61301. * Parse the serialized pipeline
  61302. * @param source Source pipeline.
  61303. * @param scene The scene to load the pipeline to.
  61304. * @param rootUrl The URL of the serialized pipeline.
  61305. * @returns An instantiated pipeline from the serialized object.
  61306. */
  61307. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61308. }
  61309. }
  61310. declare module "babylonjs/Shaders/ssao.fragment" {
  61311. /** @hidden */
  61312. export var ssaoPixelShader: {
  61313. name: string;
  61314. shader: string;
  61315. };
  61316. }
  61317. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61318. import { Camera } from "babylonjs/Cameras/camera";
  61319. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61320. import { Scene } from "babylonjs/scene";
  61321. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61322. import "babylonjs/Shaders/ssao.fragment";
  61323. import "babylonjs/Shaders/ssaoCombine.fragment";
  61324. /**
  61325. * Render pipeline to produce ssao effect
  61326. */
  61327. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61328. /**
  61329. * @ignore
  61330. * The PassPostProcess id in the pipeline that contains the original scene color
  61331. */
  61332. SSAOOriginalSceneColorEffect: string;
  61333. /**
  61334. * @ignore
  61335. * The SSAO PostProcess id in the pipeline
  61336. */
  61337. SSAORenderEffect: string;
  61338. /**
  61339. * @ignore
  61340. * The horizontal blur PostProcess id in the pipeline
  61341. */
  61342. SSAOBlurHRenderEffect: string;
  61343. /**
  61344. * @ignore
  61345. * The vertical blur PostProcess id in the pipeline
  61346. */
  61347. SSAOBlurVRenderEffect: string;
  61348. /**
  61349. * @ignore
  61350. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61351. */
  61352. SSAOCombineRenderEffect: string;
  61353. /**
  61354. * The output strength of the SSAO post-process. Default value is 1.0.
  61355. */
  61356. totalStrength: number;
  61357. /**
  61358. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61359. */
  61360. radius: number;
  61361. /**
  61362. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61363. * Must not be equal to fallOff and superior to fallOff.
  61364. * Default value is 0.0075
  61365. */
  61366. area: number;
  61367. /**
  61368. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61369. * Must not be equal to area and inferior to area.
  61370. * Default value is 0.000001
  61371. */
  61372. fallOff: number;
  61373. /**
  61374. * The base color of the SSAO post-process
  61375. * The final result is "base + ssao" between [0, 1]
  61376. */
  61377. base: number;
  61378. private _scene;
  61379. private _depthTexture;
  61380. private _randomTexture;
  61381. private _originalColorPostProcess;
  61382. private _ssaoPostProcess;
  61383. private _blurHPostProcess;
  61384. private _blurVPostProcess;
  61385. private _ssaoCombinePostProcess;
  61386. private _firstUpdate;
  61387. /**
  61388. * Gets active scene
  61389. */
  61390. readonly scene: Scene;
  61391. /**
  61392. * @constructor
  61393. * @param name - The rendering pipeline name
  61394. * @param scene - The scene linked to this pipeline
  61395. * @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 }
  61396. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61397. */
  61398. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61399. /**
  61400. * Get the class name
  61401. * @returns "SSAORenderingPipeline"
  61402. */
  61403. getClassName(): string;
  61404. /**
  61405. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61406. */
  61407. dispose(disableDepthRender?: boolean): void;
  61408. private _createBlurPostProcess;
  61409. /** @hidden */
  61410. _rebuild(): void;
  61411. private _createSSAOPostProcess;
  61412. private _createSSAOCombinePostProcess;
  61413. private _createRandomTexture;
  61414. }
  61415. }
  61416. declare module "babylonjs/Shaders/standard.fragment" {
  61417. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61418. /** @hidden */
  61419. export var standardPixelShader: {
  61420. name: string;
  61421. shader: string;
  61422. };
  61423. }
  61424. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61425. import { Nullable } from "babylonjs/types";
  61426. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61427. import { Camera } from "babylonjs/Cameras/camera";
  61428. import { Texture } from "babylonjs/Materials/Textures/texture";
  61429. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61430. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61431. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61432. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61433. import { IDisposable } from "babylonjs/scene";
  61434. import { SpotLight } from "babylonjs/Lights/spotLight";
  61435. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61436. import { Scene } from "babylonjs/scene";
  61437. import { Animation } from "babylonjs/Animations/animation";
  61438. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61439. import "babylonjs/Shaders/standard.fragment";
  61440. /**
  61441. * Standard rendering pipeline
  61442. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61443. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61444. */
  61445. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61446. /**
  61447. * Public members
  61448. */
  61449. /**
  61450. * Post-process which contains the original scene color before the pipeline applies all the effects
  61451. */
  61452. originalPostProcess: Nullable<PostProcess>;
  61453. /**
  61454. * Post-process used to down scale an image x4
  61455. */
  61456. downSampleX4PostProcess: Nullable<PostProcess>;
  61457. /**
  61458. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61459. */
  61460. brightPassPostProcess: Nullable<PostProcess>;
  61461. /**
  61462. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61463. */
  61464. blurHPostProcesses: PostProcess[];
  61465. /**
  61466. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61467. */
  61468. blurVPostProcesses: PostProcess[];
  61469. /**
  61470. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61471. */
  61472. textureAdderPostProcess: Nullable<PostProcess>;
  61473. /**
  61474. * Post-process used to create volumetric lighting effect
  61475. */
  61476. volumetricLightPostProcess: Nullable<PostProcess>;
  61477. /**
  61478. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61479. */
  61480. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61481. /**
  61482. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61483. */
  61484. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61485. /**
  61486. * Post-process used to merge the volumetric light effect and the real scene color
  61487. */
  61488. volumetricLightMergePostProces: Nullable<PostProcess>;
  61489. /**
  61490. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61491. */
  61492. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61493. /**
  61494. * Base post-process used to calculate the average luminance of the final image for HDR
  61495. */
  61496. luminancePostProcess: Nullable<PostProcess>;
  61497. /**
  61498. * Post-processes used to create down sample post-processes in order to get
  61499. * the average luminance of the final image for HDR
  61500. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61501. */
  61502. luminanceDownSamplePostProcesses: PostProcess[];
  61503. /**
  61504. * Post-process used to create a HDR effect (light adaptation)
  61505. */
  61506. hdrPostProcess: Nullable<PostProcess>;
  61507. /**
  61508. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61509. */
  61510. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61511. /**
  61512. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61513. */
  61514. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61515. /**
  61516. * Post-process used to merge the final HDR post-process and the real scene color
  61517. */
  61518. hdrFinalPostProcess: Nullable<PostProcess>;
  61519. /**
  61520. * Post-process used to create a lens flare effect
  61521. */
  61522. lensFlarePostProcess: Nullable<PostProcess>;
  61523. /**
  61524. * Post-process that merges the result of the lens flare post-process and the real scene color
  61525. */
  61526. lensFlareComposePostProcess: Nullable<PostProcess>;
  61527. /**
  61528. * Post-process used to create a motion blur effect
  61529. */
  61530. motionBlurPostProcess: Nullable<PostProcess>;
  61531. /**
  61532. * Post-process used to create a depth of field effect
  61533. */
  61534. depthOfFieldPostProcess: Nullable<PostProcess>;
  61535. /**
  61536. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61537. */
  61538. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61539. /**
  61540. * Represents the brightness threshold in order to configure the illuminated surfaces
  61541. */
  61542. brightThreshold: number;
  61543. /**
  61544. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61545. */
  61546. blurWidth: number;
  61547. /**
  61548. * Sets if the blur for highlighted surfaces must be only horizontal
  61549. */
  61550. horizontalBlur: boolean;
  61551. /**
  61552. * Gets the overall exposure used by the pipeline
  61553. */
  61554. /**
  61555. * Sets the overall exposure used by the pipeline
  61556. */
  61557. exposure: number;
  61558. /**
  61559. * Texture used typically to simulate "dirty" on camera lens
  61560. */
  61561. lensTexture: Nullable<Texture>;
  61562. /**
  61563. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61564. */
  61565. volumetricLightCoefficient: number;
  61566. /**
  61567. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61568. */
  61569. volumetricLightPower: number;
  61570. /**
  61571. * Used the set the blur intensity to smooth the volumetric lights
  61572. */
  61573. volumetricLightBlurScale: number;
  61574. /**
  61575. * Light (spot or directional) used to generate the volumetric lights rays
  61576. * The source light must have a shadow generate so the pipeline can get its
  61577. * depth map
  61578. */
  61579. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61580. /**
  61581. * For eye adaptation, represents the minimum luminance the eye can see
  61582. */
  61583. hdrMinimumLuminance: number;
  61584. /**
  61585. * For eye adaptation, represents the decrease luminance speed
  61586. */
  61587. hdrDecreaseRate: number;
  61588. /**
  61589. * For eye adaptation, represents the increase luminance speed
  61590. */
  61591. hdrIncreaseRate: number;
  61592. /**
  61593. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61594. */
  61595. /**
  61596. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61597. */
  61598. hdrAutoExposure: boolean;
  61599. /**
  61600. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61601. */
  61602. lensColorTexture: Nullable<Texture>;
  61603. /**
  61604. * The overall strengh for the lens flare effect
  61605. */
  61606. lensFlareStrength: number;
  61607. /**
  61608. * Dispersion coefficient for lens flare ghosts
  61609. */
  61610. lensFlareGhostDispersal: number;
  61611. /**
  61612. * Main lens flare halo width
  61613. */
  61614. lensFlareHaloWidth: number;
  61615. /**
  61616. * Based on the lens distortion effect, defines how much the lens flare result
  61617. * is distorted
  61618. */
  61619. lensFlareDistortionStrength: number;
  61620. /**
  61621. * Lens star texture must be used to simulate rays on the flares and is available
  61622. * in the documentation
  61623. */
  61624. lensStarTexture: Nullable<Texture>;
  61625. /**
  61626. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61627. * flare effect by taking account of the dirt texture
  61628. */
  61629. lensFlareDirtTexture: Nullable<Texture>;
  61630. /**
  61631. * Represents the focal length for the depth of field effect
  61632. */
  61633. depthOfFieldDistance: number;
  61634. /**
  61635. * Represents the blur intensity for the blurred part of the depth of field effect
  61636. */
  61637. depthOfFieldBlurWidth: number;
  61638. /**
  61639. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61640. */
  61641. /**
  61642. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61643. */
  61644. motionStrength: number;
  61645. /**
  61646. * Gets wether or not the motion blur post-process is object based or screen based.
  61647. */
  61648. /**
  61649. * Sets wether or not the motion blur post-process should be object based or screen based
  61650. */
  61651. objectBasedMotionBlur: boolean;
  61652. /**
  61653. * List of animations for the pipeline (IAnimatable implementation)
  61654. */
  61655. animations: Animation[];
  61656. /**
  61657. * Private members
  61658. */
  61659. private _scene;
  61660. private _currentDepthOfFieldSource;
  61661. private _basePostProcess;
  61662. private _fixedExposure;
  61663. private _currentExposure;
  61664. private _hdrAutoExposure;
  61665. private _hdrCurrentLuminance;
  61666. private _motionStrength;
  61667. private _isObjectBasedMotionBlur;
  61668. private _floatTextureType;
  61669. private _ratio;
  61670. private _bloomEnabled;
  61671. private _depthOfFieldEnabled;
  61672. private _vlsEnabled;
  61673. private _lensFlareEnabled;
  61674. private _hdrEnabled;
  61675. private _motionBlurEnabled;
  61676. private _fxaaEnabled;
  61677. private _motionBlurSamples;
  61678. private _volumetricLightStepsCount;
  61679. private _samples;
  61680. /**
  61681. * @ignore
  61682. * Specifies if the bloom pipeline is enabled
  61683. */
  61684. BloomEnabled: boolean;
  61685. /**
  61686. * @ignore
  61687. * Specifies if the depth of field pipeline is enabed
  61688. */
  61689. DepthOfFieldEnabled: boolean;
  61690. /**
  61691. * @ignore
  61692. * Specifies if the lens flare pipeline is enabed
  61693. */
  61694. LensFlareEnabled: boolean;
  61695. /**
  61696. * @ignore
  61697. * Specifies if the HDR pipeline is enabled
  61698. */
  61699. HDREnabled: boolean;
  61700. /**
  61701. * @ignore
  61702. * Specifies if the volumetric lights scattering effect is enabled
  61703. */
  61704. VLSEnabled: boolean;
  61705. /**
  61706. * @ignore
  61707. * Specifies if the motion blur effect is enabled
  61708. */
  61709. MotionBlurEnabled: boolean;
  61710. /**
  61711. * Specifies if anti-aliasing is enabled
  61712. */
  61713. fxaaEnabled: boolean;
  61714. /**
  61715. * Specifies the number of steps used to calculate the volumetric lights
  61716. * Typically in interval [50, 200]
  61717. */
  61718. volumetricLightStepsCount: number;
  61719. /**
  61720. * Specifies the number of samples used for the motion blur effect
  61721. * Typically in interval [16, 64]
  61722. */
  61723. motionBlurSamples: number;
  61724. /**
  61725. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61726. */
  61727. samples: number;
  61728. /**
  61729. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61730. * @constructor
  61731. * @param name The rendering pipeline name
  61732. * @param scene The scene linked to this pipeline
  61733. * @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)
  61734. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61735. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61736. */
  61737. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61738. private _buildPipeline;
  61739. private _createDownSampleX4PostProcess;
  61740. private _createBrightPassPostProcess;
  61741. private _createBlurPostProcesses;
  61742. private _createTextureAdderPostProcess;
  61743. private _createVolumetricLightPostProcess;
  61744. private _createLuminancePostProcesses;
  61745. private _createHdrPostProcess;
  61746. private _createLensFlarePostProcess;
  61747. private _createDepthOfFieldPostProcess;
  61748. private _createMotionBlurPostProcess;
  61749. private _getDepthTexture;
  61750. private _disposePostProcesses;
  61751. /**
  61752. * Dispose of the pipeline and stop all post processes
  61753. */
  61754. dispose(): void;
  61755. /**
  61756. * Serialize the rendering pipeline (Used when exporting)
  61757. * @returns the serialized object
  61758. */
  61759. serialize(): any;
  61760. /**
  61761. * Parse the serialized pipeline
  61762. * @param source Source pipeline.
  61763. * @param scene The scene to load the pipeline to.
  61764. * @param rootUrl The URL of the serialized pipeline.
  61765. * @returns An instantiated pipeline from the serialized object.
  61766. */
  61767. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61768. /**
  61769. * Luminance steps
  61770. */
  61771. static LuminanceSteps: number;
  61772. }
  61773. }
  61774. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61775. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61776. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61777. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61778. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61779. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61780. }
  61781. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61782. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61783. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61784. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61785. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61786. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61787. }
  61788. declare module "babylonjs/Shaders/tonemap.fragment" {
  61789. /** @hidden */
  61790. export var tonemapPixelShader: {
  61791. name: string;
  61792. shader: string;
  61793. };
  61794. }
  61795. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61796. import { Camera } from "babylonjs/Cameras/camera";
  61797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61798. import "babylonjs/Shaders/tonemap.fragment";
  61799. import { Engine } from "babylonjs/Engines/engine";
  61800. /** Defines operator used for tonemapping */
  61801. export enum TonemappingOperator {
  61802. /** Hable */
  61803. Hable = 0,
  61804. /** Reinhard */
  61805. Reinhard = 1,
  61806. /** HejiDawson */
  61807. HejiDawson = 2,
  61808. /** Photographic */
  61809. Photographic = 3
  61810. }
  61811. /**
  61812. * Defines a post process to apply tone mapping
  61813. */
  61814. export class TonemapPostProcess extends PostProcess {
  61815. private _operator;
  61816. /** Defines the required exposure adjustement */
  61817. exposureAdjustment: number;
  61818. /**
  61819. * Creates a new TonemapPostProcess
  61820. * @param name defines the name of the postprocess
  61821. * @param _operator defines the operator to use
  61822. * @param exposureAdjustment defines the required exposure adjustement
  61823. * @param camera defines the camera to use (can be null)
  61824. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61825. * @param engine defines the hosting engine (can be ignore if camera is set)
  61826. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61827. */
  61828. constructor(name: string, _operator: TonemappingOperator,
  61829. /** Defines the required exposure adjustement */
  61830. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61831. }
  61832. }
  61833. declare module "babylonjs/Shaders/depth.vertex" {
  61834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61837. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61839. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61840. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61841. /** @hidden */
  61842. export var depthVertexShader: {
  61843. name: string;
  61844. shader: string;
  61845. };
  61846. }
  61847. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61848. /** @hidden */
  61849. export var volumetricLightScatteringPixelShader: {
  61850. name: string;
  61851. shader: string;
  61852. };
  61853. }
  61854. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  61855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61862. /** @hidden */
  61863. export var volumetricLightScatteringPassVertexShader: {
  61864. name: string;
  61865. shader: string;
  61866. };
  61867. }
  61868. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61869. /** @hidden */
  61870. export var volumetricLightScatteringPassPixelShader: {
  61871. name: string;
  61872. shader: string;
  61873. };
  61874. }
  61875. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61876. import { Vector3 } from "babylonjs/Maths/math.vector";
  61877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61878. import { Mesh } from "babylonjs/Meshes/mesh";
  61879. import { Camera } from "babylonjs/Cameras/camera";
  61880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61882. import { Scene } from "babylonjs/scene";
  61883. import "babylonjs/Meshes/Builders/planeBuilder";
  61884. import "babylonjs/Shaders/depth.vertex";
  61885. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61886. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  61887. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61888. import { Engine } from "babylonjs/Engines/engine";
  61889. /**
  61890. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61891. */
  61892. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61893. private _volumetricLightScatteringPass;
  61894. private _volumetricLightScatteringRTT;
  61895. private _viewPort;
  61896. private _screenCoordinates;
  61897. private _cachedDefines;
  61898. /**
  61899. * If not undefined, the mesh position is computed from the attached node position
  61900. */
  61901. attachedNode: {
  61902. position: Vector3;
  61903. };
  61904. /**
  61905. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61906. */
  61907. customMeshPosition: Vector3;
  61908. /**
  61909. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61910. */
  61911. useCustomMeshPosition: boolean;
  61912. /**
  61913. * If the post-process should inverse the light scattering direction
  61914. */
  61915. invert: boolean;
  61916. /**
  61917. * The internal mesh used by the post-process
  61918. */
  61919. mesh: Mesh;
  61920. /**
  61921. * @hidden
  61922. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61923. */
  61924. useDiffuseColor: boolean;
  61925. /**
  61926. * Array containing the excluded meshes not rendered in the internal pass
  61927. */
  61928. excludedMeshes: AbstractMesh[];
  61929. /**
  61930. * Controls the overall intensity of the post-process
  61931. */
  61932. exposure: number;
  61933. /**
  61934. * Dissipates each sample's contribution in range [0, 1]
  61935. */
  61936. decay: number;
  61937. /**
  61938. * Controls the overall intensity of each sample
  61939. */
  61940. weight: number;
  61941. /**
  61942. * Controls the density of each sample
  61943. */
  61944. density: number;
  61945. /**
  61946. * @constructor
  61947. * @param name The post-process name
  61948. * @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)
  61949. * @param camera The camera that the post-process will be attached to
  61950. * @param mesh The mesh used to create the light scattering
  61951. * @param samples The post-process quality, default 100
  61952. * @param samplingModeThe post-process filtering mode
  61953. * @param engine The babylon engine
  61954. * @param reusable If the post-process is reusable
  61955. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61956. */
  61957. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61958. /**
  61959. * Returns the string "VolumetricLightScatteringPostProcess"
  61960. * @returns "VolumetricLightScatteringPostProcess"
  61961. */
  61962. getClassName(): string;
  61963. private _isReady;
  61964. /**
  61965. * Sets the new light position for light scattering effect
  61966. * @param position The new custom light position
  61967. */
  61968. setCustomMeshPosition(position: Vector3): void;
  61969. /**
  61970. * Returns the light position for light scattering effect
  61971. * @return Vector3 The custom light position
  61972. */
  61973. getCustomMeshPosition(): Vector3;
  61974. /**
  61975. * Disposes the internal assets and detaches the post-process from the camera
  61976. */
  61977. dispose(camera: Camera): void;
  61978. /**
  61979. * Returns the render target texture used by the post-process
  61980. * @return the render target texture used by the post-process
  61981. */
  61982. getPass(): RenderTargetTexture;
  61983. private _meshExcluded;
  61984. private _createPass;
  61985. private _updateMeshScreenCoordinates;
  61986. /**
  61987. * Creates a default mesh for the Volumeric Light Scattering post-process
  61988. * @param name The mesh name
  61989. * @param scene The scene where to create the mesh
  61990. * @return the default mesh
  61991. */
  61992. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61993. }
  61994. }
  61995. declare module "babylonjs/PostProcesses/index" {
  61996. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61997. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61998. export * from "babylonjs/PostProcesses/bloomEffect";
  61999. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62000. export * from "babylonjs/PostProcesses/blurPostProcess";
  62001. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62002. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62003. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62004. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62005. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62006. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62007. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62008. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62009. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62010. export * from "babylonjs/PostProcesses/filterPostProcess";
  62011. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62012. export * from "babylonjs/PostProcesses/grainPostProcess";
  62013. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62014. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62015. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62016. export * from "babylonjs/PostProcesses/passPostProcess";
  62017. export * from "babylonjs/PostProcesses/postProcess";
  62018. export * from "babylonjs/PostProcesses/postProcessManager";
  62019. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62020. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62021. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62022. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62023. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62024. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62025. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62026. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62027. }
  62028. declare module "babylonjs/Probes/index" {
  62029. export * from "babylonjs/Probes/reflectionProbe";
  62030. }
  62031. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62032. import { Scene } from "babylonjs/scene";
  62033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62034. import { SmartArray } from "babylonjs/Misc/smartArray";
  62035. import { ISceneComponent } from "babylonjs/sceneComponent";
  62036. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62037. import "babylonjs/Meshes/Builders/boxBuilder";
  62038. import "babylonjs/Shaders/color.fragment";
  62039. import "babylonjs/Shaders/color.vertex";
  62040. import { Color3 } from "babylonjs/Maths/math.color";
  62041. module "babylonjs/scene" {
  62042. interface Scene {
  62043. /** @hidden (Backing field) */
  62044. _boundingBoxRenderer: BoundingBoxRenderer;
  62045. /** @hidden (Backing field) */
  62046. _forceShowBoundingBoxes: boolean;
  62047. /**
  62048. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62049. */
  62050. forceShowBoundingBoxes: boolean;
  62051. /**
  62052. * Gets the bounding box renderer associated with the scene
  62053. * @returns a BoundingBoxRenderer
  62054. */
  62055. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62056. }
  62057. }
  62058. module "babylonjs/Meshes/abstractMesh" {
  62059. interface AbstractMesh {
  62060. /** @hidden (Backing field) */
  62061. _showBoundingBox: boolean;
  62062. /**
  62063. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62064. */
  62065. showBoundingBox: boolean;
  62066. }
  62067. }
  62068. /**
  62069. * Component responsible of rendering the bounding box of the meshes in a scene.
  62070. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62071. */
  62072. export class BoundingBoxRenderer implements ISceneComponent {
  62073. /**
  62074. * The component name helpfull to identify the component in the list of scene components.
  62075. */
  62076. readonly name: string;
  62077. /**
  62078. * The scene the component belongs to.
  62079. */
  62080. scene: Scene;
  62081. /**
  62082. * Color of the bounding box lines placed in front of an object
  62083. */
  62084. frontColor: Color3;
  62085. /**
  62086. * Color of the bounding box lines placed behind an object
  62087. */
  62088. backColor: Color3;
  62089. /**
  62090. * Defines if the renderer should show the back lines or not
  62091. */
  62092. showBackLines: boolean;
  62093. /**
  62094. * @hidden
  62095. */
  62096. renderList: SmartArray<BoundingBox>;
  62097. private _colorShader;
  62098. private _vertexBuffers;
  62099. private _indexBuffer;
  62100. private _fillIndexBuffer;
  62101. private _fillIndexData;
  62102. /**
  62103. * Instantiates a new bounding box renderer in a scene.
  62104. * @param scene the scene the renderer renders in
  62105. */
  62106. constructor(scene: Scene);
  62107. /**
  62108. * Registers the component in a given scene
  62109. */
  62110. register(): void;
  62111. private _evaluateSubMesh;
  62112. private _activeMesh;
  62113. private _prepareRessources;
  62114. private _createIndexBuffer;
  62115. /**
  62116. * Rebuilds the elements related to this component in case of
  62117. * context lost for instance.
  62118. */
  62119. rebuild(): void;
  62120. /**
  62121. * @hidden
  62122. */
  62123. reset(): void;
  62124. /**
  62125. * Render the bounding boxes of a specific rendering group
  62126. * @param renderingGroupId defines the rendering group to render
  62127. */
  62128. render(renderingGroupId: number): void;
  62129. /**
  62130. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62131. * @param mesh Define the mesh to render the occlusion bounding box for
  62132. */
  62133. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62134. /**
  62135. * Dispose and release the resources attached to this renderer.
  62136. */
  62137. dispose(): void;
  62138. }
  62139. }
  62140. declare module "babylonjs/Shaders/depth.fragment" {
  62141. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62142. /** @hidden */
  62143. export var depthPixelShader: {
  62144. name: string;
  62145. shader: string;
  62146. };
  62147. }
  62148. declare module "babylonjs/Rendering/depthRenderer" {
  62149. import { Nullable } from "babylonjs/types";
  62150. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62151. import { Scene } from "babylonjs/scene";
  62152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62153. import { Camera } from "babylonjs/Cameras/camera";
  62154. import "babylonjs/Shaders/depth.fragment";
  62155. import "babylonjs/Shaders/depth.vertex";
  62156. /**
  62157. * This represents a depth renderer in Babylon.
  62158. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62159. */
  62160. export class DepthRenderer {
  62161. private _scene;
  62162. private _depthMap;
  62163. private _effect;
  62164. private readonly _storeNonLinearDepth;
  62165. private readonly _clearColor;
  62166. /** Get if the depth renderer is using packed depth or not */
  62167. readonly isPacked: boolean;
  62168. private _cachedDefines;
  62169. private _camera;
  62170. /**
  62171. * Specifiess that the depth renderer will only be used within
  62172. * the camera it is created for.
  62173. * This can help forcing its rendering during the camera processing.
  62174. */
  62175. useOnlyInActiveCamera: boolean;
  62176. /** @hidden */
  62177. static _SceneComponentInitialization: (scene: Scene) => void;
  62178. /**
  62179. * Instantiates a depth renderer
  62180. * @param scene The scene the renderer belongs to
  62181. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62182. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62183. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62184. */
  62185. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62186. /**
  62187. * Creates the depth rendering effect and checks if the effect is ready.
  62188. * @param subMesh The submesh to be used to render the depth map of
  62189. * @param useInstances If multiple world instances should be used
  62190. * @returns if the depth renderer is ready to render the depth map
  62191. */
  62192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62193. /**
  62194. * Gets the texture which the depth map will be written to.
  62195. * @returns The depth map texture
  62196. */
  62197. getDepthMap(): RenderTargetTexture;
  62198. /**
  62199. * Disposes of the depth renderer.
  62200. */
  62201. dispose(): void;
  62202. }
  62203. }
  62204. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62205. import { Nullable } from "babylonjs/types";
  62206. import { Scene } from "babylonjs/scene";
  62207. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62208. import { Camera } from "babylonjs/Cameras/camera";
  62209. import { ISceneComponent } from "babylonjs/sceneComponent";
  62210. module "babylonjs/scene" {
  62211. interface Scene {
  62212. /** @hidden (Backing field) */
  62213. _depthRenderer: {
  62214. [id: string]: DepthRenderer;
  62215. };
  62216. /**
  62217. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62218. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62219. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62220. * @returns the created depth renderer
  62221. */
  62222. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62223. /**
  62224. * Disables a depth renderer for a given camera
  62225. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62226. */
  62227. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62228. }
  62229. }
  62230. /**
  62231. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62232. * in several rendering techniques.
  62233. */
  62234. export class DepthRendererSceneComponent implements ISceneComponent {
  62235. /**
  62236. * The component name helpfull to identify the component in the list of scene components.
  62237. */
  62238. readonly name: string;
  62239. /**
  62240. * The scene the component belongs to.
  62241. */
  62242. scene: Scene;
  62243. /**
  62244. * Creates a new instance of the component for the given scene
  62245. * @param scene Defines the scene to register the component in
  62246. */
  62247. constructor(scene: Scene);
  62248. /**
  62249. * Registers the component in a given scene
  62250. */
  62251. register(): void;
  62252. /**
  62253. * Rebuilds the elements related to this component in case of
  62254. * context lost for instance.
  62255. */
  62256. rebuild(): void;
  62257. /**
  62258. * Disposes the component and the associated ressources
  62259. */
  62260. dispose(): void;
  62261. private _gatherRenderTargets;
  62262. private _gatherActiveCameraRenderTargets;
  62263. }
  62264. }
  62265. declare module "babylonjs/Shaders/outline.fragment" {
  62266. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62267. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62268. /** @hidden */
  62269. export var outlinePixelShader: {
  62270. name: string;
  62271. shader: string;
  62272. };
  62273. }
  62274. declare module "babylonjs/Shaders/outline.vertex" {
  62275. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62276. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62277. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62278. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62279. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62280. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62281. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62282. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62283. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62284. /** @hidden */
  62285. export var outlineVertexShader: {
  62286. name: string;
  62287. shader: string;
  62288. };
  62289. }
  62290. declare module "babylonjs/Rendering/outlineRenderer" {
  62291. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62292. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62293. import { Scene } from "babylonjs/scene";
  62294. import { ISceneComponent } from "babylonjs/sceneComponent";
  62295. import "babylonjs/Shaders/outline.fragment";
  62296. import "babylonjs/Shaders/outline.vertex";
  62297. module "babylonjs/scene" {
  62298. interface Scene {
  62299. /** @hidden */
  62300. _outlineRenderer: OutlineRenderer;
  62301. /**
  62302. * Gets the outline renderer associated with the scene
  62303. * @returns a OutlineRenderer
  62304. */
  62305. getOutlineRenderer(): OutlineRenderer;
  62306. }
  62307. }
  62308. module "babylonjs/Meshes/abstractMesh" {
  62309. interface AbstractMesh {
  62310. /** @hidden (Backing field) */
  62311. _renderOutline: boolean;
  62312. /**
  62313. * Gets or sets a boolean indicating if the outline must be rendered as well
  62314. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62315. */
  62316. renderOutline: boolean;
  62317. /** @hidden (Backing field) */
  62318. _renderOverlay: boolean;
  62319. /**
  62320. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62321. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62322. */
  62323. renderOverlay: boolean;
  62324. }
  62325. }
  62326. /**
  62327. * This class is responsible to draw bothe outline/overlay of meshes.
  62328. * It should not be used directly but through the available method on mesh.
  62329. */
  62330. export class OutlineRenderer implements ISceneComponent {
  62331. /**
  62332. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62333. */
  62334. private static _StencilReference;
  62335. /**
  62336. * The name of the component. Each component must have a unique name.
  62337. */
  62338. name: string;
  62339. /**
  62340. * The scene the component belongs to.
  62341. */
  62342. scene: Scene;
  62343. /**
  62344. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62345. */
  62346. zOffset: number;
  62347. private _engine;
  62348. private _effect;
  62349. private _cachedDefines;
  62350. private _savedDepthWrite;
  62351. /**
  62352. * Instantiates a new outline renderer. (There could be only one per scene).
  62353. * @param scene Defines the scene it belongs to
  62354. */
  62355. constructor(scene: Scene);
  62356. /**
  62357. * Register the component to one instance of a scene.
  62358. */
  62359. register(): void;
  62360. /**
  62361. * Rebuilds the elements related to this component in case of
  62362. * context lost for instance.
  62363. */
  62364. rebuild(): void;
  62365. /**
  62366. * Disposes the component and the associated ressources.
  62367. */
  62368. dispose(): void;
  62369. /**
  62370. * Renders the outline in the canvas.
  62371. * @param subMesh Defines the sumesh to render
  62372. * @param batch Defines the batch of meshes in case of instances
  62373. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62374. */
  62375. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62376. /**
  62377. * Returns whether or not the outline renderer is ready for a given submesh.
  62378. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62379. * @param subMesh Defines the submesh to check readyness for
  62380. * @param useInstances Defines wheter wee are trying to render instances or not
  62381. * @returns true if ready otherwise false
  62382. */
  62383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62384. private _beforeRenderingMesh;
  62385. private _afterRenderingMesh;
  62386. }
  62387. }
  62388. declare module "babylonjs/Rendering/index" {
  62389. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62390. export * from "babylonjs/Rendering/depthRenderer";
  62391. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62392. export * from "babylonjs/Rendering/edgesRenderer";
  62393. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62394. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62395. export * from "babylonjs/Rendering/outlineRenderer";
  62396. export * from "babylonjs/Rendering/renderingGroup";
  62397. export * from "babylonjs/Rendering/renderingManager";
  62398. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62399. }
  62400. declare module "babylonjs/Sprites/index" {
  62401. export * from "babylonjs/Sprites/sprite";
  62402. export * from "babylonjs/Sprites/spriteManager";
  62403. export * from "babylonjs/Sprites/spriteSceneComponent";
  62404. }
  62405. declare module "babylonjs/Misc/assetsManager" {
  62406. import { Scene } from "babylonjs/scene";
  62407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62408. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62409. import { Skeleton } from "babylonjs/Bones/skeleton";
  62410. import { Observable } from "babylonjs/Misc/observable";
  62411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62412. import { Texture } from "babylonjs/Materials/Textures/texture";
  62413. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62414. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62415. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62416. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62417. /**
  62418. * Defines the list of states available for a task inside a AssetsManager
  62419. */
  62420. export enum AssetTaskState {
  62421. /**
  62422. * Initialization
  62423. */
  62424. INIT = 0,
  62425. /**
  62426. * Running
  62427. */
  62428. RUNNING = 1,
  62429. /**
  62430. * Done
  62431. */
  62432. DONE = 2,
  62433. /**
  62434. * Error
  62435. */
  62436. ERROR = 3
  62437. }
  62438. /**
  62439. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62440. */
  62441. export abstract class AbstractAssetTask {
  62442. /**
  62443. * Task name
  62444. */ name: string;
  62445. /**
  62446. * Callback called when the task is successful
  62447. */
  62448. onSuccess: (task: any) => void;
  62449. /**
  62450. * Callback called when the task is not successful
  62451. */
  62452. onError: (task: any, message?: string, exception?: any) => void;
  62453. /**
  62454. * Creates a new AssetsManager
  62455. * @param name defines the name of the task
  62456. */
  62457. constructor(
  62458. /**
  62459. * Task name
  62460. */ name: string);
  62461. private _isCompleted;
  62462. private _taskState;
  62463. private _errorObject;
  62464. /**
  62465. * Get if the task is completed
  62466. */
  62467. readonly isCompleted: boolean;
  62468. /**
  62469. * Gets the current state of the task
  62470. */
  62471. readonly taskState: AssetTaskState;
  62472. /**
  62473. * Gets the current error object (if task is in error)
  62474. */
  62475. readonly errorObject: {
  62476. message?: string;
  62477. exception?: any;
  62478. };
  62479. /**
  62480. * Internal only
  62481. * @hidden
  62482. */
  62483. _setErrorObject(message?: string, exception?: any): void;
  62484. /**
  62485. * Execute the current task
  62486. * @param scene defines the scene where you want your assets to be loaded
  62487. * @param onSuccess is a callback called when the task is successfully executed
  62488. * @param onError is a callback called if an error occurs
  62489. */
  62490. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62491. /**
  62492. * Execute the current task
  62493. * @param scene defines the scene where you want your assets to be loaded
  62494. * @param onSuccess is a callback called when the task is successfully executed
  62495. * @param onError is a callback called if an error occurs
  62496. */
  62497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62498. /**
  62499. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62500. * This can be used with failed tasks that have the reason for failure fixed.
  62501. */
  62502. reset(): void;
  62503. private onErrorCallback;
  62504. private onDoneCallback;
  62505. }
  62506. /**
  62507. * Define the interface used by progress events raised during assets loading
  62508. */
  62509. export interface IAssetsProgressEvent {
  62510. /**
  62511. * Defines the number of remaining tasks to process
  62512. */
  62513. remainingCount: number;
  62514. /**
  62515. * Defines the total number of tasks
  62516. */
  62517. totalCount: number;
  62518. /**
  62519. * Defines the task that was just processed
  62520. */
  62521. task: AbstractAssetTask;
  62522. }
  62523. /**
  62524. * Class used to share progress information about assets loading
  62525. */
  62526. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62527. /**
  62528. * Defines the number of remaining tasks to process
  62529. */
  62530. remainingCount: number;
  62531. /**
  62532. * Defines the total number of tasks
  62533. */
  62534. totalCount: number;
  62535. /**
  62536. * Defines the task that was just processed
  62537. */
  62538. task: AbstractAssetTask;
  62539. /**
  62540. * Creates a AssetsProgressEvent
  62541. * @param remainingCount defines the number of remaining tasks to process
  62542. * @param totalCount defines the total number of tasks
  62543. * @param task defines the task that was just processed
  62544. */
  62545. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62546. }
  62547. /**
  62548. * Define a task used by AssetsManager to load meshes
  62549. */
  62550. export class MeshAssetTask extends AbstractAssetTask {
  62551. /**
  62552. * Defines the name of the task
  62553. */
  62554. name: string;
  62555. /**
  62556. * Defines the list of mesh's names you want to load
  62557. */
  62558. meshesNames: any;
  62559. /**
  62560. * Defines the root url to use as a base to load your meshes and associated resources
  62561. */
  62562. rootUrl: string;
  62563. /**
  62564. * Defines the filename of the scene to load from
  62565. */
  62566. sceneFilename: string;
  62567. /**
  62568. * Gets the list of loaded meshes
  62569. */
  62570. loadedMeshes: Array<AbstractMesh>;
  62571. /**
  62572. * Gets the list of loaded particle systems
  62573. */
  62574. loadedParticleSystems: Array<IParticleSystem>;
  62575. /**
  62576. * Gets the list of loaded skeletons
  62577. */
  62578. loadedSkeletons: Array<Skeleton>;
  62579. /**
  62580. * Gets the list of loaded animation groups
  62581. */
  62582. loadedAnimationGroups: Array<AnimationGroup>;
  62583. /**
  62584. * Callback called when the task is successful
  62585. */
  62586. onSuccess: (task: MeshAssetTask) => void;
  62587. /**
  62588. * Callback called when the task is successful
  62589. */
  62590. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62591. /**
  62592. * Creates a new MeshAssetTask
  62593. * @param name defines the name of the task
  62594. * @param meshesNames defines the list of mesh's names you want to load
  62595. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62596. * @param sceneFilename defines the filename of the scene to load from
  62597. */
  62598. constructor(
  62599. /**
  62600. * Defines the name of the task
  62601. */
  62602. name: string,
  62603. /**
  62604. * Defines the list of mesh's names you want to load
  62605. */
  62606. meshesNames: any,
  62607. /**
  62608. * Defines the root url to use as a base to load your meshes and associated resources
  62609. */
  62610. rootUrl: string,
  62611. /**
  62612. * Defines the filename of the scene to load from
  62613. */
  62614. sceneFilename: string);
  62615. /**
  62616. * Execute the current task
  62617. * @param scene defines the scene where you want your assets to be loaded
  62618. * @param onSuccess is a callback called when the task is successfully executed
  62619. * @param onError is a callback called if an error occurs
  62620. */
  62621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62622. }
  62623. /**
  62624. * Define a task used by AssetsManager to load text content
  62625. */
  62626. export class TextFileAssetTask extends AbstractAssetTask {
  62627. /**
  62628. * Defines the name of the task
  62629. */
  62630. name: string;
  62631. /**
  62632. * Defines the location of the file to load
  62633. */
  62634. url: string;
  62635. /**
  62636. * Gets the loaded text string
  62637. */
  62638. text: string;
  62639. /**
  62640. * Callback called when the task is successful
  62641. */
  62642. onSuccess: (task: TextFileAssetTask) => void;
  62643. /**
  62644. * Callback called when the task is successful
  62645. */
  62646. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62647. /**
  62648. * Creates a new TextFileAssetTask object
  62649. * @param name defines the name of the task
  62650. * @param url defines the location of the file to load
  62651. */
  62652. constructor(
  62653. /**
  62654. * Defines the name of the task
  62655. */
  62656. name: string,
  62657. /**
  62658. * Defines the location of the file to load
  62659. */
  62660. url: string);
  62661. /**
  62662. * Execute the current task
  62663. * @param scene defines the scene where you want your assets to be loaded
  62664. * @param onSuccess is a callback called when the task is successfully executed
  62665. * @param onError is a callback called if an error occurs
  62666. */
  62667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62668. }
  62669. /**
  62670. * Define a task used by AssetsManager to load binary data
  62671. */
  62672. export class BinaryFileAssetTask extends AbstractAssetTask {
  62673. /**
  62674. * Defines the name of the task
  62675. */
  62676. name: string;
  62677. /**
  62678. * Defines the location of the file to load
  62679. */
  62680. url: string;
  62681. /**
  62682. * Gets the lodaded data (as an array buffer)
  62683. */
  62684. data: ArrayBuffer;
  62685. /**
  62686. * Callback called when the task is successful
  62687. */
  62688. onSuccess: (task: BinaryFileAssetTask) => void;
  62689. /**
  62690. * Callback called when the task is successful
  62691. */
  62692. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62693. /**
  62694. * Creates a new BinaryFileAssetTask object
  62695. * @param name defines the name of the new task
  62696. * @param url defines the location of the file to load
  62697. */
  62698. constructor(
  62699. /**
  62700. * Defines the name of the task
  62701. */
  62702. name: string,
  62703. /**
  62704. * Defines the location of the file to load
  62705. */
  62706. url: string);
  62707. /**
  62708. * Execute the current task
  62709. * @param scene defines the scene where you want your assets to be loaded
  62710. * @param onSuccess is a callback called when the task is successfully executed
  62711. * @param onError is a callback called if an error occurs
  62712. */
  62713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62714. }
  62715. /**
  62716. * Define a task used by AssetsManager to load images
  62717. */
  62718. export class ImageAssetTask extends AbstractAssetTask {
  62719. /**
  62720. * Defines the name of the task
  62721. */
  62722. name: string;
  62723. /**
  62724. * Defines the location of the image to load
  62725. */
  62726. url: string;
  62727. /**
  62728. * Gets the loaded images
  62729. */
  62730. image: HTMLImageElement;
  62731. /**
  62732. * Callback called when the task is successful
  62733. */
  62734. onSuccess: (task: ImageAssetTask) => void;
  62735. /**
  62736. * Callback called when the task is successful
  62737. */
  62738. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62739. /**
  62740. * Creates a new ImageAssetTask
  62741. * @param name defines the name of the task
  62742. * @param url defines the location of the image to load
  62743. */
  62744. constructor(
  62745. /**
  62746. * Defines the name of the task
  62747. */
  62748. name: string,
  62749. /**
  62750. * Defines the location of the image to load
  62751. */
  62752. url: string);
  62753. /**
  62754. * Execute the current task
  62755. * @param scene defines the scene where you want your assets to be loaded
  62756. * @param onSuccess is a callback called when the task is successfully executed
  62757. * @param onError is a callback called if an error occurs
  62758. */
  62759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62760. }
  62761. /**
  62762. * Defines the interface used by texture loading tasks
  62763. */
  62764. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62765. /**
  62766. * Gets the loaded texture
  62767. */
  62768. texture: TEX;
  62769. }
  62770. /**
  62771. * Define a task used by AssetsManager to load 2D textures
  62772. */
  62773. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62774. /**
  62775. * Defines the name of the task
  62776. */
  62777. name: string;
  62778. /**
  62779. * Defines the location of the file to load
  62780. */
  62781. url: string;
  62782. /**
  62783. * Defines if mipmap should not be generated (default is false)
  62784. */
  62785. noMipmap?: boolean | undefined;
  62786. /**
  62787. * Defines if texture must be inverted on Y axis (default is false)
  62788. */
  62789. invertY?: boolean | undefined;
  62790. /**
  62791. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62792. */
  62793. samplingMode: number;
  62794. /**
  62795. * Gets the loaded texture
  62796. */
  62797. texture: Texture;
  62798. /**
  62799. * Callback called when the task is successful
  62800. */
  62801. onSuccess: (task: TextureAssetTask) => void;
  62802. /**
  62803. * Callback called when the task is successful
  62804. */
  62805. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62806. /**
  62807. * Creates a new TextureAssetTask object
  62808. * @param name defines the name of the task
  62809. * @param url defines the location of the file to load
  62810. * @param noMipmap defines if mipmap should not be generated (default is false)
  62811. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62812. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62813. */
  62814. constructor(
  62815. /**
  62816. * Defines the name of the task
  62817. */
  62818. name: string,
  62819. /**
  62820. * Defines the location of the file to load
  62821. */
  62822. url: string,
  62823. /**
  62824. * Defines if mipmap should not be generated (default is false)
  62825. */
  62826. noMipmap?: boolean | undefined,
  62827. /**
  62828. * Defines if texture must be inverted on Y axis (default is false)
  62829. */
  62830. invertY?: boolean | undefined,
  62831. /**
  62832. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62833. */
  62834. samplingMode?: number);
  62835. /**
  62836. * Execute the current task
  62837. * @param scene defines the scene where you want your assets to be loaded
  62838. * @param onSuccess is a callback called when the task is successfully executed
  62839. * @param onError is a callback called if an error occurs
  62840. */
  62841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62842. }
  62843. /**
  62844. * Define a task used by AssetsManager to load cube textures
  62845. */
  62846. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62847. /**
  62848. * Defines the name of the task
  62849. */
  62850. name: string;
  62851. /**
  62852. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62853. */
  62854. url: string;
  62855. /**
  62856. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62857. */
  62858. extensions?: string[] | undefined;
  62859. /**
  62860. * Defines if mipmaps should not be generated (default is false)
  62861. */
  62862. noMipmap?: boolean | undefined;
  62863. /**
  62864. * Defines the explicit list of files (undefined by default)
  62865. */
  62866. files?: string[] | undefined;
  62867. /**
  62868. * Gets the loaded texture
  62869. */
  62870. texture: CubeTexture;
  62871. /**
  62872. * Callback called when the task is successful
  62873. */
  62874. onSuccess: (task: CubeTextureAssetTask) => void;
  62875. /**
  62876. * Callback called when the task is successful
  62877. */
  62878. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62879. /**
  62880. * Creates a new CubeTextureAssetTask
  62881. * @param name defines the name of the task
  62882. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62883. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62884. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62885. * @param files defines the explicit list of files (undefined by default)
  62886. */
  62887. constructor(
  62888. /**
  62889. * Defines the name of the task
  62890. */
  62891. name: string,
  62892. /**
  62893. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62894. */
  62895. url: string,
  62896. /**
  62897. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62898. */
  62899. extensions?: string[] | undefined,
  62900. /**
  62901. * Defines if mipmaps should not be generated (default is false)
  62902. */
  62903. noMipmap?: boolean | undefined,
  62904. /**
  62905. * Defines the explicit list of files (undefined by default)
  62906. */
  62907. files?: string[] | undefined);
  62908. /**
  62909. * Execute the current task
  62910. * @param scene defines the scene where you want your assets to be loaded
  62911. * @param onSuccess is a callback called when the task is successfully executed
  62912. * @param onError is a callback called if an error occurs
  62913. */
  62914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62915. }
  62916. /**
  62917. * Define a task used by AssetsManager to load HDR cube textures
  62918. */
  62919. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62920. /**
  62921. * Defines the name of the task
  62922. */
  62923. name: string;
  62924. /**
  62925. * Defines the location of the file to load
  62926. */
  62927. url: string;
  62928. /**
  62929. * Defines the desired size (the more it increases the longer the generation will be)
  62930. */
  62931. size: number;
  62932. /**
  62933. * Defines if mipmaps should not be generated (default is false)
  62934. */
  62935. noMipmap: boolean;
  62936. /**
  62937. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62938. */
  62939. generateHarmonics: boolean;
  62940. /**
  62941. * 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)
  62942. */
  62943. gammaSpace: boolean;
  62944. /**
  62945. * Internal Use Only
  62946. */
  62947. reserved: boolean;
  62948. /**
  62949. * Gets the loaded texture
  62950. */
  62951. texture: HDRCubeTexture;
  62952. /**
  62953. * Callback called when the task is successful
  62954. */
  62955. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62956. /**
  62957. * Callback called when the task is successful
  62958. */
  62959. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62960. /**
  62961. * Creates a new HDRCubeTextureAssetTask object
  62962. * @param name defines the name of the task
  62963. * @param url defines the location of the file to load
  62964. * @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.
  62965. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62966. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62967. * @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)
  62968. * @param reserved Internal use only
  62969. */
  62970. constructor(
  62971. /**
  62972. * Defines the name of the task
  62973. */
  62974. name: string,
  62975. /**
  62976. * Defines the location of the file to load
  62977. */
  62978. url: string,
  62979. /**
  62980. * Defines the desired size (the more it increases the longer the generation will be)
  62981. */
  62982. size: number,
  62983. /**
  62984. * Defines if mipmaps should not be generated (default is false)
  62985. */
  62986. noMipmap?: boolean,
  62987. /**
  62988. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62989. */
  62990. generateHarmonics?: boolean,
  62991. /**
  62992. * 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)
  62993. */
  62994. gammaSpace?: boolean,
  62995. /**
  62996. * Internal Use Only
  62997. */
  62998. reserved?: boolean);
  62999. /**
  63000. * Execute the current task
  63001. * @param scene defines the scene where you want your assets to be loaded
  63002. * @param onSuccess is a callback called when the task is successfully executed
  63003. * @param onError is a callback called if an error occurs
  63004. */
  63005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63006. }
  63007. /**
  63008. * Define a task used by AssetsManager to load Equirectangular cube textures
  63009. */
  63010. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63011. /**
  63012. * Defines the name of the task
  63013. */
  63014. name: string;
  63015. /**
  63016. * Defines the location of the file to load
  63017. */
  63018. url: string;
  63019. /**
  63020. * Defines the desired size (the more it increases the longer the generation will be)
  63021. */
  63022. size: number;
  63023. /**
  63024. * Defines if mipmaps should not be generated (default is false)
  63025. */
  63026. noMipmap: boolean;
  63027. /**
  63028. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63029. * but the standard material would require them in Gamma space) (default is true)
  63030. */
  63031. gammaSpace: boolean;
  63032. /**
  63033. * Gets the loaded texture
  63034. */
  63035. texture: EquiRectangularCubeTexture;
  63036. /**
  63037. * Callback called when the task is successful
  63038. */
  63039. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63040. /**
  63041. * Callback called when the task is successful
  63042. */
  63043. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63044. /**
  63045. * Creates a new EquiRectangularCubeTextureAssetTask object
  63046. * @param name defines the name of the task
  63047. * @param url defines the location of the file to load
  63048. * @param size defines the desired size (the more it increases the longer the generation will be)
  63049. * If the size is omitted this implies you are using a preprocessed cubemap.
  63050. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63051. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63052. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63053. * (default is true)
  63054. */
  63055. constructor(
  63056. /**
  63057. * Defines the name of the task
  63058. */
  63059. name: string,
  63060. /**
  63061. * Defines the location of the file to load
  63062. */
  63063. url: string,
  63064. /**
  63065. * Defines the desired size (the more it increases the longer the generation will be)
  63066. */
  63067. size: number,
  63068. /**
  63069. * Defines if mipmaps should not be generated (default is false)
  63070. */
  63071. noMipmap?: boolean,
  63072. /**
  63073. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63074. * but the standard material would require them in Gamma space) (default is true)
  63075. */
  63076. gammaSpace?: boolean);
  63077. /**
  63078. * Execute the current task
  63079. * @param scene defines the scene where you want your assets to be loaded
  63080. * @param onSuccess is a callback called when the task is successfully executed
  63081. * @param onError is a callback called if an error occurs
  63082. */
  63083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63084. }
  63085. /**
  63086. * This class can be used to easily import assets into a scene
  63087. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63088. */
  63089. export class AssetsManager {
  63090. private _scene;
  63091. private _isLoading;
  63092. protected _tasks: AbstractAssetTask[];
  63093. protected _waitingTasksCount: number;
  63094. protected _totalTasksCount: number;
  63095. /**
  63096. * Callback called when all tasks are processed
  63097. */
  63098. onFinish: (tasks: AbstractAssetTask[]) => void;
  63099. /**
  63100. * Callback called when a task is successful
  63101. */
  63102. onTaskSuccess: (task: AbstractAssetTask) => void;
  63103. /**
  63104. * Callback called when a task had an error
  63105. */
  63106. onTaskError: (task: AbstractAssetTask) => void;
  63107. /**
  63108. * Callback called when a task is done (whatever the result is)
  63109. */
  63110. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63111. /**
  63112. * Observable called when all tasks are processed
  63113. */
  63114. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63115. /**
  63116. * Observable called when a task had an error
  63117. */
  63118. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63119. /**
  63120. * Observable called when all tasks were executed
  63121. */
  63122. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63123. /**
  63124. * Observable called when a task is done (whatever the result is)
  63125. */
  63126. onProgressObservable: Observable<IAssetsProgressEvent>;
  63127. /**
  63128. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63130. */
  63131. useDefaultLoadingScreen: boolean;
  63132. /**
  63133. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63134. * when all assets have been downloaded.
  63135. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63136. */
  63137. autoHideLoadingUI: boolean;
  63138. /**
  63139. * Creates a new AssetsManager
  63140. * @param scene defines the scene to work on
  63141. */
  63142. constructor(scene: Scene);
  63143. /**
  63144. * Add a MeshAssetTask to the list of active tasks
  63145. * @param taskName defines the name of the new task
  63146. * @param meshesNames defines the name of meshes to load
  63147. * @param rootUrl defines the root url to use to locate files
  63148. * @param sceneFilename defines the filename of the scene file
  63149. * @returns a new MeshAssetTask object
  63150. */
  63151. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63152. /**
  63153. * Add a TextFileAssetTask to the list of active tasks
  63154. * @param taskName defines the name of the new task
  63155. * @param url defines the url of the file to load
  63156. * @returns a new TextFileAssetTask object
  63157. */
  63158. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63159. /**
  63160. * Add a BinaryFileAssetTask to the list of active tasks
  63161. * @param taskName defines the name of the new task
  63162. * @param url defines the url of the file to load
  63163. * @returns a new BinaryFileAssetTask object
  63164. */
  63165. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63166. /**
  63167. * Add a ImageAssetTask to the list of active tasks
  63168. * @param taskName defines the name of the new task
  63169. * @param url defines the url of the file to load
  63170. * @returns a new ImageAssetTask object
  63171. */
  63172. addImageTask(taskName: string, url: string): ImageAssetTask;
  63173. /**
  63174. * Add a TextureAssetTask to the list of active tasks
  63175. * @param taskName defines the name of the new task
  63176. * @param url defines the url of the file to load
  63177. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63178. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63179. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63180. * @returns a new TextureAssetTask object
  63181. */
  63182. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63183. /**
  63184. * Add a CubeTextureAssetTask to the list of active tasks
  63185. * @param taskName defines the name of the new task
  63186. * @param url defines the url of the file to load
  63187. * @param extensions defines the extension to use to load the cube map (can be null)
  63188. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63189. * @param files defines the list of files to load (can be null)
  63190. * @returns a new CubeTextureAssetTask object
  63191. */
  63192. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63193. /**
  63194. *
  63195. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63196. * @param taskName defines the name of the new task
  63197. * @param url defines the url of the file to load
  63198. * @param size defines the size you want for the cubemap (can be null)
  63199. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63200. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63201. * @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)
  63202. * @param reserved Internal use only
  63203. * @returns a new HDRCubeTextureAssetTask object
  63204. */
  63205. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63206. /**
  63207. *
  63208. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63209. * @param taskName defines the name of the new task
  63210. * @param url defines the url of the file to load
  63211. * @param size defines the size you want for the cubemap (can be null)
  63212. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63213. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63214. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63215. * @returns a new EquiRectangularCubeTextureAssetTask object
  63216. */
  63217. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63218. /**
  63219. * Remove a task from the assets manager.
  63220. * @param task the task to remove
  63221. */
  63222. removeTask(task: AbstractAssetTask): void;
  63223. private _decreaseWaitingTasksCount;
  63224. private _runTask;
  63225. /**
  63226. * Reset the AssetsManager and remove all tasks
  63227. * @return the current instance of the AssetsManager
  63228. */
  63229. reset(): AssetsManager;
  63230. /**
  63231. * Start the loading process
  63232. * @return the current instance of the AssetsManager
  63233. */
  63234. load(): AssetsManager;
  63235. /**
  63236. * Start the loading process as an async operation
  63237. * @return a promise returning the list of failed tasks
  63238. */
  63239. loadAsync(): Promise<void>;
  63240. }
  63241. }
  63242. declare module "babylonjs/Misc/deferred" {
  63243. /**
  63244. * Wrapper class for promise with external resolve and reject.
  63245. */
  63246. export class Deferred<T> {
  63247. /**
  63248. * The promise associated with this deferred object.
  63249. */
  63250. readonly promise: Promise<T>;
  63251. private _resolve;
  63252. private _reject;
  63253. /**
  63254. * The resolve method of the promise associated with this deferred object.
  63255. */
  63256. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63257. /**
  63258. * The reject method of the promise associated with this deferred object.
  63259. */
  63260. readonly reject: (reason?: any) => void;
  63261. /**
  63262. * Constructor for this deferred object.
  63263. */
  63264. constructor();
  63265. }
  63266. }
  63267. declare module "babylonjs/Misc/meshExploder" {
  63268. import { Mesh } from "babylonjs/Meshes/mesh";
  63269. /**
  63270. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63271. */
  63272. export class MeshExploder {
  63273. private _centerMesh;
  63274. private _meshes;
  63275. private _meshesOrigins;
  63276. private _toCenterVectors;
  63277. private _scaledDirection;
  63278. private _newPosition;
  63279. private _centerPosition;
  63280. /**
  63281. * Explodes meshes from a center mesh.
  63282. * @param meshes The meshes to explode.
  63283. * @param centerMesh The mesh to be center of explosion.
  63284. */
  63285. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63286. private _setCenterMesh;
  63287. /**
  63288. * Get class name
  63289. * @returns "MeshExploder"
  63290. */
  63291. getClassName(): string;
  63292. /**
  63293. * "Exploded meshes"
  63294. * @returns Array of meshes with the centerMesh at index 0.
  63295. */
  63296. getMeshes(): Array<Mesh>;
  63297. /**
  63298. * Explodes meshes giving a specific direction
  63299. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63300. */
  63301. explode(direction?: number): void;
  63302. }
  63303. }
  63304. declare module "babylonjs/Misc/filesInput" {
  63305. import { Engine } from "babylonjs/Engines/engine";
  63306. import { Scene } from "babylonjs/scene";
  63307. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63308. /**
  63309. * Class used to help managing file picking and drag'n'drop
  63310. */
  63311. export class FilesInput {
  63312. /**
  63313. * List of files ready to be loaded
  63314. */
  63315. static readonly FilesToLoad: {
  63316. [key: string]: File;
  63317. };
  63318. /**
  63319. * Callback called when a file is processed
  63320. */
  63321. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63322. private _engine;
  63323. private _currentScene;
  63324. private _sceneLoadedCallback;
  63325. private _progressCallback;
  63326. private _additionalRenderLoopLogicCallback;
  63327. private _textureLoadingCallback;
  63328. private _startingProcessingFilesCallback;
  63329. private _onReloadCallback;
  63330. private _errorCallback;
  63331. private _elementToMonitor;
  63332. private _sceneFileToLoad;
  63333. private _filesToLoad;
  63334. /**
  63335. * Creates a new FilesInput
  63336. * @param engine defines the rendering engine
  63337. * @param scene defines the hosting scene
  63338. * @param sceneLoadedCallback callback called when scene is loaded
  63339. * @param progressCallback callback called to track progress
  63340. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63341. * @param textureLoadingCallback callback called when a texture is loading
  63342. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63343. * @param onReloadCallback callback called when a reload is requested
  63344. * @param errorCallback callback call if an error occurs
  63345. */
  63346. 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);
  63347. private _dragEnterHandler;
  63348. private _dragOverHandler;
  63349. private _dropHandler;
  63350. /**
  63351. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63352. * @param elementToMonitor defines the DOM element to track
  63353. */
  63354. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63355. /**
  63356. * Release all associated resources
  63357. */
  63358. dispose(): void;
  63359. private renderFunction;
  63360. private drag;
  63361. private drop;
  63362. private _traverseFolder;
  63363. private _processFiles;
  63364. /**
  63365. * Load files from a drop event
  63366. * @param event defines the drop event to use as source
  63367. */
  63368. loadFiles(event: any): void;
  63369. private _processReload;
  63370. /**
  63371. * Reload the current scene from the loaded files
  63372. */
  63373. reload(): void;
  63374. }
  63375. }
  63376. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63377. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63378. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63379. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63380. }
  63381. declare module "babylonjs/Misc/sceneOptimizer" {
  63382. import { Scene, IDisposable } from "babylonjs/scene";
  63383. import { Observable } from "babylonjs/Misc/observable";
  63384. /**
  63385. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63387. */
  63388. export class SceneOptimization {
  63389. /**
  63390. * Defines the priority of this optimization (0 by default which means first in the list)
  63391. */
  63392. priority: number;
  63393. /**
  63394. * Gets a string describing the action executed by the current optimization
  63395. * @returns description string
  63396. */
  63397. getDescription(): string;
  63398. /**
  63399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63400. * @param scene defines the current scene where to apply this optimization
  63401. * @param optimizer defines the current optimizer
  63402. * @returns true if everything that can be done was applied
  63403. */
  63404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63405. /**
  63406. * Creates the SceneOptimization object
  63407. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63408. * @param desc defines the description associated with the optimization
  63409. */
  63410. constructor(
  63411. /**
  63412. * Defines the priority of this optimization (0 by default which means first in the list)
  63413. */
  63414. priority?: number);
  63415. }
  63416. /**
  63417. * Defines an optimization used to reduce the size of render target textures
  63418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63419. */
  63420. export class TextureOptimization extends SceneOptimization {
  63421. /**
  63422. * Defines the priority of this optimization (0 by default which means first in the list)
  63423. */
  63424. priority: number;
  63425. /**
  63426. * 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
  63427. */
  63428. maximumSize: number;
  63429. /**
  63430. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63431. */
  63432. step: number;
  63433. /**
  63434. * Gets a string describing the action executed by the current optimization
  63435. * @returns description string
  63436. */
  63437. getDescription(): string;
  63438. /**
  63439. * Creates the TextureOptimization object
  63440. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63441. * @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
  63442. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63443. */
  63444. constructor(
  63445. /**
  63446. * Defines the priority of this optimization (0 by default which means first in the list)
  63447. */
  63448. priority?: number,
  63449. /**
  63450. * 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
  63451. */
  63452. maximumSize?: number,
  63453. /**
  63454. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63455. */
  63456. step?: number);
  63457. /**
  63458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63459. * @param scene defines the current scene where to apply this optimization
  63460. * @param optimizer defines the current optimizer
  63461. * @returns true if everything that can be done was applied
  63462. */
  63463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63464. }
  63465. /**
  63466. * Defines an optimization used to increase or decrease the rendering resolution
  63467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63468. */
  63469. export class HardwareScalingOptimization extends SceneOptimization {
  63470. /**
  63471. * Defines the priority of this optimization (0 by default which means first in the list)
  63472. */
  63473. priority: number;
  63474. /**
  63475. * Defines the maximum scale to use (2 by default)
  63476. */
  63477. maximumScale: number;
  63478. /**
  63479. * Defines the step to use between two passes (0.5 by default)
  63480. */
  63481. step: number;
  63482. private _currentScale;
  63483. private _directionOffset;
  63484. /**
  63485. * Gets a string describing the action executed by the current optimization
  63486. * @return description string
  63487. */
  63488. getDescription(): string;
  63489. /**
  63490. * Creates the HardwareScalingOptimization object
  63491. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63492. * @param maximumScale defines the maximum scale to use (2 by default)
  63493. * @param step defines the step to use between two passes (0.5 by default)
  63494. */
  63495. constructor(
  63496. /**
  63497. * Defines the priority of this optimization (0 by default which means first in the list)
  63498. */
  63499. priority?: number,
  63500. /**
  63501. * Defines the maximum scale to use (2 by default)
  63502. */
  63503. maximumScale?: number,
  63504. /**
  63505. * Defines the step to use between two passes (0.5 by default)
  63506. */
  63507. step?: number);
  63508. /**
  63509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63510. * @param scene defines the current scene where to apply this optimization
  63511. * @param optimizer defines the current optimizer
  63512. * @returns true if everything that can be done was applied
  63513. */
  63514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63515. }
  63516. /**
  63517. * Defines an optimization used to remove shadows
  63518. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63519. */
  63520. export class ShadowsOptimization extends SceneOptimization {
  63521. /**
  63522. * Gets a string describing the action executed by the current optimization
  63523. * @return description string
  63524. */
  63525. getDescription(): string;
  63526. /**
  63527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63528. * @param scene defines the current scene where to apply this optimization
  63529. * @param optimizer defines the current optimizer
  63530. * @returns true if everything that can be done was applied
  63531. */
  63532. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63533. }
  63534. /**
  63535. * Defines an optimization used to turn post-processes off
  63536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63537. */
  63538. export class PostProcessesOptimization extends SceneOptimization {
  63539. /**
  63540. * Gets a string describing the action executed by the current optimization
  63541. * @return description string
  63542. */
  63543. getDescription(): string;
  63544. /**
  63545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63546. * @param scene defines the current scene where to apply this optimization
  63547. * @param optimizer defines the current optimizer
  63548. * @returns true if everything that can be done was applied
  63549. */
  63550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63551. }
  63552. /**
  63553. * Defines an optimization used to turn lens flares off
  63554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63555. */
  63556. export class LensFlaresOptimization extends SceneOptimization {
  63557. /**
  63558. * Gets a string describing the action executed by the current optimization
  63559. * @return description string
  63560. */
  63561. getDescription(): string;
  63562. /**
  63563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63564. * @param scene defines the current scene where to apply this optimization
  63565. * @param optimizer defines the current optimizer
  63566. * @returns true if everything that can be done was applied
  63567. */
  63568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63569. }
  63570. /**
  63571. * Defines an optimization based on user defined callback.
  63572. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63573. */
  63574. export class CustomOptimization extends SceneOptimization {
  63575. /**
  63576. * Callback called to apply the custom optimization.
  63577. */
  63578. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63579. /**
  63580. * Callback called to get custom description
  63581. */
  63582. onGetDescription: () => string;
  63583. /**
  63584. * Gets a string describing the action executed by the current optimization
  63585. * @returns description string
  63586. */
  63587. getDescription(): string;
  63588. /**
  63589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63590. * @param scene defines the current scene where to apply this optimization
  63591. * @param optimizer defines the current optimizer
  63592. * @returns true if everything that can be done was applied
  63593. */
  63594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63595. }
  63596. /**
  63597. * Defines an optimization used to turn particles off
  63598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63599. */
  63600. export class ParticlesOptimization extends SceneOptimization {
  63601. /**
  63602. * Gets a string describing the action executed by the current optimization
  63603. * @return description string
  63604. */
  63605. getDescription(): string;
  63606. /**
  63607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63608. * @param scene defines the current scene where to apply this optimization
  63609. * @param optimizer defines the current optimizer
  63610. * @returns true if everything that can be done was applied
  63611. */
  63612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63613. }
  63614. /**
  63615. * Defines an optimization used to turn render targets off
  63616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63617. */
  63618. export class RenderTargetsOptimization extends SceneOptimization {
  63619. /**
  63620. * Gets a string describing the action executed by the current optimization
  63621. * @return description string
  63622. */
  63623. getDescription(): string;
  63624. /**
  63625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63626. * @param scene defines the current scene where to apply this optimization
  63627. * @param optimizer defines the current optimizer
  63628. * @returns true if everything that can be done was applied
  63629. */
  63630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63631. }
  63632. /**
  63633. * Defines an optimization used to merge meshes with compatible materials
  63634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63635. */
  63636. export class MergeMeshesOptimization extends SceneOptimization {
  63637. private static _UpdateSelectionTree;
  63638. /**
  63639. * Gets or sets a boolean which defines if optimization octree has to be updated
  63640. */
  63641. /**
  63642. * Gets or sets a boolean which defines if optimization octree has to be updated
  63643. */
  63644. static UpdateSelectionTree: boolean;
  63645. /**
  63646. * Gets a string describing the action executed by the current optimization
  63647. * @return description string
  63648. */
  63649. getDescription(): string;
  63650. private _canBeMerged;
  63651. /**
  63652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63653. * @param scene defines the current scene where to apply this optimization
  63654. * @param optimizer defines the current optimizer
  63655. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63656. * @returns true if everything that can be done was applied
  63657. */
  63658. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63659. }
  63660. /**
  63661. * Defines a list of options used by SceneOptimizer
  63662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63663. */
  63664. export class SceneOptimizerOptions {
  63665. /**
  63666. * Defines the target frame rate to reach (60 by default)
  63667. */
  63668. targetFrameRate: number;
  63669. /**
  63670. * Defines the interval between two checkes (2000ms by default)
  63671. */
  63672. trackerDuration: number;
  63673. /**
  63674. * Gets the list of optimizations to apply
  63675. */
  63676. optimizations: SceneOptimization[];
  63677. /**
  63678. * Creates a new list of options used by SceneOptimizer
  63679. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63680. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63681. */
  63682. constructor(
  63683. /**
  63684. * Defines the target frame rate to reach (60 by default)
  63685. */
  63686. targetFrameRate?: number,
  63687. /**
  63688. * Defines the interval between two checkes (2000ms by default)
  63689. */
  63690. trackerDuration?: number);
  63691. /**
  63692. * Add a new optimization
  63693. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63694. * @returns the current SceneOptimizerOptions
  63695. */
  63696. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63697. /**
  63698. * Add a new custom optimization
  63699. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63700. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63701. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63702. * @returns the current SceneOptimizerOptions
  63703. */
  63704. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63705. /**
  63706. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63707. * @param targetFrameRate defines the target frame rate (60 by default)
  63708. * @returns a SceneOptimizerOptions object
  63709. */
  63710. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63711. /**
  63712. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63713. * @param targetFrameRate defines the target frame rate (60 by default)
  63714. * @returns a SceneOptimizerOptions object
  63715. */
  63716. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63717. /**
  63718. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63719. * @param targetFrameRate defines the target frame rate (60 by default)
  63720. * @returns a SceneOptimizerOptions object
  63721. */
  63722. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63723. }
  63724. /**
  63725. * Class used to run optimizations in order to reach a target frame rate
  63726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63727. */
  63728. export class SceneOptimizer implements IDisposable {
  63729. private _isRunning;
  63730. private _options;
  63731. private _scene;
  63732. private _currentPriorityLevel;
  63733. private _targetFrameRate;
  63734. private _trackerDuration;
  63735. private _currentFrameRate;
  63736. private _sceneDisposeObserver;
  63737. private _improvementMode;
  63738. /**
  63739. * Defines an observable called when the optimizer reaches the target frame rate
  63740. */
  63741. onSuccessObservable: Observable<SceneOptimizer>;
  63742. /**
  63743. * Defines an observable called when the optimizer enables an optimization
  63744. */
  63745. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63746. /**
  63747. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63748. */
  63749. onFailureObservable: Observable<SceneOptimizer>;
  63750. /**
  63751. * Gets a boolean indicating if the optimizer is in improvement mode
  63752. */
  63753. readonly isInImprovementMode: boolean;
  63754. /**
  63755. * Gets the current priority level (0 at start)
  63756. */
  63757. readonly currentPriorityLevel: number;
  63758. /**
  63759. * Gets the current frame rate checked by the SceneOptimizer
  63760. */
  63761. readonly currentFrameRate: number;
  63762. /**
  63763. * Gets or sets the current target frame rate (60 by default)
  63764. */
  63765. /**
  63766. * Gets or sets the current target frame rate (60 by default)
  63767. */
  63768. targetFrameRate: number;
  63769. /**
  63770. * Gets or sets the current interval between two checks (every 2000ms by default)
  63771. */
  63772. /**
  63773. * Gets or sets the current interval between two checks (every 2000ms by default)
  63774. */
  63775. trackerDuration: number;
  63776. /**
  63777. * Gets the list of active optimizations
  63778. */
  63779. readonly optimizations: SceneOptimization[];
  63780. /**
  63781. * Creates a new SceneOptimizer
  63782. * @param scene defines the scene to work on
  63783. * @param options defines the options to use with the SceneOptimizer
  63784. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63785. * @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)
  63786. */
  63787. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63788. /**
  63789. * Stops the current optimizer
  63790. */
  63791. stop(): void;
  63792. /**
  63793. * Reset the optimizer to initial step (current priority level = 0)
  63794. */
  63795. reset(): void;
  63796. /**
  63797. * Start the optimizer. By default it will try to reach a specific framerate
  63798. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63799. */
  63800. start(): void;
  63801. private _checkCurrentState;
  63802. /**
  63803. * Release all resources
  63804. */
  63805. dispose(): void;
  63806. /**
  63807. * Helper function to create a SceneOptimizer with one single line of code
  63808. * @param scene defines the scene to work on
  63809. * @param options defines the options to use with the SceneOptimizer
  63810. * @param onSuccess defines a callback to call on success
  63811. * @param onFailure defines a callback to call on failure
  63812. * @returns the new SceneOptimizer object
  63813. */
  63814. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63815. }
  63816. }
  63817. declare module "babylonjs/Misc/sceneSerializer" {
  63818. import { Scene } from "babylonjs/scene";
  63819. /**
  63820. * Class used to serialize a scene into a string
  63821. */
  63822. export class SceneSerializer {
  63823. /**
  63824. * Clear cache used by a previous serialization
  63825. */
  63826. static ClearCache(): void;
  63827. /**
  63828. * Serialize a scene into a JSON compatible object
  63829. * @param scene defines the scene to serialize
  63830. * @returns a JSON compatible object
  63831. */
  63832. static Serialize(scene: Scene): any;
  63833. /**
  63834. * Serialize a mesh into a JSON compatible object
  63835. * @param toSerialize defines the mesh to serialize
  63836. * @param withParents defines if parents must be serialized as well
  63837. * @param withChildren defines if children must be serialized as well
  63838. * @returns a JSON compatible object
  63839. */
  63840. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63841. }
  63842. }
  63843. declare module "babylonjs/Misc/textureTools" {
  63844. import { Texture } from "babylonjs/Materials/Textures/texture";
  63845. /**
  63846. * Class used to host texture specific utilities
  63847. */
  63848. export class TextureTools {
  63849. /**
  63850. * Uses the GPU to create a copy texture rescaled at a given size
  63851. * @param texture Texture to copy from
  63852. * @param width defines the desired width
  63853. * @param height defines the desired height
  63854. * @param useBilinearMode defines if bilinear mode has to be used
  63855. * @return the generated texture
  63856. */
  63857. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63858. }
  63859. }
  63860. declare module "babylonjs/Misc/videoRecorder" {
  63861. import { Nullable } from "babylonjs/types";
  63862. import { Engine } from "babylonjs/Engines/engine";
  63863. /**
  63864. * This represents the different options available for the video capture.
  63865. */
  63866. export interface VideoRecorderOptions {
  63867. /** Defines the mime type of the video. */
  63868. mimeType: string;
  63869. /** Defines the FPS the video should be recorded at. */
  63870. fps: number;
  63871. /** Defines the chunk size for the recording data. */
  63872. recordChunckSize: number;
  63873. /** The audio tracks to attach to the recording. */
  63874. audioTracks?: MediaStreamTrack[];
  63875. }
  63876. /**
  63877. * This can help with recording videos from BabylonJS.
  63878. * This is based on the available WebRTC functionalities of the browser.
  63879. *
  63880. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63881. */
  63882. export class VideoRecorder {
  63883. private static readonly _defaultOptions;
  63884. /**
  63885. * Returns whether or not the VideoRecorder is available in your browser.
  63886. * @param engine Defines the Babylon Engine.
  63887. * @returns true if supported otherwise false.
  63888. */
  63889. static IsSupported(engine: Engine): boolean;
  63890. private readonly _options;
  63891. private _canvas;
  63892. private _mediaRecorder;
  63893. private _recordedChunks;
  63894. private _fileName;
  63895. private _resolve;
  63896. private _reject;
  63897. /**
  63898. * True when a recording is already in progress.
  63899. */
  63900. readonly isRecording: boolean;
  63901. /**
  63902. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63903. * @param engine Defines the BabylonJS Engine you wish to record.
  63904. * @param options Defines options that can be used to customize the capture.
  63905. */
  63906. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63907. /**
  63908. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63909. */
  63910. stopRecording(): void;
  63911. /**
  63912. * Starts recording the canvas for a max duration specified in parameters.
  63913. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63914. * If null no automatic download will start and you can rely on the promise to get the data back.
  63915. * @param maxDuration Defines the maximum recording time in seconds.
  63916. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63917. * @return A promise callback at the end of the recording with the video data in Blob.
  63918. */
  63919. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63920. /**
  63921. * Releases internal resources used during the recording.
  63922. */
  63923. dispose(): void;
  63924. private _handleDataAvailable;
  63925. private _handleError;
  63926. private _handleStop;
  63927. }
  63928. }
  63929. declare module "babylonjs/Misc/screenshotTools" {
  63930. import { Camera } from "babylonjs/Cameras/camera";
  63931. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  63932. import { Engine } from "babylonjs/Engines/engine";
  63933. /**
  63934. * Class containing a set of static utilities functions for screenshots
  63935. */
  63936. export class ScreenshotTools {
  63937. /**
  63938. * Captures a screenshot of the current rendering
  63939. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63940. * @param engine defines the rendering engine
  63941. * @param camera defines the source camera
  63942. * @param size This parameter can be set to a single number or to an object with the
  63943. * following (optional) properties: precision, width, height. If a single number is passed,
  63944. * it will be used for both width and height. If an object is passed, the screenshot size
  63945. * will be derived from the parameters. The precision property is a multiplier allowing
  63946. * rendering at a higher or lower resolution
  63947. * @param successCallback defines the callback receives a single parameter which contains the
  63948. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63949. * src parameter of an <img> to display it
  63950. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63951. * Check your browser for supported MIME types
  63952. */
  63953. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63954. /**
  63955. * Captures a screenshot of the current rendering
  63956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63957. * @param engine defines the rendering engine
  63958. * @param camera defines the source camera
  63959. * @param size This parameter can be set to a single number or to an object with the
  63960. * following (optional) properties: precision, width, height. If a single number is passed,
  63961. * it will be used for both width and height. If an object is passed, the screenshot size
  63962. * will be derived from the parameters. The precision property is a multiplier allowing
  63963. * rendering at a higher or lower resolution
  63964. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63965. * Check your browser for supported MIME types
  63966. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63967. * to the src parameter of an <img> to display it
  63968. */
  63969. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63970. /**
  63971. * Generates an image screenshot from the specified camera.
  63972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63973. * @param engine The engine to use for rendering
  63974. * @param camera The camera to use for rendering
  63975. * @param size This parameter can be set to a single number or to an object with the
  63976. * following (optional) properties: precision, width, height. If a single number is passed,
  63977. * it will be used for both width and height. If an object is passed, the screenshot size
  63978. * will be derived from the parameters. The precision property is a multiplier allowing
  63979. * rendering at a higher or lower resolution
  63980. * @param successCallback The callback receives a single parameter which contains the
  63981. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63982. * src parameter of an <img> to display it
  63983. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63984. * Check your browser for supported MIME types
  63985. * @param samples Texture samples (default: 1)
  63986. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63987. * @param fileName A name for for the downloaded file.
  63988. */
  63989. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63990. /**
  63991. * Generates an image screenshot from the specified camera.
  63992. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63993. * @param engine The engine to use for rendering
  63994. * @param camera The camera to use for rendering
  63995. * @param size This parameter can be set to a single number or to an object with the
  63996. * following (optional) properties: precision, width, height. If a single number is passed,
  63997. * it will be used for both width and height. If an object is passed, the screenshot size
  63998. * will be derived from the parameters. The precision property is a multiplier allowing
  63999. * rendering at a higher or lower resolution
  64000. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64001. * Check your browser for supported MIME types
  64002. * @param samples Texture samples (default: 1)
  64003. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64004. * @param fileName A name for for the downloaded file.
  64005. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64006. * to the src parameter of an <img> to display it
  64007. */
  64008. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64009. /**
  64010. * Gets height and width for screenshot size
  64011. * @private
  64012. */
  64013. private static _getScreenshotSize;
  64014. }
  64015. }
  64016. declare module "babylonjs/Misc/index" {
  64017. export * from "babylonjs/Misc/andOrNotEvaluator";
  64018. export * from "babylonjs/Misc/assetsManager";
  64019. export * from "babylonjs/Misc/dds";
  64020. export * from "babylonjs/Misc/decorators";
  64021. export * from "babylonjs/Misc/deferred";
  64022. export * from "babylonjs/Misc/environmentTextureTools";
  64023. export * from "babylonjs/Misc/meshExploder";
  64024. export * from "babylonjs/Misc/filesInput";
  64025. export * from "babylonjs/Misc/HighDynamicRange/index";
  64026. export * from "babylonjs/Misc/khronosTextureContainer";
  64027. export * from "babylonjs/Misc/observable";
  64028. export * from "babylonjs/Misc/performanceMonitor";
  64029. export * from "babylonjs/Misc/promise";
  64030. export * from "babylonjs/Misc/sceneOptimizer";
  64031. export * from "babylonjs/Misc/sceneSerializer";
  64032. export * from "babylonjs/Misc/smartArray";
  64033. export * from "babylonjs/Misc/stringDictionary";
  64034. export * from "babylonjs/Misc/tags";
  64035. export * from "babylonjs/Misc/textureTools";
  64036. export * from "babylonjs/Misc/tga";
  64037. export * from "babylonjs/Misc/tools";
  64038. export * from "babylonjs/Misc/videoRecorder";
  64039. export * from "babylonjs/Misc/virtualJoystick";
  64040. export * from "babylonjs/Misc/workerPool";
  64041. export * from "babylonjs/Misc/logger";
  64042. export * from "babylonjs/Misc/typeStore";
  64043. export * from "babylonjs/Misc/filesInputStore";
  64044. export * from "babylonjs/Misc/deepCopier";
  64045. export * from "babylonjs/Misc/pivotTools";
  64046. export * from "babylonjs/Misc/precisionDate";
  64047. export * from "babylonjs/Misc/screenshotTools";
  64048. export * from "babylonjs/Misc/typeStore";
  64049. export * from "babylonjs/Misc/webRequest";
  64050. export * from "babylonjs/Misc/iInspectable";
  64051. export * from "babylonjs/Misc/brdfTextureTools";
  64052. export * from "babylonjs/Misc/gradients";
  64053. export * from "babylonjs/Misc/perfCounter";
  64054. export * from "babylonjs/Misc/fileRequest";
  64055. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64056. export * from "babylonjs/Misc/retryStrategy";
  64057. export * from "babylonjs/Misc/loadFileError";
  64058. }
  64059. declare module "babylonjs/index" {
  64060. export * from "babylonjs/abstractScene";
  64061. export * from "babylonjs/Actions/index";
  64062. export * from "babylonjs/Animations/index";
  64063. export * from "babylonjs/assetContainer";
  64064. export * from "babylonjs/Audio/index";
  64065. export * from "babylonjs/Behaviors/index";
  64066. export * from "babylonjs/Bones/index";
  64067. export * from "babylonjs/Cameras/index";
  64068. export * from "babylonjs/Collisions/index";
  64069. export * from "babylonjs/Culling/index";
  64070. export * from "babylonjs/Debug/index";
  64071. export * from "babylonjs/Engines/index";
  64072. export * from "babylonjs/Events/index";
  64073. export * from "babylonjs/Gamepads/index";
  64074. export * from "babylonjs/Gizmos/index";
  64075. export * from "babylonjs/Helpers/index";
  64076. export * from "babylonjs/Instrumentation/index";
  64077. export * from "babylonjs/Layers/index";
  64078. export * from "babylonjs/LensFlares/index";
  64079. export * from "babylonjs/Lights/index";
  64080. export * from "babylonjs/Loading/index";
  64081. export * from "babylonjs/Materials/index";
  64082. export * from "babylonjs/Maths/index";
  64083. export * from "babylonjs/Meshes/index";
  64084. export * from "babylonjs/Morph/index";
  64085. export * from "babylonjs/Navigation/index";
  64086. export * from "babylonjs/node";
  64087. export * from "babylonjs/Offline/index";
  64088. export * from "babylonjs/Particles/index";
  64089. export * from "babylonjs/Physics/index";
  64090. export * from "babylonjs/PostProcesses/index";
  64091. export * from "babylonjs/Probes/index";
  64092. export * from "babylonjs/Rendering/index";
  64093. export * from "babylonjs/scene";
  64094. export * from "babylonjs/sceneComponent";
  64095. export * from "babylonjs/Sprites/index";
  64096. export * from "babylonjs/States/index";
  64097. export * from "babylonjs/Misc/index";
  64098. export * from "babylonjs/types";
  64099. }
  64100. declare module "babylonjs/Animations/pathCursor" {
  64101. import { Vector3 } from "babylonjs/Maths/math.vector";
  64102. import { Path2 } from "babylonjs/Maths/math.path";
  64103. /**
  64104. * A cursor which tracks a point on a path
  64105. */
  64106. export class PathCursor {
  64107. private path;
  64108. /**
  64109. * Stores path cursor callbacks for when an onchange event is triggered
  64110. */
  64111. private _onchange;
  64112. /**
  64113. * The value of the path cursor
  64114. */
  64115. value: number;
  64116. /**
  64117. * The animation array of the path cursor
  64118. */
  64119. animations: Animation[];
  64120. /**
  64121. * Initializes the path cursor
  64122. * @param path The path to track
  64123. */
  64124. constructor(path: Path2);
  64125. /**
  64126. * Gets the cursor point on the path
  64127. * @returns A point on the path cursor at the cursor location
  64128. */
  64129. getPoint(): Vector3;
  64130. /**
  64131. * Moves the cursor ahead by the step amount
  64132. * @param step The amount to move the cursor forward
  64133. * @returns This path cursor
  64134. */
  64135. moveAhead(step?: number): PathCursor;
  64136. /**
  64137. * Moves the cursor behind by the step amount
  64138. * @param step The amount to move the cursor back
  64139. * @returns This path cursor
  64140. */
  64141. moveBack(step?: number): PathCursor;
  64142. /**
  64143. * Moves the cursor by the step amount
  64144. * If the step amount is greater than one, an exception is thrown
  64145. * @param step The amount to move the cursor
  64146. * @returns This path cursor
  64147. */
  64148. move(step: number): PathCursor;
  64149. /**
  64150. * Ensures that the value is limited between zero and one
  64151. * @returns This path cursor
  64152. */
  64153. private ensureLimits;
  64154. /**
  64155. * Runs onchange callbacks on change (used by the animation engine)
  64156. * @returns This path cursor
  64157. */
  64158. private raiseOnChange;
  64159. /**
  64160. * Executes a function on change
  64161. * @param f A path cursor onchange callback
  64162. * @returns This path cursor
  64163. */
  64164. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64165. }
  64166. }
  64167. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64168. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64169. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64170. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64171. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64172. }
  64173. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64174. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64175. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64176. }
  64177. declare module "babylonjs/Engines/Processors/index" {
  64178. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64179. export * from "babylonjs/Engines/Processors/Expressions/index";
  64180. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64181. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64182. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64183. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64184. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64185. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64186. }
  64187. declare module "babylonjs/Legacy/legacy" {
  64188. import * as Babylon from "babylonjs/index";
  64189. export * from "babylonjs/index";
  64190. }
  64191. declare module "babylonjs/Shaders/blur.fragment" {
  64192. /** @hidden */
  64193. export var blurPixelShader: {
  64194. name: string;
  64195. shader: string;
  64196. };
  64197. }
  64198. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64199. /** @hidden */
  64200. export var pointCloudVertexDeclaration: {
  64201. name: string;
  64202. shader: string;
  64203. };
  64204. }
  64205. declare module "babylonjs" {
  64206. export * from "babylonjs/Legacy/legacy";
  64207. }
  64208. declare module BABYLON {
  64209. /** Alias type for value that can be null */
  64210. export type Nullable<T> = T | null;
  64211. /**
  64212. * Alias type for number that are floats
  64213. * @ignorenaming
  64214. */
  64215. export type float = number;
  64216. /**
  64217. * Alias type for number that are doubles.
  64218. * @ignorenaming
  64219. */
  64220. export type double = number;
  64221. /**
  64222. * Alias type for number that are integer
  64223. * @ignorenaming
  64224. */
  64225. export type int = number;
  64226. /** Alias type for number array or Float32Array */
  64227. export type FloatArray = number[] | Float32Array;
  64228. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64229. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64230. /**
  64231. * Alias for types that can be used by a Buffer or VertexBuffer.
  64232. */
  64233. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64234. /**
  64235. * Alias type for primitive types
  64236. * @ignorenaming
  64237. */
  64238. type Primitive = undefined | null | boolean | string | number | Function;
  64239. /**
  64240. * Type modifier to make all the properties of an object Readonly
  64241. */
  64242. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64243. /**
  64244. * Type modifier to make all the properties of an object Readonly recursively
  64245. */
  64246. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64247. /** @hidden */
  64248. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64249. }
  64250. /** @hidden */
  64251. /** @hidden */
  64252. type DeepImmutableObject<T> = {
  64253. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64254. };
  64255. }
  64256. declare module BABYLON {
  64257. /**
  64258. * A class serves as a medium between the observable and its observers
  64259. */
  64260. export class EventState {
  64261. /**
  64262. * Create a new EventState
  64263. * @param mask defines the mask associated with this state
  64264. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64265. * @param target defines the original target of the state
  64266. * @param currentTarget defines the current target of the state
  64267. */
  64268. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64269. /**
  64270. * Initialize the current event state
  64271. * @param mask defines the mask associated with this state
  64272. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64273. * @param target defines the original target of the state
  64274. * @param currentTarget defines the current target of the state
  64275. * @returns the current event state
  64276. */
  64277. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64278. /**
  64279. * An Observer can set this property to true to prevent subsequent observers of being notified
  64280. */
  64281. skipNextObservers: boolean;
  64282. /**
  64283. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64284. */
  64285. mask: number;
  64286. /**
  64287. * The object that originally notified the event
  64288. */
  64289. target?: any;
  64290. /**
  64291. * The current object in the bubbling phase
  64292. */
  64293. currentTarget?: any;
  64294. /**
  64295. * This will be populated with the return value of the last function that was executed.
  64296. * If it is the first function in the callback chain it will be the event data.
  64297. */
  64298. lastReturnValue?: any;
  64299. }
  64300. /**
  64301. * Represent an Observer registered to a given Observable object.
  64302. */
  64303. export class Observer<T> {
  64304. /**
  64305. * Defines the callback to call when the observer is notified
  64306. */
  64307. callback: (eventData: T, eventState: EventState) => void;
  64308. /**
  64309. * Defines the mask of the observer (used to filter notifications)
  64310. */
  64311. mask: number;
  64312. /**
  64313. * Defines the current scope used to restore the JS context
  64314. */
  64315. scope: any;
  64316. /** @hidden */
  64317. _willBeUnregistered: boolean;
  64318. /**
  64319. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64320. */
  64321. unregisterOnNextCall: boolean;
  64322. /**
  64323. * Creates a new observer
  64324. * @param callback defines the callback to call when the observer is notified
  64325. * @param mask defines the mask of the observer (used to filter notifications)
  64326. * @param scope defines the current scope used to restore the JS context
  64327. */
  64328. constructor(
  64329. /**
  64330. * Defines the callback to call when the observer is notified
  64331. */
  64332. callback: (eventData: T, eventState: EventState) => void,
  64333. /**
  64334. * Defines the mask of the observer (used to filter notifications)
  64335. */
  64336. mask: number,
  64337. /**
  64338. * Defines the current scope used to restore the JS context
  64339. */
  64340. scope?: any);
  64341. }
  64342. /**
  64343. * Represent a list of observers registered to multiple Observables object.
  64344. */
  64345. export class MultiObserver<T> {
  64346. private _observers;
  64347. private _observables;
  64348. /**
  64349. * Release associated resources
  64350. */
  64351. dispose(): void;
  64352. /**
  64353. * Raise a callback when one of the observable will notify
  64354. * @param observables defines a list of observables to watch
  64355. * @param callback defines the callback to call on notification
  64356. * @param mask defines the mask used to filter notifications
  64357. * @param scope defines the current scope used to restore the JS context
  64358. * @returns the new MultiObserver
  64359. */
  64360. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64361. }
  64362. /**
  64363. * The Observable class is a simple implementation of the Observable pattern.
  64364. *
  64365. * 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.
  64366. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64367. * 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).
  64368. * 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.
  64369. */
  64370. export class Observable<T> {
  64371. private _observers;
  64372. private _eventState;
  64373. private _onObserverAdded;
  64374. /**
  64375. * Gets the list of observers
  64376. */
  64377. readonly observers: Array<Observer<T>>;
  64378. /**
  64379. * Creates a new observable
  64380. * @param onObserverAdded defines a callback to call when a new observer is added
  64381. */
  64382. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64383. /**
  64384. * Create a new Observer with the specified callback
  64385. * @param callback the callback that will be executed for that Observer
  64386. * @param mask the mask used to filter observers
  64387. * @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.
  64388. * @param scope optional scope for the callback to be called from
  64389. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64390. * @returns the new observer created for the callback
  64391. */
  64392. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64393. /**
  64394. * Create a new Observer with the specified callback and unregisters after the next notification
  64395. * @param callback the callback that will be executed for that Observer
  64396. * @returns the new observer created for the callback
  64397. */
  64398. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64399. /**
  64400. * Remove an Observer from the Observable object
  64401. * @param observer the instance of the Observer to remove
  64402. * @returns false if it doesn't belong to this Observable
  64403. */
  64404. remove(observer: Nullable<Observer<T>>): boolean;
  64405. /**
  64406. * Remove a callback from the Observable object
  64407. * @param callback the callback to remove
  64408. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64409. * @returns false if it doesn't belong to this Observable
  64410. */
  64411. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64412. private _deferUnregister;
  64413. private _remove;
  64414. /**
  64415. * Moves the observable to the top of the observer list making it get called first when notified
  64416. * @param observer the observer to move
  64417. */
  64418. makeObserverTopPriority(observer: Observer<T>): void;
  64419. /**
  64420. * Moves the observable to the bottom of the observer list making it get called last when notified
  64421. * @param observer the observer to move
  64422. */
  64423. makeObserverBottomPriority(observer: Observer<T>): void;
  64424. /**
  64425. * Notify all Observers by calling their respective callback with the given data
  64426. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64427. * @param eventData defines the data to send to all observers
  64428. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64429. * @param target defines the original target of the state
  64430. * @param currentTarget defines the current target of the state
  64431. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64432. */
  64433. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64434. /**
  64435. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64436. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64437. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64438. * and it is crucial that all callbacks will be executed.
  64439. * The order of the callbacks is kept, callbacks are not executed parallel.
  64440. *
  64441. * @param eventData The data to be sent to each callback
  64442. * @param mask is used to filter observers defaults to -1
  64443. * @param target defines the callback target (see EventState)
  64444. * @param currentTarget defines he current object in the bubbling phase
  64445. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64446. */
  64447. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64448. /**
  64449. * Notify a specific observer
  64450. * @param observer defines the observer to notify
  64451. * @param eventData defines the data to be sent to each callback
  64452. * @param mask is used to filter observers defaults to -1
  64453. */
  64454. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64455. /**
  64456. * Gets a boolean indicating if the observable has at least one observer
  64457. * @returns true is the Observable has at least one Observer registered
  64458. */
  64459. hasObservers(): boolean;
  64460. /**
  64461. * Clear the list of observers
  64462. */
  64463. clear(): void;
  64464. /**
  64465. * Clone the current observable
  64466. * @returns a new observable
  64467. */
  64468. clone(): Observable<T>;
  64469. /**
  64470. * Does this observable handles observer registered with a given mask
  64471. * @param mask defines the mask to be tested
  64472. * @return whether or not one observer registered with the given mask is handeled
  64473. **/
  64474. hasSpecificMask(mask?: number): boolean;
  64475. }
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64480. * Babylon.js
  64481. */
  64482. export class DomManagement {
  64483. /**
  64484. * Checks if the window object exists
  64485. * @returns true if the window object exists
  64486. */
  64487. static IsWindowObjectExist(): boolean;
  64488. /**
  64489. * Extracts text content from a DOM element hierarchy
  64490. * @param element defines the root element
  64491. * @returns a string
  64492. */
  64493. static GetDOMTextContent(element: HTMLElement): string;
  64494. }
  64495. }
  64496. declare module BABYLON {
  64497. /**
  64498. * Logger used througouht the application to allow configuration of
  64499. * the log level required for the messages.
  64500. */
  64501. export class Logger {
  64502. /**
  64503. * No log
  64504. */
  64505. static readonly NoneLogLevel: number;
  64506. /**
  64507. * Only message logs
  64508. */
  64509. static readonly MessageLogLevel: number;
  64510. /**
  64511. * Only warning logs
  64512. */
  64513. static readonly WarningLogLevel: number;
  64514. /**
  64515. * Only error logs
  64516. */
  64517. static readonly ErrorLogLevel: number;
  64518. /**
  64519. * All logs
  64520. */
  64521. static readonly AllLogLevel: number;
  64522. private static _LogCache;
  64523. /**
  64524. * Gets a value indicating the number of loading errors
  64525. * @ignorenaming
  64526. */
  64527. static errorsCount: number;
  64528. /**
  64529. * Callback called when a new log is added
  64530. */
  64531. static OnNewCacheEntry: (entry: string) => void;
  64532. private static _AddLogEntry;
  64533. private static _FormatMessage;
  64534. private static _LogDisabled;
  64535. private static _LogEnabled;
  64536. private static _WarnDisabled;
  64537. private static _WarnEnabled;
  64538. private static _ErrorDisabled;
  64539. private static _ErrorEnabled;
  64540. /**
  64541. * Log a message to the console
  64542. */
  64543. static Log: (message: string) => void;
  64544. /**
  64545. * Write a warning message to the console
  64546. */
  64547. static Warn: (message: string) => void;
  64548. /**
  64549. * Write an error message to the console
  64550. */
  64551. static Error: (message: string) => void;
  64552. /**
  64553. * Gets current log cache (list of logs)
  64554. */
  64555. static readonly LogCache: string;
  64556. /**
  64557. * Clears the log cache
  64558. */
  64559. static ClearLogCache(): void;
  64560. /**
  64561. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64562. */
  64563. static LogLevels: number;
  64564. }
  64565. }
  64566. declare module BABYLON {
  64567. /** @hidden */
  64568. export class _TypeStore {
  64569. /** @hidden */
  64570. static RegisteredTypes: {
  64571. [key: string]: Object;
  64572. };
  64573. /** @hidden */
  64574. static GetClass(fqdn: string): any;
  64575. }
  64576. }
  64577. declare module BABYLON {
  64578. /**
  64579. * Class containing a set of static utilities functions for deep copy.
  64580. */
  64581. export class DeepCopier {
  64582. /**
  64583. * Tries to copy an object by duplicating every property
  64584. * @param source defines the source object
  64585. * @param destination defines the target object
  64586. * @param doNotCopyList defines a list of properties to avoid
  64587. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64588. */
  64589. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64590. }
  64591. }
  64592. declare module BABYLON {
  64593. /**
  64594. * Class containing a set of static utilities functions for precision date
  64595. */
  64596. export class PrecisionDate {
  64597. /**
  64598. * Gets either window.performance.now() if supported or Date.now() else
  64599. */
  64600. static readonly Now: number;
  64601. }
  64602. }
  64603. declare module BABYLON {
  64604. /** @hidden */
  64605. export class _DevTools {
  64606. static WarnImport(name: string): string;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64612. */
  64613. export class WebRequest {
  64614. private _xhr;
  64615. /**
  64616. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64617. * i.e. when loading files, where the server/service expects an Authorization header
  64618. */
  64619. static CustomRequestHeaders: {
  64620. [key: string]: string;
  64621. };
  64622. /**
  64623. * Add callback functions in this array to update all the requests before they get sent to the network
  64624. */
  64625. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64626. private _injectCustomRequestHeaders;
  64627. /**
  64628. * Gets or sets a function to be called when loading progress changes
  64629. */
  64630. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64631. /**
  64632. * Returns client's state
  64633. */
  64634. readonly readyState: number;
  64635. /**
  64636. * Returns client's status
  64637. */
  64638. readonly status: number;
  64639. /**
  64640. * Returns client's status as a text
  64641. */
  64642. readonly statusText: string;
  64643. /**
  64644. * Returns client's response
  64645. */
  64646. readonly response: any;
  64647. /**
  64648. * Returns client's response url
  64649. */
  64650. readonly responseURL: string;
  64651. /**
  64652. * Returns client's response as text
  64653. */
  64654. readonly responseText: string;
  64655. /**
  64656. * Gets or sets the expected response type
  64657. */
  64658. responseType: XMLHttpRequestResponseType;
  64659. /** @hidden */
  64660. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64661. /** @hidden */
  64662. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64663. /**
  64664. * Cancels any network activity
  64665. */
  64666. abort(): void;
  64667. /**
  64668. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64669. * @param body defines an optional request body
  64670. */
  64671. send(body?: Document | BodyInit | null): void;
  64672. /**
  64673. * Sets the request method, request URL
  64674. * @param method defines the method to use (GET, POST, etc..)
  64675. * @param url defines the url to connect with
  64676. */
  64677. open(method: string, url: string): void;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /**
  64682. * File request interface
  64683. */
  64684. export interface IFileRequest {
  64685. /**
  64686. * Raised when the request is complete (success or error).
  64687. */
  64688. onCompleteObservable: Observable<IFileRequest>;
  64689. /**
  64690. * Aborts the request for a file.
  64691. */
  64692. abort: () => void;
  64693. }
  64694. }
  64695. declare module BABYLON {
  64696. /**
  64697. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64698. */
  64699. export class PerformanceMonitor {
  64700. private _enabled;
  64701. private _rollingFrameTime;
  64702. private _lastFrameTimeMs;
  64703. /**
  64704. * constructor
  64705. * @param frameSampleSize The number of samples required to saturate the sliding window
  64706. */
  64707. constructor(frameSampleSize?: number);
  64708. /**
  64709. * Samples current frame
  64710. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64711. */
  64712. sampleFrame(timeMs?: number): void;
  64713. /**
  64714. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64715. */
  64716. readonly averageFrameTime: number;
  64717. /**
  64718. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64719. */
  64720. readonly averageFrameTimeVariance: number;
  64721. /**
  64722. * Returns the frame time of the most recent frame
  64723. */
  64724. readonly instantaneousFrameTime: number;
  64725. /**
  64726. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64727. */
  64728. readonly averageFPS: number;
  64729. /**
  64730. * Returns the average framerate in frames per second using the most recent frame time
  64731. */
  64732. readonly instantaneousFPS: number;
  64733. /**
  64734. * Returns true if enough samples have been taken to completely fill the sliding window
  64735. */
  64736. readonly isSaturated: boolean;
  64737. /**
  64738. * Enables contributions to the sliding window sample set
  64739. */
  64740. enable(): void;
  64741. /**
  64742. * Disables contributions to the sliding window sample set
  64743. * Samples will not be interpolated over the disabled period
  64744. */
  64745. disable(): void;
  64746. /**
  64747. * Returns true if sampling is enabled
  64748. */
  64749. readonly isEnabled: boolean;
  64750. /**
  64751. * Resets performance monitor
  64752. */
  64753. reset(): void;
  64754. }
  64755. /**
  64756. * RollingAverage
  64757. *
  64758. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64759. */
  64760. export class RollingAverage {
  64761. /**
  64762. * Current average
  64763. */
  64764. average: number;
  64765. /**
  64766. * Current variance
  64767. */
  64768. variance: number;
  64769. protected _samples: Array<number>;
  64770. protected _sampleCount: number;
  64771. protected _pos: number;
  64772. protected _m2: number;
  64773. /**
  64774. * constructor
  64775. * @param length The number of samples required to saturate the sliding window
  64776. */
  64777. constructor(length: number);
  64778. /**
  64779. * Adds a sample to the sample set
  64780. * @param v The sample value
  64781. */
  64782. add(v: number): void;
  64783. /**
  64784. * Returns previously added values or null if outside of history or outside the sliding window domain
  64785. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64786. * @return Value previously recorded with add() or null if outside of range
  64787. */
  64788. history(i: number): number;
  64789. /**
  64790. * Returns true if enough samples have been taken to completely fill the sliding window
  64791. * @return true if sample-set saturated
  64792. */
  64793. isSaturated(): boolean;
  64794. /**
  64795. * Resets the rolling average (equivalent to 0 samples taken so far)
  64796. */
  64797. reset(): void;
  64798. /**
  64799. * Wraps a value around the sample range boundaries
  64800. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64801. * @return Wrapped position in sample range
  64802. */
  64803. protected _wrapPosition(i: number): number;
  64804. }
  64805. }
  64806. declare module BABYLON {
  64807. /**
  64808. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64809. * The underlying implementation relies on an associative array to ensure the best performances.
  64810. * The value can be anything including 'null' but except 'undefined'
  64811. */
  64812. export class StringDictionary<T> {
  64813. /**
  64814. * This will clear this dictionary and copy the content from the 'source' one.
  64815. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64816. * @param source the dictionary to take the content from and copy to this dictionary
  64817. */
  64818. copyFrom(source: StringDictionary<T>): void;
  64819. /**
  64820. * Get a value based from its key
  64821. * @param key the given key to get the matching value from
  64822. * @return the value if found, otherwise undefined is returned
  64823. */
  64824. get(key: string): T | undefined;
  64825. /**
  64826. * Get a value from its key or add it if it doesn't exist.
  64827. * This method will ensure you that a given key/data will be present in the dictionary.
  64828. * @param key the given key to get the matching value from
  64829. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64830. * The factory will only be invoked if there's no data for the given key.
  64831. * @return the value corresponding to the key.
  64832. */
  64833. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64834. /**
  64835. * Get a value from its key if present in the dictionary otherwise add it
  64836. * @param key the key to get the value from
  64837. * @param val if there's no such key/value pair in the dictionary add it with this value
  64838. * @return the value corresponding to the key
  64839. */
  64840. getOrAdd(key: string, val: T): T;
  64841. /**
  64842. * Check if there's a given key in the dictionary
  64843. * @param key the key to check for
  64844. * @return true if the key is present, false otherwise
  64845. */
  64846. contains(key: string): boolean;
  64847. /**
  64848. * Add a new key and its corresponding value
  64849. * @param key the key to add
  64850. * @param value the value corresponding to the key
  64851. * @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
  64852. */
  64853. add(key: string, value: T): boolean;
  64854. /**
  64855. * Update a specific value associated to a key
  64856. * @param key defines the key to use
  64857. * @param value defines the value to store
  64858. * @returns true if the value was updated (or false if the key was not found)
  64859. */
  64860. set(key: string, value: T): boolean;
  64861. /**
  64862. * Get the element of the given key and remove it from the dictionary
  64863. * @param key defines the key to search
  64864. * @returns the value associated with the key or null if not found
  64865. */
  64866. getAndRemove(key: string): Nullable<T>;
  64867. /**
  64868. * Remove a key/value from the dictionary.
  64869. * @param key the key to remove
  64870. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64871. */
  64872. remove(key: string): boolean;
  64873. /**
  64874. * Clear the whole content of the dictionary
  64875. */
  64876. clear(): void;
  64877. /**
  64878. * Gets the current count
  64879. */
  64880. readonly count: number;
  64881. /**
  64882. * Execute a callback on each key/val of the dictionary.
  64883. * Note that you can remove any element in this dictionary in the callback implementation
  64884. * @param callback the callback to execute on a given key/value pair
  64885. */
  64886. forEach(callback: (key: string, val: T) => void): void;
  64887. /**
  64888. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64889. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64890. * Note that you can remove any element in this dictionary in the callback implementation
  64891. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64892. * @returns the first item
  64893. */
  64894. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64895. private _count;
  64896. private _data;
  64897. }
  64898. }
  64899. declare module BABYLON {
  64900. /**
  64901. * Class used to store gfx data (like WebGLBuffer)
  64902. */
  64903. export class DataBuffer {
  64904. /**
  64905. * Gets or sets the number of objects referencing this buffer
  64906. */
  64907. references: number;
  64908. /** Gets or sets the size of the underlying buffer */
  64909. capacity: number;
  64910. /**
  64911. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64912. */
  64913. is32Bits: boolean;
  64914. /**
  64915. * Gets the underlying buffer
  64916. */
  64917. readonly underlyingResource: any;
  64918. }
  64919. }
  64920. declare module BABYLON {
  64921. /**
  64922. * Class used to store data that will be store in GPU memory
  64923. */
  64924. export class Buffer {
  64925. private _engine;
  64926. private _buffer;
  64927. /** @hidden */
  64928. _data: Nullable<DataArray>;
  64929. private _updatable;
  64930. private _instanced;
  64931. /**
  64932. * Gets the byte stride.
  64933. */
  64934. readonly byteStride: number;
  64935. /**
  64936. * Constructor
  64937. * @param engine the engine
  64938. * @param data the data to use for this buffer
  64939. * @param updatable whether the data is updatable
  64940. * @param stride the stride (optional)
  64941. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64942. * @param instanced whether the buffer is instanced (optional)
  64943. * @param useBytes set to true if the stride in in bytes (optional)
  64944. */
  64945. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64946. /**
  64947. * Create a new VertexBuffer based on the current buffer
  64948. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64949. * @param offset defines offset in the buffer (0 by default)
  64950. * @param size defines the size in floats of attributes (position is 3 for instance)
  64951. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64952. * @param instanced defines if the vertex buffer contains indexed data
  64953. * @param useBytes defines if the offset and stride are in bytes
  64954. * @returns the new vertex buffer
  64955. */
  64956. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64957. /**
  64958. * Gets a boolean indicating if the Buffer is updatable?
  64959. * @returns true if the buffer is updatable
  64960. */
  64961. isUpdatable(): boolean;
  64962. /**
  64963. * Gets current buffer's data
  64964. * @returns a DataArray or null
  64965. */
  64966. getData(): Nullable<DataArray>;
  64967. /**
  64968. * Gets underlying native buffer
  64969. * @returns underlying native buffer
  64970. */
  64971. getBuffer(): Nullable<DataBuffer>;
  64972. /**
  64973. * Gets the stride in float32 units (i.e. byte stride / 4).
  64974. * May not be an integer if the byte stride is not divisible by 4.
  64975. * DEPRECATED. Use byteStride instead.
  64976. * @returns the stride in float32 units
  64977. */
  64978. getStrideSize(): number;
  64979. /**
  64980. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64981. * @param data defines the data to store
  64982. */
  64983. create(data?: Nullable<DataArray>): void;
  64984. /** @hidden */
  64985. _rebuild(): void;
  64986. /**
  64987. * Update current buffer data
  64988. * @param data defines the data to store
  64989. */
  64990. update(data: DataArray): void;
  64991. /**
  64992. * Updates the data directly.
  64993. * @param data the new data
  64994. * @param offset the new offset
  64995. * @param vertexCount the vertex count (optional)
  64996. * @param useBytes set to true if the offset is in bytes
  64997. */
  64998. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64999. /**
  65000. * Release all resources
  65001. */
  65002. dispose(): void;
  65003. }
  65004. /**
  65005. * Specialized buffer used to store vertex data
  65006. */
  65007. export class VertexBuffer {
  65008. /** @hidden */
  65009. _buffer: Buffer;
  65010. private _kind;
  65011. private _size;
  65012. private _ownsBuffer;
  65013. private _instanced;
  65014. private _instanceDivisor;
  65015. /**
  65016. * The byte type.
  65017. */
  65018. static readonly BYTE: number;
  65019. /**
  65020. * The unsigned byte type.
  65021. */
  65022. static readonly UNSIGNED_BYTE: number;
  65023. /**
  65024. * The short type.
  65025. */
  65026. static readonly SHORT: number;
  65027. /**
  65028. * The unsigned short type.
  65029. */
  65030. static readonly UNSIGNED_SHORT: number;
  65031. /**
  65032. * The integer type.
  65033. */
  65034. static readonly INT: number;
  65035. /**
  65036. * The unsigned integer type.
  65037. */
  65038. static readonly UNSIGNED_INT: number;
  65039. /**
  65040. * The float type.
  65041. */
  65042. static readonly FLOAT: number;
  65043. /**
  65044. * Gets or sets the instance divisor when in instanced mode
  65045. */
  65046. instanceDivisor: number;
  65047. /**
  65048. * Gets the byte stride.
  65049. */
  65050. readonly byteStride: number;
  65051. /**
  65052. * Gets the byte offset.
  65053. */
  65054. readonly byteOffset: number;
  65055. /**
  65056. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65057. */
  65058. readonly normalized: boolean;
  65059. /**
  65060. * Gets the data type of each component in the array.
  65061. */
  65062. readonly type: number;
  65063. /**
  65064. * Constructor
  65065. * @param engine the engine
  65066. * @param data the data to use for this vertex buffer
  65067. * @param kind the vertex buffer kind
  65068. * @param updatable whether the data is updatable
  65069. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65070. * @param stride the stride (optional)
  65071. * @param instanced whether the buffer is instanced (optional)
  65072. * @param offset the offset of the data (optional)
  65073. * @param size the number of components (optional)
  65074. * @param type the type of the component (optional)
  65075. * @param normalized whether the data contains normalized data (optional)
  65076. * @param useBytes set to true if stride and offset are in bytes (optional)
  65077. */
  65078. 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);
  65079. /** @hidden */
  65080. _rebuild(): void;
  65081. /**
  65082. * Returns the kind of the VertexBuffer (string)
  65083. * @returns a string
  65084. */
  65085. getKind(): string;
  65086. /**
  65087. * Gets a boolean indicating if the VertexBuffer is updatable?
  65088. * @returns true if the buffer is updatable
  65089. */
  65090. isUpdatable(): boolean;
  65091. /**
  65092. * Gets current buffer's data
  65093. * @returns a DataArray or null
  65094. */
  65095. getData(): Nullable<DataArray>;
  65096. /**
  65097. * Gets underlying native buffer
  65098. * @returns underlying native buffer
  65099. */
  65100. getBuffer(): Nullable<DataBuffer>;
  65101. /**
  65102. * Gets the stride in float32 units (i.e. byte stride / 4).
  65103. * May not be an integer if the byte stride is not divisible by 4.
  65104. * DEPRECATED. Use byteStride instead.
  65105. * @returns the stride in float32 units
  65106. */
  65107. getStrideSize(): number;
  65108. /**
  65109. * Returns the offset as a multiple of the type byte length.
  65110. * DEPRECATED. Use byteOffset instead.
  65111. * @returns the offset in bytes
  65112. */
  65113. getOffset(): number;
  65114. /**
  65115. * Returns the number of components per vertex attribute (integer)
  65116. * @returns the size in float
  65117. */
  65118. getSize(): number;
  65119. /**
  65120. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65121. * @returns true if this buffer is instanced
  65122. */
  65123. getIsInstanced(): boolean;
  65124. /**
  65125. * Returns the instancing divisor, zero for non-instanced (integer).
  65126. * @returns a number
  65127. */
  65128. getInstanceDivisor(): number;
  65129. /**
  65130. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65131. * @param data defines the data to store
  65132. */
  65133. create(data?: DataArray): void;
  65134. /**
  65135. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65136. * This function will create a new buffer if the current one is not updatable
  65137. * @param data defines the data to store
  65138. */
  65139. update(data: DataArray): void;
  65140. /**
  65141. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65142. * Returns the directly updated WebGLBuffer.
  65143. * @param data the new data
  65144. * @param offset the new offset
  65145. * @param useBytes set to true if the offset is in bytes
  65146. */
  65147. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65148. /**
  65149. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65150. */
  65151. dispose(): void;
  65152. /**
  65153. * Enumerates each value of this vertex buffer as numbers.
  65154. * @param count the number of values to enumerate
  65155. * @param callback the callback function called for each value
  65156. */
  65157. forEach(count: number, callback: (value: number, index: number) => void): void;
  65158. /**
  65159. * Positions
  65160. */
  65161. static readonly PositionKind: string;
  65162. /**
  65163. * Normals
  65164. */
  65165. static readonly NormalKind: string;
  65166. /**
  65167. * Tangents
  65168. */
  65169. static readonly TangentKind: string;
  65170. /**
  65171. * Texture coordinates
  65172. */
  65173. static readonly UVKind: string;
  65174. /**
  65175. * Texture coordinates 2
  65176. */
  65177. static readonly UV2Kind: string;
  65178. /**
  65179. * Texture coordinates 3
  65180. */
  65181. static readonly UV3Kind: string;
  65182. /**
  65183. * Texture coordinates 4
  65184. */
  65185. static readonly UV4Kind: string;
  65186. /**
  65187. * Texture coordinates 5
  65188. */
  65189. static readonly UV5Kind: string;
  65190. /**
  65191. * Texture coordinates 6
  65192. */
  65193. static readonly UV6Kind: string;
  65194. /**
  65195. * Colors
  65196. */
  65197. static readonly ColorKind: string;
  65198. /**
  65199. * Matrix indices (for bones)
  65200. */
  65201. static readonly MatricesIndicesKind: string;
  65202. /**
  65203. * Matrix weights (for bones)
  65204. */
  65205. static readonly MatricesWeightsKind: string;
  65206. /**
  65207. * Additional matrix indices (for bones)
  65208. */
  65209. static readonly MatricesIndicesExtraKind: string;
  65210. /**
  65211. * Additional matrix weights (for bones)
  65212. */
  65213. static readonly MatricesWeightsExtraKind: string;
  65214. /**
  65215. * Deduces the stride given a kind.
  65216. * @param kind The kind string to deduce
  65217. * @returns The deduced stride
  65218. */
  65219. static DeduceStride(kind: string): number;
  65220. /**
  65221. * Gets the byte length of the given type.
  65222. * @param type the type
  65223. * @returns the number of bytes
  65224. */
  65225. static GetTypeByteLength(type: number): number;
  65226. /**
  65227. * Enumerates each value of the given parameters as numbers.
  65228. * @param data the data to enumerate
  65229. * @param byteOffset the byte offset of the data
  65230. * @param byteStride the byte stride of the data
  65231. * @param componentCount the number of components per element
  65232. * @param componentType the type of the component
  65233. * @param count the number of values to enumerate
  65234. * @param normalized whether the data is normalized
  65235. * @param callback the callback function called for each value
  65236. */
  65237. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65238. private static _GetFloatValue;
  65239. }
  65240. }
  65241. declare module BABYLON {
  65242. /**
  65243. * Scalar computation library
  65244. */
  65245. export class Scalar {
  65246. /**
  65247. * Two pi constants convenient for computation.
  65248. */
  65249. static TwoPi: number;
  65250. /**
  65251. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65252. * @param a number
  65253. * @param b number
  65254. * @param epsilon (default = 1.401298E-45)
  65255. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65256. */
  65257. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65258. /**
  65259. * Returns a string : the upper case translation of the number i to hexadecimal.
  65260. * @param i number
  65261. * @returns the upper case translation of the number i to hexadecimal.
  65262. */
  65263. static ToHex(i: number): string;
  65264. /**
  65265. * Returns -1 if value is negative and +1 is value is positive.
  65266. * @param value the value
  65267. * @returns the value itself if it's equal to zero.
  65268. */
  65269. static Sign(value: number): number;
  65270. /**
  65271. * Returns the value itself if it's between min and max.
  65272. * Returns min if the value is lower than min.
  65273. * Returns max if the value is greater than max.
  65274. * @param value the value to clmap
  65275. * @param min the min value to clamp to (default: 0)
  65276. * @param max the max value to clamp to (default: 1)
  65277. * @returns the clamped value
  65278. */
  65279. static Clamp(value: number, min?: number, max?: number): number;
  65280. /**
  65281. * the log2 of value.
  65282. * @param value the value to compute log2 of
  65283. * @returns the log2 of value.
  65284. */
  65285. static Log2(value: number): number;
  65286. /**
  65287. * Loops the value, so that it is never larger than length and never smaller than 0.
  65288. *
  65289. * This is similar to the modulo operator but it works with floating point numbers.
  65290. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65291. * With t = 5 and length = 2.5, the result would be 0.0.
  65292. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65293. * @param value the value
  65294. * @param length the length
  65295. * @returns the looped value
  65296. */
  65297. static Repeat(value: number, length: number): number;
  65298. /**
  65299. * Normalize the value between 0.0 and 1.0 using min and max values
  65300. * @param value value to normalize
  65301. * @param min max to normalize between
  65302. * @param max min to normalize between
  65303. * @returns the normalized value
  65304. */
  65305. static Normalize(value: number, min: number, max: number): number;
  65306. /**
  65307. * Denormalize the value from 0.0 and 1.0 using min and max values
  65308. * @param normalized value to denormalize
  65309. * @param min max to denormalize between
  65310. * @param max min to denormalize between
  65311. * @returns the denormalized value
  65312. */
  65313. static Denormalize(normalized: number, min: number, max: number): number;
  65314. /**
  65315. * Calculates the shortest difference between two given angles given in degrees.
  65316. * @param current current angle in degrees
  65317. * @param target target angle in degrees
  65318. * @returns the delta
  65319. */
  65320. static DeltaAngle(current: number, target: number): number;
  65321. /**
  65322. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65323. * @param tx value
  65324. * @param length length
  65325. * @returns The returned value will move back and forth between 0 and length
  65326. */
  65327. static PingPong(tx: number, length: number): number;
  65328. /**
  65329. * Interpolates between min and max with smoothing at the limits.
  65330. *
  65331. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65332. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65333. * @param from from
  65334. * @param to to
  65335. * @param tx value
  65336. * @returns the smooth stepped value
  65337. */
  65338. static SmoothStep(from: number, to: number, tx: number): number;
  65339. /**
  65340. * Moves a value current towards target.
  65341. *
  65342. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65343. * Negative values of maxDelta pushes the value away from target.
  65344. * @param current current value
  65345. * @param target target value
  65346. * @param maxDelta max distance to move
  65347. * @returns resulting value
  65348. */
  65349. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65350. /**
  65351. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65352. *
  65353. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65354. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65355. * @param current current value
  65356. * @param target target value
  65357. * @param maxDelta max distance to move
  65358. * @returns resulting angle
  65359. */
  65360. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65361. /**
  65362. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65363. * @param start start value
  65364. * @param end target value
  65365. * @param amount amount to lerp between
  65366. * @returns the lerped value
  65367. */
  65368. static Lerp(start: number, end: number, amount: number): number;
  65369. /**
  65370. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65371. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65372. * @param start start value
  65373. * @param end target value
  65374. * @param amount amount to lerp between
  65375. * @returns the lerped value
  65376. */
  65377. static LerpAngle(start: number, end: number, amount: number): number;
  65378. /**
  65379. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65380. * @param a start value
  65381. * @param b target value
  65382. * @param value value between a and b
  65383. * @returns the inverseLerp value
  65384. */
  65385. static InverseLerp(a: number, b: number, value: number): number;
  65386. /**
  65387. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65388. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65389. * @param value1 spline value
  65390. * @param tangent1 spline value
  65391. * @param value2 spline value
  65392. * @param tangent2 spline value
  65393. * @param amount input value
  65394. * @returns hermite result
  65395. */
  65396. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65397. /**
  65398. * Returns a random float number between and min and max values
  65399. * @param min min value of random
  65400. * @param max max value of random
  65401. * @returns random value
  65402. */
  65403. static RandomRange(min: number, max: number): number;
  65404. /**
  65405. * This function returns percentage of a number in a given range.
  65406. *
  65407. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65408. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65409. * @param number to convert to percentage
  65410. * @param min min range
  65411. * @param max max range
  65412. * @returns the percentage
  65413. */
  65414. static RangeToPercent(number: number, min: number, max: number): number;
  65415. /**
  65416. * This function returns number that corresponds to the percentage in a given range.
  65417. *
  65418. * PercentToRange(0.34,0,100) will return 34.
  65419. * @param percent to convert to number
  65420. * @param min min range
  65421. * @param max max range
  65422. * @returns the number
  65423. */
  65424. static PercentToRange(percent: number, min: number, max: number): number;
  65425. /**
  65426. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65427. * @param angle The angle to normalize in radian.
  65428. * @return The converted angle.
  65429. */
  65430. static NormalizeRadians(angle: number): number;
  65431. }
  65432. }
  65433. declare module BABYLON {
  65434. /**
  65435. * Constant used to convert a value to gamma space
  65436. * @ignorenaming
  65437. */
  65438. export const ToGammaSpace: number;
  65439. /**
  65440. * Constant used to convert a value to linear space
  65441. * @ignorenaming
  65442. */
  65443. export const ToLinearSpace = 2.2;
  65444. /**
  65445. * Constant used to define the minimal number value in Babylon.js
  65446. * @ignorenaming
  65447. */
  65448. let Epsilon: number;
  65449. }
  65450. declare module BABYLON {
  65451. /**
  65452. * Class used to represent a viewport on screen
  65453. */
  65454. export class Viewport {
  65455. /** viewport left coordinate */
  65456. x: number;
  65457. /** viewport top coordinate */
  65458. y: number;
  65459. /**viewport width */
  65460. width: number;
  65461. /** viewport height */
  65462. height: number;
  65463. /**
  65464. * Creates a Viewport object located at (x, y) and sized (width, height)
  65465. * @param x defines viewport left coordinate
  65466. * @param y defines viewport top coordinate
  65467. * @param width defines the viewport width
  65468. * @param height defines the viewport height
  65469. */
  65470. constructor(
  65471. /** viewport left coordinate */
  65472. x: number,
  65473. /** viewport top coordinate */
  65474. y: number,
  65475. /**viewport width */
  65476. width: number,
  65477. /** viewport height */
  65478. height: number);
  65479. /**
  65480. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65481. * @param renderWidth defines the rendering width
  65482. * @param renderHeight defines the rendering height
  65483. * @returns a new Viewport
  65484. */
  65485. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65486. /**
  65487. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65488. * @param renderWidth defines the rendering width
  65489. * @param renderHeight defines the rendering height
  65490. * @param ref defines the target viewport
  65491. * @returns the current viewport
  65492. */
  65493. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65494. /**
  65495. * Returns a new Viewport copied from the current one
  65496. * @returns a new Viewport
  65497. */
  65498. clone(): Viewport;
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /**
  65503. * Class containing a set of static utilities functions for arrays.
  65504. */
  65505. export class ArrayTools {
  65506. /**
  65507. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65508. * @param size the number of element to construct and put in the array
  65509. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65510. * @returns a new array filled with new objects
  65511. */
  65512. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65513. }
  65514. }
  65515. declare module BABYLON {
  65516. /**
  65517. * @hidden
  65518. */
  65519. export interface IColor4Like {
  65520. r: float;
  65521. g: float;
  65522. b: float;
  65523. a: float;
  65524. }
  65525. /**
  65526. * @hidden
  65527. */
  65528. export interface IColor3Like {
  65529. r: float;
  65530. g: float;
  65531. b: float;
  65532. }
  65533. /**
  65534. * @hidden
  65535. */
  65536. export interface IVector4Like {
  65537. x: float;
  65538. y: float;
  65539. z: float;
  65540. w: float;
  65541. }
  65542. /**
  65543. * @hidden
  65544. */
  65545. export interface IVector3Like {
  65546. x: float;
  65547. y: float;
  65548. z: float;
  65549. }
  65550. /**
  65551. * @hidden
  65552. */
  65553. export interface IVector2Like {
  65554. x: float;
  65555. y: float;
  65556. }
  65557. /**
  65558. * @hidden
  65559. */
  65560. export interface IMatrixLike {
  65561. toArray(): DeepImmutable<Float32Array>;
  65562. updateFlag: int;
  65563. }
  65564. /**
  65565. * @hidden
  65566. */
  65567. export interface IViewportLike {
  65568. x: float;
  65569. y: float;
  65570. width: float;
  65571. height: float;
  65572. }
  65573. /**
  65574. * @hidden
  65575. */
  65576. export interface IPlaneLike {
  65577. normal: IVector3Like;
  65578. d: float;
  65579. normalize(): void;
  65580. }
  65581. }
  65582. declare module BABYLON {
  65583. /**
  65584. * Class representing a vector containing 2 coordinates
  65585. */
  65586. export class Vector2 {
  65587. /** defines the first coordinate */
  65588. x: number;
  65589. /** defines the second coordinate */
  65590. y: number;
  65591. /**
  65592. * Creates a new Vector2 from the given x and y coordinates
  65593. * @param x defines the first coordinate
  65594. * @param y defines the second coordinate
  65595. */
  65596. constructor(
  65597. /** defines the first coordinate */
  65598. x?: number,
  65599. /** defines the second coordinate */
  65600. y?: number);
  65601. /**
  65602. * Gets a string with the Vector2 coordinates
  65603. * @returns a string with the Vector2 coordinates
  65604. */
  65605. toString(): string;
  65606. /**
  65607. * Gets class name
  65608. * @returns the string "Vector2"
  65609. */
  65610. getClassName(): string;
  65611. /**
  65612. * Gets current vector hash code
  65613. * @returns the Vector2 hash code as a number
  65614. */
  65615. getHashCode(): number;
  65616. /**
  65617. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65618. * @param array defines the source array
  65619. * @param index defines the offset in source array
  65620. * @returns the current Vector2
  65621. */
  65622. toArray(array: FloatArray, index?: number): Vector2;
  65623. /**
  65624. * Copy the current vector to an array
  65625. * @returns a new array with 2 elements: the Vector2 coordinates.
  65626. */
  65627. asArray(): number[];
  65628. /**
  65629. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65630. * @param source defines the source Vector2
  65631. * @returns the current updated Vector2
  65632. */
  65633. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65634. /**
  65635. * Sets the Vector2 coordinates with the given floats
  65636. * @param x defines the first coordinate
  65637. * @param y defines the second coordinate
  65638. * @returns the current updated Vector2
  65639. */
  65640. copyFromFloats(x: number, y: number): Vector2;
  65641. /**
  65642. * Sets the Vector2 coordinates with the given floats
  65643. * @param x defines the first coordinate
  65644. * @param y defines the second coordinate
  65645. * @returns the current updated Vector2
  65646. */
  65647. set(x: number, y: number): Vector2;
  65648. /**
  65649. * Add another vector with the current one
  65650. * @param otherVector defines the other vector
  65651. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65652. */
  65653. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65654. /**
  65655. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65656. * @param otherVector defines the other vector
  65657. * @param result defines the target vector
  65658. * @returns the unmodified current Vector2
  65659. */
  65660. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65661. /**
  65662. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65663. * @param otherVector defines the other vector
  65664. * @returns the current updated Vector2
  65665. */
  65666. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65667. /**
  65668. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65669. * @param otherVector defines the other vector
  65670. * @returns a new Vector2
  65671. */
  65672. addVector3(otherVector: Vector3): Vector2;
  65673. /**
  65674. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65675. * @param otherVector defines the other vector
  65676. * @returns a new Vector2
  65677. */
  65678. subtract(otherVector: Vector2): Vector2;
  65679. /**
  65680. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65681. * @param otherVector defines the other vector
  65682. * @param result defines the target vector
  65683. * @returns the unmodified current Vector2
  65684. */
  65685. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65686. /**
  65687. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65688. * @param otherVector defines the other vector
  65689. * @returns the current updated Vector2
  65690. */
  65691. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65692. /**
  65693. * Multiplies in place the current Vector2 coordinates by the given ones
  65694. * @param otherVector defines the other vector
  65695. * @returns the current updated Vector2
  65696. */
  65697. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65698. /**
  65699. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65700. * @param otherVector defines the other vector
  65701. * @returns a new Vector2
  65702. */
  65703. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65704. /**
  65705. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65706. * @param otherVector defines the other vector
  65707. * @param result defines the target vector
  65708. * @returns the unmodified current Vector2
  65709. */
  65710. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65711. /**
  65712. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65713. * @param x defines the first coordinate
  65714. * @param y defines the second coordinate
  65715. * @returns a new Vector2
  65716. */
  65717. multiplyByFloats(x: number, y: number): Vector2;
  65718. /**
  65719. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65720. * @param otherVector defines the other vector
  65721. * @returns a new Vector2
  65722. */
  65723. divide(otherVector: Vector2): Vector2;
  65724. /**
  65725. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65726. * @param otherVector defines the other vector
  65727. * @param result defines the target vector
  65728. * @returns the unmodified current Vector2
  65729. */
  65730. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65731. /**
  65732. * Divides the current Vector2 coordinates by the given ones
  65733. * @param otherVector defines the other vector
  65734. * @returns the current updated Vector2
  65735. */
  65736. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65737. /**
  65738. * Gets a new Vector2 with current Vector2 negated coordinates
  65739. * @returns a new Vector2
  65740. */
  65741. negate(): Vector2;
  65742. /**
  65743. * Multiply the Vector2 coordinates by scale
  65744. * @param scale defines the scaling factor
  65745. * @returns the current updated Vector2
  65746. */
  65747. scaleInPlace(scale: number): Vector2;
  65748. /**
  65749. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65750. * @param scale defines the scaling factor
  65751. * @returns a new Vector2
  65752. */
  65753. scale(scale: number): Vector2;
  65754. /**
  65755. * Scale the current Vector2 values by a factor to a given Vector2
  65756. * @param scale defines the scale factor
  65757. * @param result defines the Vector2 object where to store the result
  65758. * @returns the unmodified current Vector2
  65759. */
  65760. scaleToRef(scale: number, result: Vector2): Vector2;
  65761. /**
  65762. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65763. * @param scale defines the scale factor
  65764. * @param result defines the Vector2 object where to store the result
  65765. * @returns the unmodified current Vector2
  65766. */
  65767. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65768. /**
  65769. * Gets a boolean if two vectors are equals
  65770. * @param otherVector defines the other vector
  65771. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65772. */
  65773. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65774. /**
  65775. * Gets a boolean if two vectors are equals (using an epsilon value)
  65776. * @param otherVector defines the other vector
  65777. * @param epsilon defines the minimal distance to consider equality
  65778. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65779. */
  65780. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65781. /**
  65782. * Gets a new Vector2 from current Vector2 floored values
  65783. * @returns a new Vector2
  65784. */
  65785. floor(): Vector2;
  65786. /**
  65787. * Gets a new Vector2 from current Vector2 floored values
  65788. * @returns a new Vector2
  65789. */
  65790. fract(): Vector2;
  65791. /**
  65792. * Gets the length of the vector
  65793. * @returns the vector length (float)
  65794. */
  65795. length(): number;
  65796. /**
  65797. * Gets the vector squared length
  65798. * @returns the vector squared length (float)
  65799. */
  65800. lengthSquared(): number;
  65801. /**
  65802. * Normalize the vector
  65803. * @returns the current updated Vector2
  65804. */
  65805. normalize(): Vector2;
  65806. /**
  65807. * Gets a new Vector2 copied from the Vector2
  65808. * @returns a new Vector2
  65809. */
  65810. clone(): Vector2;
  65811. /**
  65812. * Gets a new Vector2(0, 0)
  65813. * @returns a new Vector2
  65814. */
  65815. static Zero(): Vector2;
  65816. /**
  65817. * Gets a new Vector2(1, 1)
  65818. * @returns a new Vector2
  65819. */
  65820. static One(): Vector2;
  65821. /**
  65822. * Gets a new Vector2 set from the given index element of the given array
  65823. * @param array defines the data source
  65824. * @param offset defines the offset in the data source
  65825. * @returns a new Vector2
  65826. */
  65827. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65828. /**
  65829. * Sets "result" from the given index element of the given array
  65830. * @param array defines the data source
  65831. * @param offset defines the offset in the data source
  65832. * @param result defines the target vector
  65833. */
  65834. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65835. /**
  65836. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65837. * @param value1 defines 1st point of control
  65838. * @param value2 defines 2nd point of control
  65839. * @param value3 defines 3rd point of control
  65840. * @param value4 defines 4th point of control
  65841. * @param amount defines the interpolation factor
  65842. * @returns a new Vector2
  65843. */
  65844. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65845. /**
  65846. * 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".
  65847. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65848. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65849. * @param value defines the value to clamp
  65850. * @param min defines the lower limit
  65851. * @param max defines the upper limit
  65852. * @returns a new Vector2
  65853. */
  65854. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65855. /**
  65856. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65857. * @param value1 defines the 1st control point
  65858. * @param tangent1 defines the outgoing tangent
  65859. * @param value2 defines the 2nd control point
  65860. * @param tangent2 defines the incoming tangent
  65861. * @param amount defines the interpolation factor
  65862. * @returns a new Vector2
  65863. */
  65864. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65865. /**
  65866. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65867. * @param start defines the start vector
  65868. * @param end defines the end vector
  65869. * @param amount defines the interpolation factor
  65870. * @returns a new Vector2
  65871. */
  65872. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65873. /**
  65874. * Gets the dot product of the vector "left" and the vector "right"
  65875. * @param left defines first vector
  65876. * @param right defines second vector
  65877. * @returns the dot product (float)
  65878. */
  65879. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65880. /**
  65881. * Returns a new Vector2 equal to the normalized given vector
  65882. * @param vector defines the vector to normalize
  65883. * @returns a new Vector2
  65884. */
  65885. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65886. /**
  65887. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65888. * @param left defines 1st vector
  65889. * @param right defines 2nd vector
  65890. * @returns a new Vector2
  65891. */
  65892. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65893. /**
  65894. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65895. * @param left defines 1st vector
  65896. * @param right defines 2nd vector
  65897. * @returns a new Vector2
  65898. */
  65899. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65900. /**
  65901. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65902. * @param vector defines the vector to transform
  65903. * @param transformation defines the matrix to apply
  65904. * @returns a new Vector2
  65905. */
  65906. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65907. /**
  65908. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65909. * @param vector defines the vector to transform
  65910. * @param transformation defines the matrix to apply
  65911. * @param result defines the target vector
  65912. */
  65913. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65914. /**
  65915. * Determines if a given vector is included in a triangle
  65916. * @param p defines the vector to test
  65917. * @param p0 defines 1st triangle point
  65918. * @param p1 defines 2nd triangle point
  65919. * @param p2 defines 3rd triangle point
  65920. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65921. */
  65922. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65923. /**
  65924. * Gets the distance between the vectors "value1" and "value2"
  65925. * @param value1 defines first vector
  65926. * @param value2 defines second vector
  65927. * @returns the distance between vectors
  65928. */
  65929. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65930. /**
  65931. * Returns the squared distance between the vectors "value1" and "value2"
  65932. * @param value1 defines first vector
  65933. * @param value2 defines second vector
  65934. * @returns the squared distance between vectors
  65935. */
  65936. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65937. /**
  65938. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65939. * @param value1 defines first vector
  65940. * @param value2 defines second vector
  65941. * @returns a new Vector2
  65942. */
  65943. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65944. /**
  65945. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65946. * @param p defines the middle point
  65947. * @param segA defines one point of the segment
  65948. * @param segB defines the other point of the segment
  65949. * @returns the shortest distance
  65950. */
  65951. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65952. }
  65953. /**
  65954. * Classed used to store (x,y,z) vector representation
  65955. * A Vector3 is the main object used in 3D geometry
  65956. * It can represent etiher the coordinates of a point the space, either a direction
  65957. * Reminder: js uses a left handed forward facing system
  65958. */
  65959. export class Vector3 {
  65960. /**
  65961. * Defines the first coordinates (on X axis)
  65962. */
  65963. x: number;
  65964. /**
  65965. * Defines the second coordinates (on Y axis)
  65966. */
  65967. y: number;
  65968. /**
  65969. * Defines the third coordinates (on Z axis)
  65970. */
  65971. z: number;
  65972. private static _UpReadOnly;
  65973. private static _ZeroReadOnly;
  65974. /**
  65975. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65976. * @param x defines the first coordinates (on X axis)
  65977. * @param y defines the second coordinates (on Y axis)
  65978. * @param z defines the third coordinates (on Z axis)
  65979. */
  65980. constructor(
  65981. /**
  65982. * Defines the first coordinates (on X axis)
  65983. */
  65984. x?: number,
  65985. /**
  65986. * Defines the second coordinates (on Y axis)
  65987. */
  65988. y?: number,
  65989. /**
  65990. * Defines the third coordinates (on Z axis)
  65991. */
  65992. z?: number);
  65993. /**
  65994. * Creates a string representation of the Vector3
  65995. * @returns a string with the Vector3 coordinates.
  65996. */
  65997. toString(): string;
  65998. /**
  65999. * Gets the class name
  66000. * @returns the string "Vector3"
  66001. */
  66002. getClassName(): string;
  66003. /**
  66004. * Creates the Vector3 hash code
  66005. * @returns a number which tends to be unique between Vector3 instances
  66006. */
  66007. getHashCode(): number;
  66008. /**
  66009. * Creates an array containing three elements : the coordinates of the Vector3
  66010. * @returns a new array of numbers
  66011. */
  66012. asArray(): number[];
  66013. /**
  66014. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66015. * @param array defines the destination array
  66016. * @param index defines the offset in the destination array
  66017. * @returns the current Vector3
  66018. */
  66019. toArray(array: FloatArray, index?: number): Vector3;
  66020. /**
  66021. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66022. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66023. */
  66024. toQuaternion(): Quaternion;
  66025. /**
  66026. * Adds the given vector to the current Vector3
  66027. * @param otherVector defines the second operand
  66028. * @returns the current updated Vector3
  66029. */
  66030. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66031. /**
  66032. * Adds the given coordinates to the current Vector3
  66033. * @param x defines the x coordinate of the operand
  66034. * @param y defines the y coordinate of the operand
  66035. * @param z defines the z coordinate of the operand
  66036. * @returns the current updated Vector3
  66037. */
  66038. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66039. /**
  66040. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66041. * @param otherVector defines the second operand
  66042. * @returns the resulting Vector3
  66043. */
  66044. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66045. /**
  66046. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66047. * @param otherVector defines the second operand
  66048. * @param result defines the Vector3 object where to store the result
  66049. * @returns the current Vector3
  66050. */
  66051. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66052. /**
  66053. * Subtract the given vector from the current Vector3
  66054. * @param otherVector defines the second operand
  66055. * @returns the current updated Vector3
  66056. */
  66057. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66058. /**
  66059. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66060. * @param otherVector defines the second operand
  66061. * @returns the resulting Vector3
  66062. */
  66063. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66064. /**
  66065. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66066. * @param otherVector defines the second operand
  66067. * @param result defines the Vector3 object where to store the result
  66068. * @returns the current Vector3
  66069. */
  66070. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66071. /**
  66072. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66073. * @param x defines the x coordinate of the operand
  66074. * @param y defines the y coordinate of the operand
  66075. * @param z defines the z coordinate of the operand
  66076. * @returns the resulting Vector3
  66077. */
  66078. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66079. /**
  66080. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66081. * @param x defines the x coordinate of the operand
  66082. * @param y defines the y coordinate of the operand
  66083. * @param z defines the z coordinate of the operand
  66084. * @param result defines the Vector3 object where to store the result
  66085. * @returns the current Vector3
  66086. */
  66087. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66088. /**
  66089. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66090. * @returns a new Vector3
  66091. */
  66092. negate(): Vector3;
  66093. /**
  66094. * Multiplies the Vector3 coordinates by the float "scale"
  66095. * @param scale defines the multiplier factor
  66096. * @returns the current updated Vector3
  66097. */
  66098. scaleInPlace(scale: number): Vector3;
  66099. /**
  66100. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66101. * @param scale defines the multiplier factor
  66102. * @returns a new Vector3
  66103. */
  66104. scale(scale: number): Vector3;
  66105. /**
  66106. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66107. * @param scale defines the multiplier factor
  66108. * @param result defines the Vector3 object where to store the result
  66109. * @returns the current Vector3
  66110. */
  66111. scaleToRef(scale: number, result: Vector3): Vector3;
  66112. /**
  66113. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66114. * @param scale defines the scale factor
  66115. * @param result defines the Vector3 object where to store the result
  66116. * @returns the unmodified current Vector3
  66117. */
  66118. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66119. /**
  66120. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66121. * @param otherVector defines the second operand
  66122. * @returns true if both vectors are equals
  66123. */
  66124. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66125. /**
  66126. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66127. * @param otherVector defines the second operand
  66128. * @param epsilon defines the minimal distance to define values as equals
  66129. * @returns true if both vectors are distant less than epsilon
  66130. */
  66131. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66132. /**
  66133. * Returns true if the current Vector3 coordinates equals the given floats
  66134. * @param x defines the x coordinate of the operand
  66135. * @param y defines the y coordinate of the operand
  66136. * @param z defines the z coordinate of the operand
  66137. * @returns true if both vectors are equals
  66138. */
  66139. equalsToFloats(x: number, y: number, z: number): boolean;
  66140. /**
  66141. * Multiplies the current Vector3 coordinates by the given ones
  66142. * @param otherVector defines the second operand
  66143. * @returns the current updated Vector3
  66144. */
  66145. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66146. /**
  66147. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66148. * @param otherVector defines the second operand
  66149. * @returns the new Vector3
  66150. */
  66151. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66152. /**
  66153. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66154. * @param otherVector defines the second operand
  66155. * @param result defines the Vector3 object where to store the result
  66156. * @returns the current Vector3
  66157. */
  66158. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66159. /**
  66160. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66161. * @param x defines the x coordinate of the operand
  66162. * @param y defines the y coordinate of the operand
  66163. * @param z defines the z coordinate of the operand
  66164. * @returns the new Vector3
  66165. */
  66166. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66167. /**
  66168. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66169. * @param otherVector defines the second operand
  66170. * @returns the new Vector3
  66171. */
  66172. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66173. /**
  66174. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66175. * @param otherVector defines the second operand
  66176. * @param result defines the Vector3 object where to store the result
  66177. * @returns the current Vector3
  66178. */
  66179. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66180. /**
  66181. * Divides the current Vector3 coordinates by the given ones.
  66182. * @param otherVector defines the second operand
  66183. * @returns the current updated Vector3
  66184. */
  66185. divideInPlace(otherVector: Vector3): Vector3;
  66186. /**
  66187. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66188. * @param other defines the second operand
  66189. * @returns the current updated Vector3
  66190. */
  66191. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66192. /**
  66193. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66194. * @param other defines the second operand
  66195. * @returns the current updated Vector3
  66196. */
  66197. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66198. /**
  66199. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66200. * @param x defines the x coordinate of the operand
  66201. * @param y defines the y coordinate of the operand
  66202. * @param z defines the z coordinate of the operand
  66203. * @returns the current updated Vector3
  66204. */
  66205. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66206. /**
  66207. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66208. * @param x defines the x coordinate of the operand
  66209. * @param y defines the y coordinate of the operand
  66210. * @param z defines the z coordinate of the operand
  66211. * @returns the current updated Vector3
  66212. */
  66213. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66214. /**
  66215. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66216. * Check if is non uniform within a certain amount of decimal places to account for this
  66217. * @param epsilon the amount the values can differ
  66218. * @returns if the the vector is non uniform to a certain number of decimal places
  66219. */
  66220. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66221. /**
  66222. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66223. */
  66224. readonly isNonUniform: boolean;
  66225. /**
  66226. * Gets a new Vector3 from current Vector3 floored values
  66227. * @returns a new Vector3
  66228. */
  66229. floor(): Vector3;
  66230. /**
  66231. * Gets a new Vector3 from current Vector3 floored values
  66232. * @returns a new Vector3
  66233. */
  66234. fract(): Vector3;
  66235. /**
  66236. * Gets the length of the Vector3
  66237. * @returns the length of the Vector3
  66238. */
  66239. length(): number;
  66240. /**
  66241. * Gets the squared length of the Vector3
  66242. * @returns squared length of the Vector3
  66243. */
  66244. lengthSquared(): number;
  66245. /**
  66246. * Normalize the current Vector3.
  66247. * Please note that this is an in place operation.
  66248. * @returns the current updated Vector3
  66249. */
  66250. normalize(): Vector3;
  66251. /**
  66252. * Reorders the x y z properties of the vector in place
  66253. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66254. * @returns the current updated vector
  66255. */
  66256. reorderInPlace(order: string): this;
  66257. /**
  66258. * Rotates the vector around 0,0,0 by a quaternion
  66259. * @param quaternion the rotation quaternion
  66260. * @param result vector to store the result
  66261. * @returns the resulting vector
  66262. */
  66263. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66264. /**
  66265. * Rotates a vector around a given point
  66266. * @param quaternion the rotation quaternion
  66267. * @param point the point to rotate around
  66268. * @param result vector to store the result
  66269. * @returns the resulting vector
  66270. */
  66271. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66272. /**
  66273. * Normalize the current Vector3 with the given input length.
  66274. * Please note that this is an in place operation.
  66275. * @param len the length of the vector
  66276. * @returns the current updated Vector3
  66277. */
  66278. normalizeFromLength(len: number): Vector3;
  66279. /**
  66280. * Normalize the current Vector3 to a new vector
  66281. * @returns the new Vector3
  66282. */
  66283. normalizeToNew(): Vector3;
  66284. /**
  66285. * Normalize the current Vector3 to the reference
  66286. * @param reference define the Vector3 to update
  66287. * @returns the updated Vector3
  66288. */
  66289. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66290. /**
  66291. * Creates a new Vector3 copied from the current Vector3
  66292. * @returns the new Vector3
  66293. */
  66294. clone(): Vector3;
  66295. /**
  66296. * Copies the given vector coordinates to the current Vector3 ones
  66297. * @param source defines the source Vector3
  66298. * @returns the current updated Vector3
  66299. */
  66300. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66301. /**
  66302. * Copies the given floats to the current Vector3 coordinates
  66303. * @param x defines the x coordinate of the operand
  66304. * @param y defines the y coordinate of the operand
  66305. * @param z defines the z coordinate of the operand
  66306. * @returns the current updated Vector3
  66307. */
  66308. copyFromFloats(x: number, y: number, z: number): Vector3;
  66309. /**
  66310. * Copies the given floats to the current Vector3 coordinates
  66311. * @param x defines the x coordinate of the operand
  66312. * @param y defines the y coordinate of the operand
  66313. * @param z defines the z coordinate of the operand
  66314. * @returns the current updated Vector3
  66315. */
  66316. set(x: number, y: number, z: number): Vector3;
  66317. /**
  66318. * Copies the given float to the current Vector3 coordinates
  66319. * @param v defines the x, y and z coordinates of the operand
  66320. * @returns the current updated Vector3
  66321. */
  66322. setAll(v: number): Vector3;
  66323. /**
  66324. * Get the clip factor between two vectors
  66325. * @param vector0 defines the first operand
  66326. * @param vector1 defines the second operand
  66327. * @param axis defines the axis to use
  66328. * @param size defines the size along the axis
  66329. * @returns the clip factor
  66330. */
  66331. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66332. /**
  66333. * Get angle between two vectors
  66334. * @param vector0 angle between vector0 and vector1
  66335. * @param vector1 angle between vector0 and vector1
  66336. * @param normal direction of the normal
  66337. * @return the angle between vector0 and vector1
  66338. */
  66339. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66340. /**
  66341. * Returns a new Vector3 set from the index "offset" of the given array
  66342. * @param array defines the source array
  66343. * @param offset defines the offset in the source array
  66344. * @returns the new Vector3
  66345. */
  66346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66347. /**
  66348. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66349. * This function is deprecated. Use FromArray instead
  66350. * @param array defines the source array
  66351. * @param offset defines the offset in the source array
  66352. * @returns the new Vector3
  66353. */
  66354. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66355. /**
  66356. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66357. * @param array defines the source array
  66358. * @param offset defines the offset in the source array
  66359. * @param result defines the Vector3 where to store the result
  66360. */
  66361. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66362. /**
  66363. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66364. * This function is deprecated. Use FromArrayToRef instead.
  66365. * @param array defines the source array
  66366. * @param offset defines the offset in the source array
  66367. * @param result defines the Vector3 where to store the result
  66368. */
  66369. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66370. /**
  66371. * Sets the given vector "result" with the given floats.
  66372. * @param x defines the x coordinate of the source
  66373. * @param y defines the y coordinate of the source
  66374. * @param z defines the z coordinate of the source
  66375. * @param result defines the Vector3 where to store the result
  66376. */
  66377. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66378. /**
  66379. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66380. * @returns a new empty Vector3
  66381. */
  66382. static Zero(): Vector3;
  66383. /**
  66384. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66385. * @returns a new unit Vector3
  66386. */
  66387. static One(): Vector3;
  66388. /**
  66389. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66390. * @returns a new up Vector3
  66391. */
  66392. static Up(): Vector3;
  66393. /**
  66394. * Gets a up Vector3 that must not be updated
  66395. */
  66396. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66397. /**
  66398. * Gets a zero Vector3 that must not be updated
  66399. */
  66400. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66401. /**
  66402. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66403. * @returns a new down Vector3
  66404. */
  66405. static Down(): Vector3;
  66406. /**
  66407. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66408. * @returns a new forward Vector3
  66409. */
  66410. static Forward(): Vector3;
  66411. /**
  66412. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66413. * @returns a new forward Vector3
  66414. */
  66415. static Backward(): Vector3;
  66416. /**
  66417. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66418. * @returns a new right Vector3
  66419. */
  66420. static Right(): Vector3;
  66421. /**
  66422. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66423. * @returns a new left Vector3
  66424. */
  66425. static Left(): Vector3;
  66426. /**
  66427. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66428. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66429. * @param vector defines the Vector3 to transform
  66430. * @param transformation defines the transformation matrix
  66431. * @returns the transformed Vector3
  66432. */
  66433. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66434. /**
  66435. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66436. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66437. * @param vector defines the Vector3 to transform
  66438. * @param transformation defines the transformation matrix
  66439. * @param result defines the Vector3 where to store the result
  66440. */
  66441. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66442. /**
  66443. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66444. * This method computes tranformed coordinates only, not transformed direction vectors
  66445. * @param x define the x coordinate of the source vector
  66446. * @param y define the y coordinate of the source vector
  66447. * @param z define the z coordinate of the source vector
  66448. * @param transformation defines the transformation matrix
  66449. * @param result defines the Vector3 where to store the result
  66450. */
  66451. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66452. /**
  66453. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66454. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66455. * @param vector defines the Vector3 to transform
  66456. * @param transformation defines the transformation matrix
  66457. * @returns the new Vector3
  66458. */
  66459. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66460. /**
  66461. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66462. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66463. * @param vector defines the Vector3 to transform
  66464. * @param transformation defines the transformation matrix
  66465. * @param result defines the Vector3 where to store the result
  66466. */
  66467. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66468. /**
  66469. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66470. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66471. * @param x define the x coordinate of the source vector
  66472. * @param y define the y coordinate of the source vector
  66473. * @param z define the z coordinate of the source vector
  66474. * @param transformation defines the transformation matrix
  66475. * @param result defines the Vector3 where to store the result
  66476. */
  66477. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66478. /**
  66479. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66480. * @param value1 defines the first control point
  66481. * @param value2 defines the second control point
  66482. * @param value3 defines the third control point
  66483. * @param value4 defines the fourth control point
  66484. * @param amount defines the amount on the spline to use
  66485. * @returns the new Vector3
  66486. */
  66487. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66488. /**
  66489. * 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"
  66490. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66491. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66492. * @param value defines the current value
  66493. * @param min defines the lower range value
  66494. * @param max defines the upper range value
  66495. * @returns the new Vector3
  66496. */
  66497. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66498. /**
  66499. * 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"
  66500. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66501. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66502. * @param value defines the current value
  66503. * @param min defines the lower range value
  66504. * @param max defines the upper range value
  66505. * @param result defines the Vector3 where to store the result
  66506. */
  66507. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66508. /**
  66509. * Checks if a given vector is inside a specific range
  66510. * @param v defines the vector to test
  66511. * @param min defines the minimum range
  66512. * @param max defines the maximum range
  66513. */
  66514. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66515. /**
  66516. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66517. * @param value1 defines the first control point
  66518. * @param tangent1 defines the first tangent vector
  66519. * @param value2 defines the second control point
  66520. * @param tangent2 defines the second tangent vector
  66521. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66522. * @returns the new Vector3
  66523. */
  66524. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66525. /**
  66526. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66527. * @param start defines the start value
  66528. * @param end defines the end value
  66529. * @param amount max defines amount between both (between 0 and 1)
  66530. * @returns the new Vector3
  66531. */
  66532. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66533. /**
  66534. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66535. * @param start defines the start value
  66536. * @param end defines the end value
  66537. * @param amount max defines amount between both (between 0 and 1)
  66538. * @param result defines the Vector3 where to store the result
  66539. */
  66540. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66541. /**
  66542. * Returns the dot product (float) between the vectors "left" and "right"
  66543. * @param left defines the left operand
  66544. * @param right defines the right operand
  66545. * @returns the dot product
  66546. */
  66547. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66548. /**
  66549. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66550. * The cross product is then orthogonal to both "left" and "right"
  66551. * @param left defines the left operand
  66552. * @param right defines the right operand
  66553. * @returns the cross product
  66554. */
  66555. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66556. /**
  66557. * Sets the given vector "result" with the cross product of "left" and "right"
  66558. * The cross product is then orthogonal to both "left" and "right"
  66559. * @param left defines the left operand
  66560. * @param right defines the right operand
  66561. * @param result defines the Vector3 where to store the result
  66562. */
  66563. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66564. /**
  66565. * Returns a new Vector3 as the normalization of the given vector
  66566. * @param vector defines the Vector3 to normalize
  66567. * @returns the new Vector3
  66568. */
  66569. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66570. /**
  66571. * Sets the given vector "result" with the normalization of the given first vector
  66572. * @param vector defines the Vector3 to normalize
  66573. * @param result defines the Vector3 where to store the result
  66574. */
  66575. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66576. /**
  66577. * Project a Vector3 onto screen space
  66578. * @param vector defines the Vector3 to project
  66579. * @param world defines the world matrix to use
  66580. * @param transform defines the transform (view x projection) matrix to use
  66581. * @param viewport defines the screen viewport to use
  66582. * @returns the new Vector3
  66583. */
  66584. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66585. /** @hidden */
  66586. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66587. /**
  66588. * Unproject from screen space to object space
  66589. * @param source defines the screen space Vector3 to use
  66590. * @param viewportWidth defines the current width of the viewport
  66591. * @param viewportHeight defines the current height of the viewport
  66592. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66593. * @param transform defines the transform (view x projection) matrix to use
  66594. * @returns the new Vector3
  66595. */
  66596. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66597. /**
  66598. * Unproject from screen space to object space
  66599. * @param source defines the screen space Vector3 to use
  66600. * @param viewportWidth defines the current width of the viewport
  66601. * @param viewportHeight defines the current height of the viewport
  66602. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66603. * @param view defines the view matrix to use
  66604. * @param projection defines the projection matrix to use
  66605. * @returns the new Vector3
  66606. */
  66607. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66608. /**
  66609. * Unproject from screen space to object space
  66610. * @param source defines the screen space Vector3 to use
  66611. * @param viewportWidth defines the current width of the viewport
  66612. * @param viewportHeight defines the current height of the viewport
  66613. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66614. * @param view defines the view matrix to use
  66615. * @param projection defines the projection matrix to use
  66616. * @param result defines the Vector3 where to store the result
  66617. */
  66618. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66619. /**
  66620. * Unproject from screen space to object space
  66621. * @param sourceX defines the screen space x coordinate to use
  66622. * @param sourceY defines the screen space y coordinate to use
  66623. * @param sourceZ defines the screen space z coordinate to use
  66624. * @param viewportWidth defines the current width of the viewport
  66625. * @param viewportHeight defines the current height of the viewport
  66626. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66627. * @param view defines the view matrix to use
  66628. * @param projection defines the projection matrix to use
  66629. * @param result defines the Vector3 where to store the result
  66630. */
  66631. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66632. /**
  66633. * Gets the minimal coordinate values between two Vector3
  66634. * @param left defines the first operand
  66635. * @param right defines the second operand
  66636. * @returns the new Vector3
  66637. */
  66638. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66639. /**
  66640. * Gets the maximal coordinate values between two Vector3
  66641. * @param left defines the first operand
  66642. * @param right defines the second operand
  66643. * @returns the new Vector3
  66644. */
  66645. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66646. /**
  66647. * Returns the distance between the vectors "value1" and "value2"
  66648. * @param value1 defines the first operand
  66649. * @param value2 defines the second operand
  66650. * @returns the distance
  66651. */
  66652. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66653. /**
  66654. * Returns the squared distance between the vectors "value1" and "value2"
  66655. * @param value1 defines the first operand
  66656. * @param value2 defines the second operand
  66657. * @returns the squared distance
  66658. */
  66659. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66660. /**
  66661. * Returns a new Vector3 located at the center between "value1" and "value2"
  66662. * @param value1 defines the first operand
  66663. * @param value2 defines the second operand
  66664. * @returns the new Vector3
  66665. */
  66666. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66667. /**
  66668. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66669. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66670. * to something in order to rotate it from its local system to the given target system
  66671. * Note: axis1, axis2 and axis3 are normalized during this operation
  66672. * @param axis1 defines the first axis
  66673. * @param axis2 defines the second axis
  66674. * @param axis3 defines the third axis
  66675. * @returns a new Vector3
  66676. */
  66677. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66678. /**
  66679. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66680. * @param axis1 defines the first axis
  66681. * @param axis2 defines the second axis
  66682. * @param axis3 defines the third axis
  66683. * @param ref defines the Vector3 where to store the result
  66684. */
  66685. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66686. }
  66687. /**
  66688. * Vector4 class created for EulerAngle class conversion to Quaternion
  66689. */
  66690. export class Vector4 {
  66691. /** x value of the vector */
  66692. x: number;
  66693. /** y value of the vector */
  66694. y: number;
  66695. /** z value of the vector */
  66696. z: number;
  66697. /** w value of the vector */
  66698. w: number;
  66699. /**
  66700. * Creates a Vector4 object from the given floats.
  66701. * @param x x value of the vector
  66702. * @param y y value of the vector
  66703. * @param z z value of the vector
  66704. * @param w w value of the vector
  66705. */
  66706. constructor(
  66707. /** x value of the vector */
  66708. x: number,
  66709. /** y value of the vector */
  66710. y: number,
  66711. /** z value of the vector */
  66712. z: number,
  66713. /** w value of the vector */
  66714. w: number);
  66715. /**
  66716. * Returns the string with the Vector4 coordinates.
  66717. * @returns a string containing all the vector values
  66718. */
  66719. toString(): string;
  66720. /**
  66721. * Returns the string "Vector4".
  66722. * @returns "Vector4"
  66723. */
  66724. getClassName(): string;
  66725. /**
  66726. * Returns the Vector4 hash code.
  66727. * @returns a unique hash code
  66728. */
  66729. getHashCode(): number;
  66730. /**
  66731. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66732. * @returns the resulting array
  66733. */
  66734. asArray(): number[];
  66735. /**
  66736. * Populates the given array from the given index with the Vector4 coordinates.
  66737. * @param array array to populate
  66738. * @param index index of the array to start at (default: 0)
  66739. * @returns the Vector4.
  66740. */
  66741. toArray(array: FloatArray, index?: number): Vector4;
  66742. /**
  66743. * Adds the given vector to the current Vector4.
  66744. * @param otherVector the vector to add
  66745. * @returns the updated Vector4.
  66746. */
  66747. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66748. /**
  66749. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66750. * @param otherVector the vector to add
  66751. * @returns the resulting vector
  66752. */
  66753. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66754. /**
  66755. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66756. * @param otherVector the vector to add
  66757. * @param result the vector to store the result
  66758. * @returns the current Vector4.
  66759. */
  66760. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66761. /**
  66762. * Subtract in place the given vector from the current Vector4.
  66763. * @param otherVector the vector to subtract
  66764. * @returns the updated Vector4.
  66765. */
  66766. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66767. /**
  66768. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66769. * @param otherVector the vector to add
  66770. * @returns the new vector with the result
  66771. */
  66772. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66773. /**
  66774. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66775. * @param otherVector the vector to subtract
  66776. * @param result the vector to store the result
  66777. * @returns the current Vector4.
  66778. */
  66779. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66780. /**
  66781. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66782. */
  66783. /**
  66784. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66785. * @param x value to subtract
  66786. * @param y value to subtract
  66787. * @param z value to subtract
  66788. * @param w value to subtract
  66789. * @returns new vector containing the result
  66790. */
  66791. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66792. /**
  66793. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66794. * @param x value to subtract
  66795. * @param y value to subtract
  66796. * @param z value to subtract
  66797. * @param w value to subtract
  66798. * @param result the vector to store the result in
  66799. * @returns the current Vector4.
  66800. */
  66801. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66802. /**
  66803. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66804. * @returns a new vector with the negated values
  66805. */
  66806. negate(): Vector4;
  66807. /**
  66808. * Multiplies the current Vector4 coordinates by scale (float).
  66809. * @param scale the number to scale with
  66810. * @returns the updated Vector4.
  66811. */
  66812. scaleInPlace(scale: number): Vector4;
  66813. /**
  66814. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66815. * @param scale the number to scale with
  66816. * @returns a new vector with the result
  66817. */
  66818. scale(scale: number): Vector4;
  66819. /**
  66820. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66821. * @param scale the number to scale with
  66822. * @param result a vector to store the result in
  66823. * @returns the current Vector4.
  66824. */
  66825. scaleToRef(scale: number, result: Vector4): Vector4;
  66826. /**
  66827. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66828. * @param scale defines the scale factor
  66829. * @param result defines the Vector4 object where to store the result
  66830. * @returns the unmodified current Vector4
  66831. */
  66832. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66833. /**
  66834. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66835. * @param otherVector the vector to compare against
  66836. * @returns true if they are equal
  66837. */
  66838. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66839. /**
  66840. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66841. * @param otherVector vector to compare against
  66842. * @param epsilon (Default: very small number)
  66843. * @returns true if they are equal
  66844. */
  66845. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66846. /**
  66847. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66848. * @param x x value to compare against
  66849. * @param y y value to compare against
  66850. * @param z z value to compare against
  66851. * @param w w value to compare against
  66852. * @returns true if equal
  66853. */
  66854. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66855. /**
  66856. * Multiplies in place the current Vector4 by the given one.
  66857. * @param otherVector vector to multiple with
  66858. * @returns the updated Vector4.
  66859. */
  66860. multiplyInPlace(otherVector: Vector4): Vector4;
  66861. /**
  66862. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66863. * @param otherVector vector to multiple with
  66864. * @returns resulting new vector
  66865. */
  66866. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66867. /**
  66868. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66869. * @param otherVector vector to multiple with
  66870. * @param result vector to store the result
  66871. * @returns the current Vector4.
  66872. */
  66873. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66874. /**
  66875. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66876. * @param x x value multiply with
  66877. * @param y y value multiply with
  66878. * @param z z value multiply with
  66879. * @param w w value multiply with
  66880. * @returns resulting new vector
  66881. */
  66882. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66883. /**
  66884. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66885. * @param otherVector vector to devide with
  66886. * @returns resulting new vector
  66887. */
  66888. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66889. /**
  66890. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66891. * @param otherVector vector to devide with
  66892. * @param result vector to store the result
  66893. * @returns the current Vector4.
  66894. */
  66895. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66896. /**
  66897. * Divides the current Vector3 coordinates by the given ones.
  66898. * @param otherVector vector to devide with
  66899. * @returns the updated Vector3.
  66900. */
  66901. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66902. /**
  66903. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66904. * @param other defines the second operand
  66905. * @returns the current updated Vector4
  66906. */
  66907. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66908. /**
  66909. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66910. * @param other defines the second operand
  66911. * @returns the current updated Vector4
  66912. */
  66913. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66914. /**
  66915. * Gets a new Vector4 from current Vector4 floored values
  66916. * @returns a new Vector4
  66917. */
  66918. floor(): Vector4;
  66919. /**
  66920. * Gets a new Vector4 from current Vector3 floored values
  66921. * @returns a new Vector4
  66922. */
  66923. fract(): Vector4;
  66924. /**
  66925. * Returns the Vector4 length (float).
  66926. * @returns the length
  66927. */
  66928. length(): number;
  66929. /**
  66930. * Returns the Vector4 squared length (float).
  66931. * @returns the length squared
  66932. */
  66933. lengthSquared(): number;
  66934. /**
  66935. * Normalizes in place the Vector4.
  66936. * @returns the updated Vector4.
  66937. */
  66938. normalize(): Vector4;
  66939. /**
  66940. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66941. * @returns this converted to a new vector3
  66942. */
  66943. toVector3(): Vector3;
  66944. /**
  66945. * Returns a new Vector4 copied from the current one.
  66946. * @returns the new cloned vector
  66947. */
  66948. clone(): Vector4;
  66949. /**
  66950. * Updates the current Vector4 with the given one coordinates.
  66951. * @param source the source vector to copy from
  66952. * @returns the updated Vector4.
  66953. */
  66954. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66955. /**
  66956. * Updates the current Vector4 coordinates with the given floats.
  66957. * @param x float to copy from
  66958. * @param y float to copy from
  66959. * @param z float to copy from
  66960. * @param w float to copy from
  66961. * @returns the updated Vector4.
  66962. */
  66963. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66964. /**
  66965. * Updates the current Vector4 coordinates with the given floats.
  66966. * @param x float to set from
  66967. * @param y float to set from
  66968. * @param z float to set from
  66969. * @param w float to set from
  66970. * @returns the updated Vector4.
  66971. */
  66972. set(x: number, y: number, z: number, w: number): Vector4;
  66973. /**
  66974. * Copies the given float to the current Vector3 coordinates
  66975. * @param v defines the x, y, z and w coordinates of the operand
  66976. * @returns the current updated Vector3
  66977. */
  66978. setAll(v: number): Vector4;
  66979. /**
  66980. * Returns a new Vector4 set from the starting index of the given array.
  66981. * @param array the array to pull values from
  66982. * @param offset the offset into the array to start at
  66983. * @returns the new vector
  66984. */
  66985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66986. /**
  66987. * Updates the given vector "result" from the starting index of the given array.
  66988. * @param array the array to pull values from
  66989. * @param offset the offset into the array to start at
  66990. * @param result the vector to store the result in
  66991. */
  66992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66993. /**
  66994. * Updates the given vector "result" from the starting index of the given Float32Array.
  66995. * @param array the array to pull values from
  66996. * @param offset the offset into the array to start at
  66997. * @param result the vector to store the result in
  66998. */
  66999. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67000. /**
  67001. * Updates the given vector "result" coordinates from the given floats.
  67002. * @param x float to set from
  67003. * @param y float to set from
  67004. * @param z float to set from
  67005. * @param w float to set from
  67006. * @param result the vector to the floats in
  67007. */
  67008. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67009. /**
  67010. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67011. * @returns the new vector
  67012. */
  67013. static Zero(): Vector4;
  67014. /**
  67015. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67016. * @returns the new vector
  67017. */
  67018. static One(): Vector4;
  67019. /**
  67020. * Returns a new normalized Vector4 from the given one.
  67021. * @param vector the vector to normalize
  67022. * @returns the vector
  67023. */
  67024. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67025. /**
  67026. * Updates the given vector "result" from the normalization of the given one.
  67027. * @param vector the vector to normalize
  67028. * @param result the vector to store the result in
  67029. */
  67030. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67031. /**
  67032. * Returns a vector with the minimum values from the left and right vectors
  67033. * @param left left vector to minimize
  67034. * @param right right vector to minimize
  67035. * @returns a new vector with the minimum of the left and right vector values
  67036. */
  67037. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67038. /**
  67039. * Returns a vector with the maximum values from the left and right vectors
  67040. * @param left left vector to maximize
  67041. * @param right right vector to maximize
  67042. * @returns a new vector with the maximum of the left and right vector values
  67043. */
  67044. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67045. /**
  67046. * Returns the distance (float) between the vectors "value1" and "value2".
  67047. * @param value1 value to calulate the distance between
  67048. * @param value2 value to calulate the distance between
  67049. * @return the distance between the two vectors
  67050. */
  67051. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67052. /**
  67053. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67054. * @param value1 value to calulate the distance between
  67055. * @param value2 value to calulate the distance between
  67056. * @return the distance between the two vectors squared
  67057. */
  67058. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67059. /**
  67060. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67061. * @param value1 value to calulate the center between
  67062. * @param value2 value to calulate the center between
  67063. * @return the center between the two vectors
  67064. */
  67065. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67066. /**
  67067. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67068. * This methods computes transformed normalized direction vectors only.
  67069. * @param vector the vector to transform
  67070. * @param transformation the transformation matrix to apply
  67071. * @returns the new vector
  67072. */
  67073. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67074. /**
  67075. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67076. * This methods computes transformed normalized direction vectors only.
  67077. * @param vector the vector to transform
  67078. * @param transformation the transformation matrix to apply
  67079. * @param result the vector to store the result in
  67080. */
  67081. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67082. /**
  67083. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67084. * This methods computes transformed normalized direction vectors only.
  67085. * @param x value to transform
  67086. * @param y value to transform
  67087. * @param z value to transform
  67088. * @param w value to transform
  67089. * @param transformation the transformation matrix to apply
  67090. * @param result the vector to store the results in
  67091. */
  67092. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67093. /**
  67094. * Creates a new Vector4 from a Vector3
  67095. * @param source defines the source data
  67096. * @param w defines the 4th component (default is 0)
  67097. * @returns a new Vector4
  67098. */
  67099. static FromVector3(source: Vector3, w?: number): Vector4;
  67100. }
  67101. /**
  67102. * Class used to store quaternion data
  67103. * @see https://en.wikipedia.org/wiki/Quaternion
  67104. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67105. */
  67106. export class Quaternion {
  67107. /** defines the first component (0 by default) */
  67108. x: number;
  67109. /** defines the second component (0 by default) */
  67110. y: number;
  67111. /** defines the third component (0 by default) */
  67112. z: number;
  67113. /** defines the fourth component (1.0 by default) */
  67114. w: number;
  67115. /**
  67116. * Creates a new Quaternion from the given floats
  67117. * @param x defines the first component (0 by default)
  67118. * @param y defines the second component (0 by default)
  67119. * @param z defines the third component (0 by default)
  67120. * @param w defines the fourth component (1.0 by default)
  67121. */
  67122. constructor(
  67123. /** defines the first component (0 by default) */
  67124. x?: number,
  67125. /** defines the second component (0 by default) */
  67126. y?: number,
  67127. /** defines the third component (0 by default) */
  67128. z?: number,
  67129. /** defines the fourth component (1.0 by default) */
  67130. w?: number);
  67131. /**
  67132. * Gets a string representation for the current quaternion
  67133. * @returns a string with the Quaternion coordinates
  67134. */
  67135. toString(): string;
  67136. /**
  67137. * Gets the class name of the quaternion
  67138. * @returns the string "Quaternion"
  67139. */
  67140. getClassName(): string;
  67141. /**
  67142. * Gets a hash code for this quaternion
  67143. * @returns the quaternion hash code
  67144. */
  67145. getHashCode(): number;
  67146. /**
  67147. * Copy the quaternion to an array
  67148. * @returns a new array populated with 4 elements from the quaternion coordinates
  67149. */
  67150. asArray(): number[];
  67151. /**
  67152. * Check if two quaternions are equals
  67153. * @param otherQuaternion defines the second operand
  67154. * @return true if the current quaternion and the given one coordinates are strictly equals
  67155. */
  67156. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67157. /**
  67158. * Clone the current quaternion
  67159. * @returns a new quaternion copied from the current one
  67160. */
  67161. clone(): Quaternion;
  67162. /**
  67163. * Copy a quaternion to the current one
  67164. * @param other defines the other quaternion
  67165. * @returns the updated current quaternion
  67166. */
  67167. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67168. /**
  67169. * Updates the current quaternion with the given float coordinates
  67170. * @param x defines the x coordinate
  67171. * @param y defines the y coordinate
  67172. * @param z defines the z coordinate
  67173. * @param w defines the w coordinate
  67174. * @returns the updated current quaternion
  67175. */
  67176. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67177. /**
  67178. * Updates the current quaternion from the given float coordinates
  67179. * @param x defines the x coordinate
  67180. * @param y defines the y coordinate
  67181. * @param z defines the z coordinate
  67182. * @param w defines the w coordinate
  67183. * @returns the updated current quaternion
  67184. */
  67185. set(x: number, y: number, z: number, w: number): Quaternion;
  67186. /**
  67187. * Adds two quaternions
  67188. * @param other defines the second operand
  67189. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67190. */
  67191. add(other: DeepImmutable<Quaternion>): Quaternion;
  67192. /**
  67193. * Add a quaternion to the current one
  67194. * @param other defines the quaternion to add
  67195. * @returns the current quaternion
  67196. */
  67197. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67198. /**
  67199. * Subtract two quaternions
  67200. * @param other defines the second operand
  67201. * @returns a new quaternion as the subtraction result of the given one from the current one
  67202. */
  67203. subtract(other: Quaternion): Quaternion;
  67204. /**
  67205. * Multiplies the current quaternion by a scale factor
  67206. * @param value defines the scale factor
  67207. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67208. */
  67209. scale(value: number): Quaternion;
  67210. /**
  67211. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67212. * @param scale defines the scale factor
  67213. * @param result defines the Quaternion object where to store the result
  67214. * @returns the unmodified current quaternion
  67215. */
  67216. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67217. /**
  67218. * Multiplies in place the current quaternion by a scale factor
  67219. * @param value defines the scale factor
  67220. * @returns the current modified quaternion
  67221. */
  67222. scaleInPlace(value: number): Quaternion;
  67223. /**
  67224. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67225. * @param scale defines the scale factor
  67226. * @param result defines the Quaternion object where to store the result
  67227. * @returns the unmodified current quaternion
  67228. */
  67229. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67230. /**
  67231. * Multiplies two quaternions
  67232. * @param q1 defines the second operand
  67233. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67234. */
  67235. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67236. /**
  67237. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67238. * @param q1 defines the second operand
  67239. * @param result defines the target quaternion
  67240. * @returns the current quaternion
  67241. */
  67242. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67243. /**
  67244. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67245. * @param q1 defines the second operand
  67246. * @returns the currentupdated quaternion
  67247. */
  67248. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67249. /**
  67250. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67251. * @param ref defines the target quaternion
  67252. * @returns the current quaternion
  67253. */
  67254. conjugateToRef(ref: Quaternion): Quaternion;
  67255. /**
  67256. * Conjugates in place (1-q) the current quaternion
  67257. * @returns the current updated quaternion
  67258. */
  67259. conjugateInPlace(): Quaternion;
  67260. /**
  67261. * Conjugates in place (1-q) the current quaternion
  67262. * @returns a new quaternion
  67263. */
  67264. conjugate(): Quaternion;
  67265. /**
  67266. * Gets length of current quaternion
  67267. * @returns the quaternion length (float)
  67268. */
  67269. length(): number;
  67270. /**
  67271. * Normalize in place the current quaternion
  67272. * @returns the current updated quaternion
  67273. */
  67274. normalize(): Quaternion;
  67275. /**
  67276. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67277. * @param order is a reserved parameter and is ignore for now
  67278. * @returns a new Vector3 containing the Euler angles
  67279. */
  67280. toEulerAngles(order?: string): Vector3;
  67281. /**
  67282. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67283. * @param result defines the vector which will be filled with the Euler angles
  67284. * @param order is a reserved parameter and is ignore for now
  67285. * @returns the current unchanged quaternion
  67286. */
  67287. toEulerAnglesToRef(result: Vector3): Quaternion;
  67288. /**
  67289. * Updates the given rotation matrix with the current quaternion values
  67290. * @param result defines the target matrix
  67291. * @returns the current unchanged quaternion
  67292. */
  67293. toRotationMatrix(result: Matrix): Quaternion;
  67294. /**
  67295. * Updates the current quaternion from the given rotation matrix values
  67296. * @param matrix defines the source matrix
  67297. * @returns the current updated quaternion
  67298. */
  67299. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67300. /**
  67301. * Creates a new quaternion from a rotation matrix
  67302. * @param matrix defines the source matrix
  67303. * @returns a new quaternion created from the given rotation matrix values
  67304. */
  67305. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67306. /**
  67307. * Updates the given quaternion with the given rotation matrix values
  67308. * @param matrix defines the source matrix
  67309. * @param result defines the target quaternion
  67310. */
  67311. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67312. /**
  67313. * Returns the dot product (float) between the quaternions "left" and "right"
  67314. * @param left defines the left operand
  67315. * @param right defines the right operand
  67316. * @returns the dot product
  67317. */
  67318. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67319. /**
  67320. * Checks if the two quaternions are close to each other
  67321. * @param quat0 defines the first quaternion to check
  67322. * @param quat1 defines the second quaternion to check
  67323. * @returns true if the two quaternions are close to each other
  67324. */
  67325. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67326. /**
  67327. * Creates an empty quaternion
  67328. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67329. */
  67330. static Zero(): Quaternion;
  67331. /**
  67332. * Inverse a given quaternion
  67333. * @param q defines the source quaternion
  67334. * @returns a new quaternion as the inverted current quaternion
  67335. */
  67336. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67337. /**
  67338. * Inverse a given quaternion
  67339. * @param q defines the source quaternion
  67340. * @param result the quaternion the result will be stored in
  67341. * @returns the result quaternion
  67342. */
  67343. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67344. /**
  67345. * Creates an identity quaternion
  67346. * @returns the identity quaternion
  67347. */
  67348. static Identity(): Quaternion;
  67349. /**
  67350. * Gets a boolean indicating if the given quaternion is identity
  67351. * @param quaternion defines the quaternion to check
  67352. * @returns true if the quaternion is identity
  67353. */
  67354. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67355. /**
  67356. * Creates a quaternion from a rotation around an axis
  67357. * @param axis defines the axis to use
  67358. * @param angle defines the angle to use
  67359. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67360. */
  67361. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67362. /**
  67363. * Creates a rotation around an axis and stores it into the given quaternion
  67364. * @param axis defines the axis to use
  67365. * @param angle defines the angle to use
  67366. * @param result defines the target quaternion
  67367. * @returns the target quaternion
  67368. */
  67369. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67370. /**
  67371. * Creates a new quaternion from data stored into an array
  67372. * @param array defines the data source
  67373. * @param offset defines the offset in the source array where the data starts
  67374. * @returns a new quaternion
  67375. */
  67376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67377. /**
  67378. * Create a quaternion from Euler rotation angles
  67379. * @param x Pitch
  67380. * @param y Yaw
  67381. * @param z Roll
  67382. * @returns the new Quaternion
  67383. */
  67384. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67385. /**
  67386. * Updates a quaternion from Euler rotation angles
  67387. * @param x Pitch
  67388. * @param y Yaw
  67389. * @param z Roll
  67390. * @param result the quaternion to store the result
  67391. * @returns the updated quaternion
  67392. */
  67393. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67394. /**
  67395. * Create a quaternion from Euler rotation vector
  67396. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67397. * @returns the new Quaternion
  67398. */
  67399. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67400. /**
  67401. * Updates a quaternion from Euler rotation vector
  67402. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67403. * @param result the quaternion to store the result
  67404. * @returns the updated quaternion
  67405. */
  67406. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67407. /**
  67408. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67409. * @param yaw defines the rotation around Y axis
  67410. * @param pitch defines the rotation around X axis
  67411. * @param roll defines the rotation around Z axis
  67412. * @returns the new quaternion
  67413. */
  67414. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67415. /**
  67416. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67417. * @param yaw defines the rotation around Y axis
  67418. * @param pitch defines the rotation around X axis
  67419. * @param roll defines the rotation around Z axis
  67420. * @param result defines the target quaternion
  67421. */
  67422. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67423. /**
  67424. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67425. * @param alpha defines the rotation around first axis
  67426. * @param beta defines the rotation around second axis
  67427. * @param gamma defines the rotation around third axis
  67428. * @returns the new quaternion
  67429. */
  67430. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67431. /**
  67432. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67433. * @param alpha defines the rotation around first axis
  67434. * @param beta defines the rotation around second axis
  67435. * @param gamma defines the rotation around third axis
  67436. * @param result defines the target quaternion
  67437. */
  67438. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67439. /**
  67440. * 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)
  67441. * @param axis1 defines the first axis
  67442. * @param axis2 defines the second axis
  67443. * @param axis3 defines the third axis
  67444. * @returns the new quaternion
  67445. */
  67446. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67447. /**
  67448. * 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
  67449. * @param axis1 defines the first axis
  67450. * @param axis2 defines the second axis
  67451. * @param axis3 defines the third axis
  67452. * @param ref defines the target quaternion
  67453. */
  67454. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67455. /**
  67456. * Interpolates between two quaternions
  67457. * @param left defines first quaternion
  67458. * @param right defines second quaternion
  67459. * @param amount defines the gradient to use
  67460. * @returns the new interpolated quaternion
  67461. */
  67462. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67463. /**
  67464. * Interpolates between two quaternions and stores it into a target quaternion
  67465. * @param left defines first quaternion
  67466. * @param right defines second quaternion
  67467. * @param amount defines the gradient to use
  67468. * @param result defines the target quaternion
  67469. */
  67470. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67471. /**
  67472. * Interpolate between two quaternions using Hermite interpolation
  67473. * @param value1 defines first quaternion
  67474. * @param tangent1 defines the incoming tangent
  67475. * @param value2 defines second quaternion
  67476. * @param tangent2 defines the outgoing tangent
  67477. * @param amount defines the target quaternion
  67478. * @returns the new interpolated quaternion
  67479. */
  67480. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67481. }
  67482. /**
  67483. * Class used to store matrix data (4x4)
  67484. */
  67485. export class Matrix {
  67486. private static _updateFlagSeed;
  67487. private static _identityReadOnly;
  67488. private _isIdentity;
  67489. private _isIdentityDirty;
  67490. private _isIdentity3x2;
  67491. private _isIdentity3x2Dirty;
  67492. /**
  67493. * Gets the update flag of the matrix which is an unique number for the matrix.
  67494. * It will be incremented every time the matrix data change.
  67495. * You can use it to speed the comparison between two versions of the same matrix.
  67496. */
  67497. updateFlag: number;
  67498. private readonly _m;
  67499. /**
  67500. * Gets the internal data of the matrix
  67501. */
  67502. readonly m: DeepImmutable<Float32Array>;
  67503. /** @hidden */
  67504. _markAsUpdated(): void;
  67505. /** @hidden */
  67506. private _updateIdentityStatus;
  67507. /**
  67508. * Creates an empty matrix (filled with zeros)
  67509. */
  67510. constructor();
  67511. /**
  67512. * Check if the current matrix is identity
  67513. * @returns true is the matrix is the identity matrix
  67514. */
  67515. isIdentity(): boolean;
  67516. /**
  67517. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67518. * @returns true is the matrix is the identity matrix
  67519. */
  67520. isIdentityAs3x2(): boolean;
  67521. /**
  67522. * Gets the determinant of the matrix
  67523. * @returns the matrix determinant
  67524. */
  67525. determinant(): number;
  67526. /**
  67527. * Returns the matrix as a Float32Array
  67528. * @returns the matrix underlying array
  67529. */
  67530. toArray(): DeepImmutable<Float32Array>;
  67531. /**
  67532. * Returns the matrix as a Float32Array
  67533. * @returns the matrix underlying array.
  67534. */
  67535. asArray(): DeepImmutable<Float32Array>;
  67536. /**
  67537. * Inverts the current matrix in place
  67538. * @returns the current inverted matrix
  67539. */
  67540. invert(): Matrix;
  67541. /**
  67542. * Sets all the matrix elements to zero
  67543. * @returns the current matrix
  67544. */
  67545. reset(): Matrix;
  67546. /**
  67547. * Adds the current matrix with a second one
  67548. * @param other defines the matrix to add
  67549. * @returns a new matrix as the addition of the current matrix and the given one
  67550. */
  67551. add(other: DeepImmutable<Matrix>): Matrix;
  67552. /**
  67553. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67554. * @param other defines the matrix to add
  67555. * @param result defines the target matrix
  67556. * @returns the current matrix
  67557. */
  67558. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67559. /**
  67560. * Adds in place the given matrix to the current matrix
  67561. * @param other defines the second operand
  67562. * @returns the current updated matrix
  67563. */
  67564. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67565. /**
  67566. * Sets the given matrix to the current inverted Matrix
  67567. * @param other defines the target matrix
  67568. * @returns the unmodified current matrix
  67569. */
  67570. invertToRef(other: Matrix): Matrix;
  67571. /**
  67572. * add a value at the specified position in the current Matrix
  67573. * @param index the index of the value within the matrix. between 0 and 15.
  67574. * @param value the value to be added
  67575. * @returns the current updated matrix
  67576. */
  67577. addAtIndex(index: number, value: number): Matrix;
  67578. /**
  67579. * mutiply the specified position in the current Matrix by a value
  67580. * @param index the index of the value within the matrix. between 0 and 15.
  67581. * @param value the value to be added
  67582. * @returns the current updated matrix
  67583. */
  67584. multiplyAtIndex(index: number, value: number): Matrix;
  67585. /**
  67586. * Inserts the translation vector (using 3 floats) in the current matrix
  67587. * @param x defines the 1st component of the translation
  67588. * @param y defines the 2nd component of the translation
  67589. * @param z defines the 3rd component of the translation
  67590. * @returns the current updated matrix
  67591. */
  67592. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67593. /**
  67594. * Adds the translation vector (using 3 floats) in the current matrix
  67595. * @param x defines the 1st component of the translation
  67596. * @param y defines the 2nd component of the translation
  67597. * @param z defines the 3rd component of the translation
  67598. * @returns the current updated matrix
  67599. */
  67600. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67601. /**
  67602. * Inserts the translation vector in the current matrix
  67603. * @param vector3 defines the translation to insert
  67604. * @returns the current updated matrix
  67605. */
  67606. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67607. /**
  67608. * Gets the translation value of the current matrix
  67609. * @returns a new Vector3 as the extracted translation from the matrix
  67610. */
  67611. getTranslation(): Vector3;
  67612. /**
  67613. * Fill a Vector3 with the extracted translation from the matrix
  67614. * @param result defines the Vector3 where to store the translation
  67615. * @returns the current matrix
  67616. */
  67617. getTranslationToRef(result: Vector3): Matrix;
  67618. /**
  67619. * Remove rotation and scaling part from the matrix
  67620. * @returns the updated matrix
  67621. */
  67622. removeRotationAndScaling(): Matrix;
  67623. /**
  67624. * Multiply two matrices
  67625. * @param other defines the second operand
  67626. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67627. */
  67628. multiply(other: DeepImmutable<Matrix>): Matrix;
  67629. /**
  67630. * Copy the current matrix from the given one
  67631. * @param other defines the source matrix
  67632. * @returns the current updated matrix
  67633. */
  67634. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67635. /**
  67636. * Populates the given array from the starting index with the current matrix values
  67637. * @param array defines the target array
  67638. * @param offset defines the offset in the target array where to start storing values
  67639. * @returns the current matrix
  67640. */
  67641. copyToArray(array: Float32Array, offset?: number): Matrix;
  67642. /**
  67643. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67644. * @param other defines the second operand
  67645. * @param result defines the matrix where to store the multiplication
  67646. * @returns the current matrix
  67647. */
  67648. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67649. /**
  67650. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67651. * @param other defines the second operand
  67652. * @param result defines the array where to store the multiplication
  67653. * @param offset defines the offset in the target array where to start storing values
  67654. * @returns the current matrix
  67655. */
  67656. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67657. /**
  67658. * Check equality between this matrix and a second one
  67659. * @param value defines the second matrix to compare
  67660. * @returns true is the current matrix and the given one values are strictly equal
  67661. */
  67662. equals(value: DeepImmutable<Matrix>): boolean;
  67663. /**
  67664. * Clone the current matrix
  67665. * @returns a new matrix from the current matrix
  67666. */
  67667. clone(): Matrix;
  67668. /**
  67669. * Returns the name of the current matrix class
  67670. * @returns the string "Matrix"
  67671. */
  67672. getClassName(): string;
  67673. /**
  67674. * Gets the hash code of the current matrix
  67675. * @returns the hash code
  67676. */
  67677. getHashCode(): number;
  67678. /**
  67679. * Decomposes the current Matrix into a translation, rotation and scaling components
  67680. * @param scale defines the scale vector3 given as a reference to update
  67681. * @param rotation defines the rotation quaternion given as a reference to update
  67682. * @param translation defines the translation vector3 given as a reference to update
  67683. * @returns true if operation was successful
  67684. */
  67685. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67686. /**
  67687. * Gets specific row of the matrix
  67688. * @param index defines the number of the row to get
  67689. * @returns the index-th row of the current matrix as a new Vector4
  67690. */
  67691. getRow(index: number): Nullable<Vector4>;
  67692. /**
  67693. * Sets the index-th row of the current matrix to the vector4 values
  67694. * @param index defines the number of the row to set
  67695. * @param row defines the target vector4
  67696. * @returns the updated current matrix
  67697. */
  67698. setRow(index: number, row: Vector4): Matrix;
  67699. /**
  67700. * Compute the transpose of the matrix
  67701. * @returns the new transposed matrix
  67702. */
  67703. transpose(): Matrix;
  67704. /**
  67705. * Compute the transpose of the matrix and store it in a given matrix
  67706. * @param result defines the target matrix
  67707. * @returns the current matrix
  67708. */
  67709. transposeToRef(result: Matrix): Matrix;
  67710. /**
  67711. * Sets the index-th row of the current matrix with the given 4 x float values
  67712. * @param index defines the row index
  67713. * @param x defines the x component to set
  67714. * @param y defines the y component to set
  67715. * @param z defines the z component to set
  67716. * @param w defines the w component to set
  67717. * @returns the updated current matrix
  67718. */
  67719. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67720. /**
  67721. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67722. * @param scale defines the scale factor
  67723. * @returns a new matrix
  67724. */
  67725. scale(scale: number): Matrix;
  67726. /**
  67727. * Scale the current matrix values by a factor to a given result matrix
  67728. * @param scale defines the scale factor
  67729. * @param result defines the matrix to store the result
  67730. * @returns the current matrix
  67731. */
  67732. scaleToRef(scale: number, result: Matrix): Matrix;
  67733. /**
  67734. * Scale the current matrix values by a factor and add the result to a given matrix
  67735. * @param scale defines the scale factor
  67736. * @param result defines the Matrix to store the result
  67737. * @returns the current matrix
  67738. */
  67739. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67740. /**
  67741. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67742. * @param ref matrix to store the result
  67743. */
  67744. toNormalMatrix(ref: Matrix): void;
  67745. /**
  67746. * Gets only rotation part of the current matrix
  67747. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67748. */
  67749. getRotationMatrix(): Matrix;
  67750. /**
  67751. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67752. * @param result defines the target matrix to store data to
  67753. * @returns the current matrix
  67754. */
  67755. getRotationMatrixToRef(result: Matrix): Matrix;
  67756. /**
  67757. * Toggles model matrix from being right handed to left handed in place and vice versa
  67758. */
  67759. toggleModelMatrixHandInPlace(): void;
  67760. /**
  67761. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67762. */
  67763. toggleProjectionMatrixHandInPlace(): void;
  67764. /**
  67765. * Creates a matrix from an array
  67766. * @param array defines the source array
  67767. * @param offset defines an offset in the source array
  67768. * @returns a new Matrix set from the starting index of the given array
  67769. */
  67770. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67771. /**
  67772. * Copy the content of an array into a given matrix
  67773. * @param array defines the source array
  67774. * @param offset defines an offset in the source array
  67775. * @param result defines the target matrix
  67776. */
  67777. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67778. /**
  67779. * Stores an array into a matrix after having multiplied each component by a given factor
  67780. * @param array defines the source array
  67781. * @param offset defines the offset in the source array
  67782. * @param scale defines the scaling factor
  67783. * @param result defines the target matrix
  67784. */
  67785. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67786. /**
  67787. * Gets an identity matrix that must not be updated
  67788. */
  67789. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67790. /**
  67791. * Stores a list of values (16) inside a given matrix
  67792. * @param initialM11 defines 1st value of 1st row
  67793. * @param initialM12 defines 2nd value of 1st row
  67794. * @param initialM13 defines 3rd value of 1st row
  67795. * @param initialM14 defines 4th value of 1st row
  67796. * @param initialM21 defines 1st value of 2nd row
  67797. * @param initialM22 defines 2nd value of 2nd row
  67798. * @param initialM23 defines 3rd value of 2nd row
  67799. * @param initialM24 defines 4th value of 2nd row
  67800. * @param initialM31 defines 1st value of 3rd row
  67801. * @param initialM32 defines 2nd value of 3rd row
  67802. * @param initialM33 defines 3rd value of 3rd row
  67803. * @param initialM34 defines 4th value of 3rd row
  67804. * @param initialM41 defines 1st value of 4th row
  67805. * @param initialM42 defines 2nd value of 4th row
  67806. * @param initialM43 defines 3rd value of 4th row
  67807. * @param initialM44 defines 4th value of 4th row
  67808. * @param result defines the target matrix
  67809. */
  67810. 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;
  67811. /**
  67812. * Creates new matrix from a list of values (16)
  67813. * @param initialM11 defines 1st value of 1st row
  67814. * @param initialM12 defines 2nd value of 1st row
  67815. * @param initialM13 defines 3rd value of 1st row
  67816. * @param initialM14 defines 4th value of 1st row
  67817. * @param initialM21 defines 1st value of 2nd row
  67818. * @param initialM22 defines 2nd value of 2nd row
  67819. * @param initialM23 defines 3rd value of 2nd row
  67820. * @param initialM24 defines 4th value of 2nd row
  67821. * @param initialM31 defines 1st value of 3rd row
  67822. * @param initialM32 defines 2nd value of 3rd row
  67823. * @param initialM33 defines 3rd value of 3rd row
  67824. * @param initialM34 defines 4th value of 3rd row
  67825. * @param initialM41 defines 1st value of 4th row
  67826. * @param initialM42 defines 2nd value of 4th row
  67827. * @param initialM43 defines 3rd value of 4th row
  67828. * @param initialM44 defines 4th value of 4th row
  67829. * @returns the new matrix
  67830. */
  67831. 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;
  67832. /**
  67833. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67834. * @param scale defines the scale vector3
  67835. * @param rotation defines the rotation quaternion
  67836. * @param translation defines the translation vector3
  67837. * @returns a new matrix
  67838. */
  67839. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67840. /**
  67841. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67842. * @param scale defines the scale vector3
  67843. * @param rotation defines the rotation quaternion
  67844. * @param translation defines the translation vector3
  67845. * @param result defines the target matrix
  67846. */
  67847. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67848. /**
  67849. * Creates a new identity matrix
  67850. * @returns a new identity matrix
  67851. */
  67852. static Identity(): Matrix;
  67853. /**
  67854. * Creates a new identity matrix and stores the result in a given matrix
  67855. * @param result defines the target matrix
  67856. */
  67857. static IdentityToRef(result: Matrix): void;
  67858. /**
  67859. * Creates a new zero matrix
  67860. * @returns a new zero matrix
  67861. */
  67862. static Zero(): Matrix;
  67863. /**
  67864. * Creates a new rotation matrix for "angle" radians around the X axis
  67865. * @param angle defines the angle (in radians) to use
  67866. * @return the new matrix
  67867. */
  67868. static RotationX(angle: number): Matrix;
  67869. /**
  67870. * Creates a new matrix as the invert of a given matrix
  67871. * @param source defines the source matrix
  67872. * @returns the new matrix
  67873. */
  67874. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67875. /**
  67876. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67877. * @param angle defines the angle (in radians) to use
  67878. * @param result defines the target matrix
  67879. */
  67880. static RotationXToRef(angle: number, result: Matrix): void;
  67881. /**
  67882. * Creates a new rotation matrix for "angle" radians around the Y axis
  67883. * @param angle defines the angle (in radians) to use
  67884. * @return the new matrix
  67885. */
  67886. static RotationY(angle: number): Matrix;
  67887. /**
  67888. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67889. * @param angle defines the angle (in radians) to use
  67890. * @param result defines the target matrix
  67891. */
  67892. static RotationYToRef(angle: number, result: Matrix): void;
  67893. /**
  67894. * Creates a new rotation matrix for "angle" radians around the Z axis
  67895. * @param angle defines the angle (in radians) to use
  67896. * @return the new matrix
  67897. */
  67898. static RotationZ(angle: number): Matrix;
  67899. /**
  67900. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67901. * @param angle defines the angle (in radians) to use
  67902. * @param result defines the target matrix
  67903. */
  67904. static RotationZToRef(angle: number, result: Matrix): void;
  67905. /**
  67906. * Creates a new rotation matrix for "angle" radians around the given axis
  67907. * @param axis defines the axis to use
  67908. * @param angle defines the angle (in radians) to use
  67909. * @return the new matrix
  67910. */
  67911. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67912. /**
  67913. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67914. * @param axis defines the axis to use
  67915. * @param angle defines the angle (in radians) to use
  67916. * @param result defines the target matrix
  67917. */
  67918. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67919. /**
  67920. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67921. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67922. * @param from defines the vector to align
  67923. * @param to defines the vector to align to
  67924. * @param result defines the target matrix
  67925. */
  67926. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67927. /**
  67928. * Creates a rotation matrix
  67929. * @param yaw defines the yaw angle in radians (Y axis)
  67930. * @param pitch defines the pitch angle in radians (X axis)
  67931. * @param roll defines the roll angle in radians (X axis)
  67932. * @returns the new rotation matrix
  67933. */
  67934. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67935. /**
  67936. * Creates a rotation matrix and stores it in a given matrix
  67937. * @param yaw defines the yaw angle in radians (Y axis)
  67938. * @param pitch defines the pitch angle in radians (X axis)
  67939. * @param roll defines the roll angle in radians (X axis)
  67940. * @param result defines the target matrix
  67941. */
  67942. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67943. /**
  67944. * Creates a scaling matrix
  67945. * @param x defines the scale factor on X axis
  67946. * @param y defines the scale factor on Y axis
  67947. * @param z defines the scale factor on Z axis
  67948. * @returns the new matrix
  67949. */
  67950. static Scaling(x: number, y: number, z: number): Matrix;
  67951. /**
  67952. * Creates a scaling matrix and stores it in a given matrix
  67953. * @param x defines the scale factor on X axis
  67954. * @param y defines the scale factor on Y axis
  67955. * @param z defines the scale factor on Z axis
  67956. * @param result defines the target matrix
  67957. */
  67958. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67959. /**
  67960. * Creates a translation matrix
  67961. * @param x defines the translation on X axis
  67962. * @param y defines the translation on Y axis
  67963. * @param z defines the translationon Z axis
  67964. * @returns the new matrix
  67965. */
  67966. static Translation(x: number, y: number, z: number): Matrix;
  67967. /**
  67968. * Creates a translation matrix and stores it in a given matrix
  67969. * @param x defines the translation on X axis
  67970. * @param y defines the translation on Y axis
  67971. * @param z defines the translationon Z axis
  67972. * @param result defines the target matrix
  67973. */
  67974. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67975. /**
  67976. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67977. * @param startValue defines the start value
  67978. * @param endValue defines the end value
  67979. * @param gradient defines the gradient factor
  67980. * @returns the new matrix
  67981. */
  67982. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67983. /**
  67984. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67985. * @param startValue defines the start value
  67986. * @param endValue defines the end value
  67987. * @param gradient defines the gradient factor
  67988. * @param result defines the Matrix object where to store data
  67989. */
  67990. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67991. /**
  67992. * Builds a new matrix whose values are computed by:
  67993. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67994. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67995. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67996. * @param startValue defines the first matrix
  67997. * @param endValue defines the second matrix
  67998. * @param gradient defines the gradient between the two matrices
  67999. * @returns the new matrix
  68000. */
  68001. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68002. /**
  68003. * Update a matrix to values which are computed by:
  68004. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68005. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68006. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68007. * @param startValue defines the first matrix
  68008. * @param endValue defines the second matrix
  68009. * @param gradient defines the gradient between the two matrices
  68010. * @param result defines the target matrix
  68011. */
  68012. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68013. /**
  68014. * 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"
  68015. * This function works in left handed mode
  68016. * @param eye defines the final position of the entity
  68017. * @param target defines where the entity should look at
  68018. * @param up defines the up vector for the entity
  68019. * @returns the new matrix
  68020. */
  68021. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68022. /**
  68023. * 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".
  68024. * This function works in left handed mode
  68025. * @param eye defines the final position of the entity
  68026. * @param target defines where the entity should look at
  68027. * @param up defines the up vector for the entity
  68028. * @param result defines the target matrix
  68029. */
  68030. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68031. /**
  68032. * 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"
  68033. * This function works in right handed mode
  68034. * @param eye defines the final position of the entity
  68035. * @param target defines where the entity should look at
  68036. * @param up defines the up vector for the entity
  68037. * @returns the new matrix
  68038. */
  68039. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68040. /**
  68041. * 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".
  68042. * This function works in right handed mode
  68043. * @param eye defines the final position of the entity
  68044. * @param target defines where the entity should look at
  68045. * @param up defines the up vector for the entity
  68046. * @param result defines the target matrix
  68047. */
  68048. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68049. /**
  68050. * Create a left-handed orthographic projection matrix
  68051. * @param width defines the viewport width
  68052. * @param height defines the viewport height
  68053. * @param znear defines the near clip plane
  68054. * @param zfar defines the far clip plane
  68055. * @returns a new matrix as a left-handed orthographic projection matrix
  68056. */
  68057. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68058. /**
  68059. * Store a left-handed orthographic projection to a given matrix
  68060. * @param width defines the viewport width
  68061. * @param height defines the viewport height
  68062. * @param znear defines the near clip plane
  68063. * @param zfar defines the far clip plane
  68064. * @param result defines the target matrix
  68065. */
  68066. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68067. /**
  68068. * Create a left-handed orthographic projection matrix
  68069. * @param left defines the viewport left coordinate
  68070. * @param right defines the viewport right coordinate
  68071. * @param bottom defines the viewport bottom coordinate
  68072. * @param top defines the viewport top coordinate
  68073. * @param znear defines the near clip plane
  68074. * @param zfar defines the far clip plane
  68075. * @returns a new matrix as a left-handed orthographic projection matrix
  68076. */
  68077. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68078. /**
  68079. * Stores a left-handed orthographic projection into a given matrix
  68080. * @param left defines the viewport left coordinate
  68081. * @param right defines the viewport right coordinate
  68082. * @param bottom defines the viewport bottom coordinate
  68083. * @param top defines the viewport top coordinate
  68084. * @param znear defines the near clip plane
  68085. * @param zfar defines the far clip plane
  68086. * @param result defines the target matrix
  68087. */
  68088. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68089. /**
  68090. * Creates a right-handed orthographic projection matrix
  68091. * @param left defines the viewport left coordinate
  68092. * @param right defines the viewport right coordinate
  68093. * @param bottom defines the viewport bottom coordinate
  68094. * @param top defines the viewport top coordinate
  68095. * @param znear defines the near clip plane
  68096. * @param zfar defines the far clip plane
  68097. * @returns a new matrix as a right-handed orthographic projection matrix
  68098. */
  68099. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68100. /**
  68101. * Stores a right-handed orthographic projection into a given matrix
  68102. * @param left defines the viewport left coordinate
  68103. * @param right defines the viewport right coordinate
  68104. * @param bottom defines the viewport bottom coordinate
  68105. * @param top defines the viewport top coordinate
  68106. * @param znear defines the near clip plane
  68107. * @param zfar defines the far clip plane
  68108. * @param result defines the target matrix
  68109. */
  68110. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68111. /**
  68112. * Creates a left-handed perspective projection matrix
  68113. * @param width defines the viewport width
  68114. * @param height defines the viewport height
  68115. * @param znear defines the near clip plane
  68116. * @param zfar defines the far clip plane
  68117. * @returns a new matrix as a left-handed perspective projection matrix
  68118. */
  68119. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68120. /**
  68121. * Creates a left-handed perspective projection matrix
  68122. * @param fov defines the horizontal field of view
  68123. * @param aspect defines the aspect ratio
  68124. * @param znear defines the near clip plane
  68125. * @param zfar defines the far clip plane
  68126. * @returns a new matrix as a left-handed perspective projection matrix
  68127. */
  68128. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68129. /**
  68130. * Stores a left-handed perspective projection into a given matrix
  68131. * @param fov defines the horizontal field of view
  68132. * @param aspect defines the aspect ratio
  68133. * @param znear defines the near clip plane
  68134. * @param zfar defines the far clip plane
  68135. * @param result defines the target matrix
  68136. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68137. */
  68138. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68139. /**
  68140. * Creates a right-handed perspective projection matrix
  68141. * @param fov defines the horizontal field of view
  68142. * @param aspect defines the aspect ratio
  68143. * @param znear defines the near clip plane
  68144. * @param zfar defines the far clip plane
  68145. * @returns a new matrix as a right-handed perspective projection matrix
  68146. */
  68147. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68148. /**
  68149. * Stores a right-handed perspective projection into a given matrix
  68150. * @param fov defines the horizontal field of view
  68151. * @param aspect defines the aspect ratio
  68152. * @param znear defines the near clip plane
  68153. * @param zfar defines the far clip plane
  68154. * @param result defines the target matrix
  68155. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68156. */
  68157. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68158. /**
  68159. * Stores a perspective projection for WebVR info a given matrix
  68160. * @param fov defines the field of view
  68161. * @param znear defines the near clip plane
  68162. * @param zfar defines the far clip plane
  68163. * @param result defines the target matrix
  68164. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68165. */
  68166. static PerspectiveFovWebVRToRef(fov: {
  68167. upDegrees: number;
  68168. downDegrees: number;
  68169. leftDegrees: number;
  68170. rightDegrees: number;
  68171. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68172. /**
  68173. * Computes a complete transformation matrix
  68174. * @param viewport defines the viewport to use
  68175. * @param world defines the world matrix
  68176. * @param view defines the view matrix
  68177. * @param projection defines the projection matrix
  68178. * @param zmin defines the near clip plane
  68179. * @param zmax defines the far clip plane
  68180. * @returns the transformation matrix
  68181. */
  68182. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68183. /**
  68184. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68185. * @param matrix defines the matrix to use
  68186. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68187. */
  68188. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68189. /**
  68190. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68191. * @param matrix defines the matrix to use
  68192. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68193. */
  68194. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68195. /**
  68196. * Compute the transpose of a given matrix
  68197. * @param matrix defines the matrix to transpose
  68198. * @returns the new matrix
  68199. */
  68200. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68201. /**
  68202. * Compute the transpose of a matrix and store it in a target matrix
  68203. * @param matrix defines the matrix to transpose
  68204. * @param result defines the target matrix
  68205. */
  68206. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68207. /**
  68208. * Computes a reflection matrix from a plane
  68209. * @param plane defines the reflection plane
  68210. * @returns a new matrix
  68211. */
  68212. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68213. /**
  68214. * Computes a reflection matrix from a plane
  68215. * @param plane defines the reflection plane
  68216. * @param result defines the target matrix
  68217. */
  68218. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68219. /**
  68220. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68221. * @param xaxis defines the value of the 1st axis
  68222. * @param yaxis defines the value of the 2nd axis
  68223. * @param zaxis defines the value of the 3rd axis
  68224. * @param result defines the target matrix
  68225. */
  68226. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68227. /**
  68228. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68229. * @param quat defines the quaternion to use
  68230. * @param result defines the target matrix
  68231. */
  68232. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68233. }
  68234. /**
  68235. * @hidden
  68236. */
  68237. export class TmpVectors {
  68238. static Vector2: Vector2[];
  68239. static Vector3: Vector3[];
  68240. static Vector4: Vector4[];
  68241. static Quaternion: Quaternion[];
  68242. static Matrix: Matrix[];
  68243. }
  68244. }
  68245. declare module BABYLON {
  68246. /** Defines the cross module used constants to avoid circular dependncies */
  68247. export class Constants {
  68248. /** Defines that alpha blending is disabled */
  68249. static readonly ALPHA_DISABLE: number;
  68250. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68251. static readonly ALPHA_ADD: number;
  68252. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68253. static readonly ALPHA_COMBINE: number;
  68254. /** Defines that alpha blending to DEST - SRC * DEST */
  68255. static readonly ALPHA_SUBTRACT: number;
  68256. /** Defines that alpha blending to SRC * DEST */
  68257. static readonly ALPHA_MULTIPLY: number;
  68258. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68259. static readonly ALPHA_MAXIMIZED: number;
  68260. /** Defines that alpha blending to SRC + DEST */
  68261. static readonly ALPHA_ONEONE: number;
  68262. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68263. static readonly ALPHA_PREMULTIPLIED: number;
  68264. /**
  68265. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68266. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68267. */
  68268. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68269. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68270. static readonly ALPHA_INTERPOLATE: number;
  68271. /**
  68272. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68273. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68274. */
  68275. static readonly ALPHA_SCREENMODE: number;
  68276. /** Defines that the ressource is not delayed*/
  68277. static readonly DELAYLOADSTATE_NONE: number;
  68278. /** Defines that the ressource was successfully delay loaded */
  68279. static readonly DELAYLOADSTATE_LOADED: number;
  68280. /** Defines that the ressource is currently delay loading */
  68281. static readonly DELAYLOADSTATE_LOADING: number;
  68282. /** Defines that the ressource is delayed and has not started loading */
  68283. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68284. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68285. static readonly NEVER: number;
  68286. /** 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 */
  68287. static readonly ALWAYS: number;
  68288. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68289. static readonly LESS: number;
  68290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68291. static readonly EQUAL: number;
  68292. /** 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 */
  68293. static readonly LEQUAL: number;
  68294. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68295. static readonly GREATER: number;
  68296. /** 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 */
  68297. static readonly GEQUAL: number;
  68298. /** 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 */
  68299. static readonly NOTEQUAL: number;
  68300. /** Passed to stencilOperation to specify that stencil value must be kept */
  68301. static readonly KEEP: number;
  68302. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68303. static readonly REPLACE: number;
  68304. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68305. static readonly INCR: number;
  68306. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68307. static readonly DECR: number;
  68308. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68309. static readonly INVERT: number;
  68310. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68311. static readonly INCR_WRAP: number;
  68312. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68313. static readonly DECR_WRAP: number;
  68314. /** Texture is not repeating outside of 0..1 UVs */
  68315. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68316. /** Texture is repeating outside of 0..1 UVs */
  68317. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68318. /** Texture is repeating and mirrored */
  68319. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68320. /** ALPHA */
  68321. static readonly TEXTUREFORMAT_ALPHA: number;
  68322. /** LUMINANCE */
  68323. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68324. /** LUMINANCE_ALPHA */
  68325. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68326. /** RGB */
  68327. static readonly TEXTUREFORMAT_RGB: number;
  68328. /** RGBA */
  68329. static readonly TEXTUREFORMAT_RGBA: number;
  68330. /** RED */
  68331. static readonly TEXTUREFORMAT_RED: number;
  68332. /** RED (2nd reference) */
  68333. static readonly TEXTUREFORMAT_R: number;
  68334. /** RG */
  68335. static readonly TEXTUREFORMAT_RG: number;
  68336. /** RED_INTEGER */
  68337. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68338. /** RED_INTEGER (2nd reference) */
  68339. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68340. /** RG_INTEGER */
  68341. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68342. /** RGB_INTEGER */
  68343. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68344. /** RGBA_INTEGER */
  68345. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68346. /** UNSIGNED_BYTE */
  68347. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68348. /** UNSIGNED_BYTE (2nd reference) */
  68349. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68350. /** FLOAT */
  68351. static readonly TEXTURETYPE_FLOAT: number;
  68352. /** HALF_FLOAT */
  68353. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68354. /** BYTE */
  68355. static readonly TEXTURETYPE_BYTE: number;
  68356. /** SHORT */
  68357. static readonly TEXTURETYPE_SHORT: number;
  68358. /** UNSIGNED_SHORT */
  68359. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68360. /** INT */
  68361. static readonly TEXTURETYPE_INT: number;
  68362. /** UNSIGNED_INT */
  68363. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68364. /** UNSIGNED_SHORT_4_4_4_4 */
  68365. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68366. /** UNSIGNED_SHORT_5_5_5_1 */
  68367. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68368. /** UNSIGNED_SHORT_5_6_5 */
  68369. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68370. /** UNSIGNED_INT_2_10_10_10_REV */
  68371. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68372. /** UNSIGNED_INT_24_8 */
  68373. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68374. /** UNSIGNED_INT_10F_11F_11F_REV */
  68375. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68376. /** UNSIGNED_INT_5_9_9_9_REV */
  68377. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68378. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68379. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68380. /** nearest is mag = nearest and min = nearest and mip = linear */
  68381. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68382. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68383. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68384. /** Trilinear is mag = linear and min = linear and mip = linear */
  68385. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68386. /** nearest is mag = nearest and min = nearest and mip = linear */
  68387. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68388. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68389. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68390. /** Trilinear is mag = linear and min = linear and mip = linear */
  68391. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68392. /** mag = nearest and min = nearest and mip = nearest */
  68393. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68394. /** mag = nearest and min = linear and mip = nearest */
  68395. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68396. /** mag = nearest and min = linear and mip = linear */
  68397. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68398. /** mag = nearest and min = linear and mip = none */
  68399. static readonly TEXTURE_NEAREST_LINEAR: number;
  68400. /** mag = nearest and min = nearest and mip = none */
  68401. static readonly TEXTURE_NEAREST_NEAREST: number;
  68402. /** mag = linear and min = nearest and mip = nearest */
  68403. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68404. /** mag = linear and min = nearest and mip = linear */
  68405. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68406. /** mag = linear and min = linear and mip = none */
  68407. static readonly TEXTURE_LINEAR_LINEAR: number;
  68408. /** mag = linear and min = nearest and mip = none */
  68409. static readonly TEXTURE_LINEAR_NEAREST: number;
  68410. /** Explicit coordinates mode */
  68411. static readonly TEXTURE_EXPLICIT_MODE: number;
  68412. /** Spherical coordinates mode */
  68413. static readonly TEXTURE_SPHERICAL_MODE: number;
  68414. /** Planar coordinates mode */
  68415. static readonly TEXTURE_PLANAR_MODE: number;
  68416. /** Cubic coordinates mode */
  68417. static readonly TEXTURE_CUBIC_MODE: number;
  68418. /** Projection coordinates mode */
  68419. static readonly TEXTURE_PROJECTION_MODE: number;
  68420. /** Skybox coordinates mode */
  68421. static readonly TEXTURE_SKYBOX_MODE: number;
  68422. /** Inverse Cubic coordinates mode */
  68423. static readonly TEXTURE_INVCUBIC_MODE: number;
  68424. /** Equirectangular coordinates mode */
  68425. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68426. /** Equirectangular Fixed coordinates mode */
  68427. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68428. /** Equirectangular Fixed Mirrored coordinates mode */
  68429. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68430. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68431. static readonly SCALEMODE_FLOOR: number;
  68432. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68433. static readonly SCALEMODE_NEAREST: number;
  68434. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68435. static readonly SCALEMODE_CEILING: number;
  68436. /**
  68437. * The dirty texture flag value
  68438. */
  68439. static readonly MATERIAL_TextureDirtyFlag: number;
  68440. /**
  68441. * The dirty light flag value
  68442. */
  68443. static readonly MATERIAL_LightDirtyFlag: number;
  68444. /**
  68445. * The dirty fresnel flag value
  68446. */
  68447. static readonly MATERIAL_FresnelDirtyFlag: number;
  68448. /**
  68449. * The dirty attribute flag value
  68450. */
  68451. static readonly MATERIAL_AttributesDirtyFlag: number;
  68452. /**
  68453. * The dirty misc flag value
  68454. */
  68455. static readonly MATERIAL_MiscDirtyFlag: number;
  68456. /**
  68457. * The all dirty flag value
  68458. */
  68459. static readonly MATERIAL_AllDirtyFlag: number;
  68460. /**
  68461. * Returns the triangle fill mode
  68462. */
  68463. static readonly MATERIAL_TriangleFillMode: number;
  68464. /**
  68465. * Returns the wireframe mode
  68466. */
  68467. static readonly MATERIAL_WireFrameFillMode: number;
  68468. /**
  68469. * Returns the point fill mode
  68470. */
  68471. static readonly MATERIAL_PointFillMode: number;
  68472. /**
  68473. * Returns the point list draw mode
  68474. */
  68475. static readonly MATERIAL_PointListDrawMode: number;
  68476. /**
  68477. * Returns the line list draw mode
  68478. */
  68479. static readonly MATERIAL_LineListDrawMode: number;
  68480. /**
  68481. * Returns the line loop draw mode
  68482. */
  68483. static readonly MATERIAL_LineLoopDrawMode: number;
  68484. /**
  68485. * Returns the line strip draw mode
  68486. */
  68487. static readonly MATERIAL_LineStripDrawMode: number;
  68488. /**
  68489. * Returns the triangle strip draw mode
  68490. */
  68491. static readonly MATERIAL_TriangleStripDrawMode: number;
  68492. /**
  68493. * Returns the triangle fan draw mode
  68494. */
  68495. static readonly MATERIAL_TriangleFanDrawMode: number;
  68496. /**
  68497. * Stores the clock-wise side orientation
  68498. */
  68499. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68500. /**
  68501. * Stores the counter clock-wise side orientation
  68502. */
  68503. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68504. /**
  68505. * Nothing
  68506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68507. */
  68508. static readonly ACTION_NothingTrigger: number;
  68509. /**
  68510. * On pick
  68511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68512. */
  68513. static readonly ACTION_OnPickTrigger: number;
  68514. /**
  68515. * On left pick
  68516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68517. */
  68518. static readonly ACTION_OnLeftPickTrigger: number;
  68519. /**
  68520. * On right pick
  68521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68522. */
  68523. static readonly ACTION_OnRightPickTrigger: number;
  68524. /**
  68525. * On center pick
  68526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68527. */
  68528. static readonly ACTION_OnCenterPickTrigger: number;
  68529. /**
  68530. * On pick down
  68531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68532. */
  68533. static readonly ACTION_OnPickDownTrigger: number;
  68534. /**
  68535. * On double pick
  68536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68537. */
  68538. static readonly ACTION_OnDoublePickTrigger: number;
  68539. /**
  68540. * On pick up
  68541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68542. */
  68543. static readonly ACTION_OnPickUpTrigger: number;
  68544. /**
  68545. * On pick out.
  68546. * This trigger will only be raised if you also declared a OnPickDown
  68547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68548. */
  68549. static readonly ACTION_OnPickOutTrigger: number;
  68550. /**
  68551. * On long press
  68552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68553. */
  68554. static readonly ACTION_OnLongPressTrigger: number;
  68555. /**
  68556. * On pointer over
  68557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68558. */
  68559. static readonly ACTION_OnPointerOverTrigger: number;
  68560. /**
  68561. * On pointer out
  68562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68563. */
  68564. static readonly ACTION_OnPointerOutTrigger: number;
  68565. /**
  68566. * On every frame
  68567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68568. */
  68569. static readonly ACTION_OnEveryFrameTrigger: number;
  68570. /**
  68571. * On intersection enter
  68572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68573. */
  68574. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68575. /**
  68576. * On intersection exit
  68577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68578. */
  68579. static readonly ACTION_OnIntersectionExitTrigger: number;
  68580. /**
  68581. * On key down
  68582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68583. */
  68584. static readonly ACTION_OnKeyDownTrigger: number;
  68585. /**
  68586. * On key up
  68587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68588. */
  68589. static readonly ACTION_OnKeyUpTrigger: number;
  68590. /**
  68591. * Billboard mode will only apply to Y axis
  68592. */
  68593. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68594. /**
  68595. * Billboard mode will apply to all axes
  68596. */
  68597. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68598. /**
  68599. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68600. */
  68601. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68602. /**
  68603. * Gets or sets base Assets URL
  68604. */
  68605. static PARTICLES_BaseAssetsUrl: string;
  68606. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68607. * Test order :
  68608. * Is the bounding sphere outside the frustum ?
  68609. * If not, are the bounding box vertices outside the frustum ?
  68610. * It not, then the cullable object is in the frustum.
  68611. */
  68612. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68613. /** Culling strategy : Bounding Sphere Only.
  68614. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68615. * It's also less accurate than the standard because some not visible objects can still be selected.
  68616. * Test : is the bounding sphere outside the frustum ?
  68617. * If not, then the cullable object is in the frustum.
  68618. */
  68619. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68620. /** Culling strategy : Optimistic Inclusion.
  68621. * This in an inclusion test first, then the standard exclusion test.
  68622. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68623. * 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.
  68624. * Anyway, it's as accurate as the standard strategy.
  68625. * Test :
  68626. * Is the cullable object bounding sphere center in the frustum ?
  68627. * If not, apply the default culling strategy.
  68628. */
  68629. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68630. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68631. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68632. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68633. * 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.
  68634. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68635. * Test :
  68636. * Is the cullable object bounding sphere center in the frustum ?
  68637. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68638. */
  68639. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68640. /**
  68641. * No logging while loading
  68642. */
  68643. static readonly SCENELOADER_NO_LOGGING: number;
  68644. /**
  68645. * Minimal logging while loading
  68646. */
  68647. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68648. /**
  68649. * Summary logging while loading
  68650. */
  68651. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68652. /**
  68653. * Detailled logging while loading
  68654. */
  68655. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68656. }
  68657. }
  68658. declare module BABYLON {
  68659. /**
  68660. * Class used to store and describe the pipeline context associated with an effect
  68661. */
  68662. export interface IPipelineContext {
  68663. /**
  68664. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68665. */
  68666. isAsync: boolean;
  68667. /**
  68668. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68669. */
  68670. isReady: boolean;
  68671. /** @hidden */
  68672. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68673. }
  68674. }
  68675. declare module BABYLON {
  68676. /** @hidden */
  68677. export interface IShaderProcessor {
  68678. attributeProcessor?: (attribute: string) => string;
  68679. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68680. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68681. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68682. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68683. lineProcessor?: (line: string, isFragment: boolean) => string;
  68684. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68685. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68686. }
  68687. }
  68688. declare module BABYLON {
  68689. /** @hidden */
  68690. export interface ProcessingOptions {
  68691. defines: string[];
  68692. indexParameters: any;
  68693. isFragment: boolean;
  68694. shouldUseHighPrecisionShader: boolean;
  68695. supportsUniformBuffers: boolean;
  68696. shadersRepository: string;
  68697. includesShadersStore: {
  68698. [key: string]: string;
  68699. };
  68700. processor?: IShaderProcessor;
  68701. version: string;
  68702. platformName: string;
  68703. lookForClosingBracketForUniformBuffer?: boolean;
  68704. }
  68705. }
  68706. declare module BABYLON {
  68707. /**
  68708. * Helper to manipulate strings
  68709. */
  68710. export class StringTools {
  68711. /**
  68712. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68713. * @param str Source string
  68714. * @param suffix Suffix to search for in the source string
  68715. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68716. */
  68717. static EndsWith(str: string, suffix: string): boolean;
  68718. /**
  68719. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68720. * @param str Source string
  68721. * @param suffix Suffix to search for in the source string
  68722. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68723. */
  68724. static StartsWith(str: string, suffix: string): boolean;
  68725. }
  68726. }
  68727. declare module BABYLON {
  68728. /** @hidden */
  68729. export class ShaderCodeNode {
  68730. line: string;
  68731. children: ShaderCodeNode[];
  68732. additionalDefineKey?: string;
  68733. additionalDefineValue?: string;
  68734. isValid(preprocessors: {
  68735. [key: string]: string;
  68736. }): boolean;
  68737. process(preprocessors: {
  68738. [key: string]: string;
  68739. }, options: ProcessingOptions): string;
  68740. }
  68741. }
  68742. declare module BABYLON {
  68743. /** @hidden */
  68744. export class ShaderCodeCursor {
  68745. private _lines;
  68746. lineIndex: number;
  68747. readonly currentLine: string;
  68748. readonly canRead: boolean;
  68749. lines: string[];
  68750. }
  68751. }
  68752. declare module BABYLON {
  68753. /** @hidden */
  68754. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68755. process(preprocessors: {
  68756. [key: string]: string;
  68757. }, options: ProcessingOptions): string;
  68758. }
  68759. }
  68760. declare module BABYLON {
  68761. /** @hidden */
  68762. export class ShaderDefineExpression {
  68763. isTrue(preprocessors: {
  68764. [key: string]: string;
  68765. }): boolean;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /** @hidden */
  68770. export class ShaderCodeTestNode extends ShaderCodeNode {
  68771. testExpression: ShaderDefineExpression;
  68772. isValid(preprocessors: {
  68773. [key: string]: string;
  68774. }): boolean;
  68775. }
  68776. }
  68777. declare module BABYLON {
  68778. /** @hidden */
  68779. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68780. define: string;
  68781. not: boolean;
  68782. constructor(define: string, not?: boolean);
  68783. isTrue(preprocessors: {
  68784. [key: string]: string;
  68785. }): boolean;
  68786. }
  68787. }
  68788. declare module BABYLON {
  68789. /** @hidden */
  68790. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68791. leftOperand: ShaderDefineExpression;
  68792. rightOperand: ShaderDefineExpression;
  68793. isTrue(preprocessors: {
  68794. [key: string]: string;
  68795. }): boolean;
  68796. }
  68797. }
  68798. declare module BABYLON {
  68799. /** @hidden */
  68800. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68801. leftOperand: ShaderDefineExpression;
  68802. rightOperand: ShaderDefineExpression;
  68803. isTrue(preprocessors: {
  68804. [key: string]: string;
  68805. }): boolean;
  68806. }
  68807. }
  68808. declare module BABYLON {
  68809. /** @hidden */
  68810. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68811. define: string;
  68812. operand: string;
  68813. testValue: string;
  68814. constructor(define: string, operand: string, testValue: string);
  68815. isTrue(preprocessors: {
  68816. [key: string]: string;
  68817. }): boolean;
  68818. }
  68819. }
  68820. declare module BABYLON {
  68821. /**
  68822. * @ignore
  68823. * Application error to support additional information when loading a file
  68824. */
  68825. export class LoadFileError extends Error {
  68826. /** defines the optional web request */
  68827. request?: WebRequest | undefined;
  68828. private static _setPrototypeOf;
  68829. /**
  68830. * Creates a new LoadFileError
  68831. * @param message defines the message of the error
  68832. * @param request defines the optional web request
  68833. */
  68834. constructor(message: string,
  68835. /** defines the optional web request */
  68836. request?: WebRequest | undefined);
  68837. }
  68838. }
  68839. declare module BABYLON {
  68840. /**
  68841. * Class used to enable access to offline support
  68842. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68843. */
  68844. export interface IOfflineProvider {
  68845. /**
  68846. * Gets a boolean indicating if scene must be saved in the database
  68847. */
  68848. enableSceneOffline: boolean;
  68849. /**
  68850. * Gets a boolean indicating if textures must be saved in the database
  68851. */
  68852. enableTexturesOffline: boolean;
  68853. /**
  68854. * Open the offline support and make it available
  68855. * @param successCallback defines the callback to call on success
  68856. * @param errorCallback defines the callback to call on error
  68857. */
  68858. open(successCallback: () => void, errorCallback: () => void): void;
  68859. /**
  68860. * Loads an image from the offline support
  68861. * @param url defines the url to load from
  68862. * @param image defines the target DOM image
  68863. */
  68864. loadImage(url: string, image: HTMLImageElement): void;
  68865. /**
  68866. * Loads a file from offline support
  68867. * @param url defines the URL to load from
  68868. * @param sceneLoaded defines a callback to call on success
  68869. * @param progressCallBack defines a callback to call when progress changed
  68870. * @param errorCallback defines a callback to call on error
  68871. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68872. */
  68873. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68874. }
  68875. }
  68876. declare module BABYLON {
  68877. /**
  68878. * Class used to help managing file picking and drag'n'drop
  68879. * File Storage
  68880. */
  68881. export class FilesInputStore {
  68882. /**
  68883. * List of files ready to be loaded
  68884. */
  68885. static FilesToLoad: {
  68886. [key: string]: File;
  68887. };
  68888. }
  68889. }
  68890. declare module BABYLON {
  68891. /**
  68892. * Class used to define a retry strategy when error happens while loading assets
  68893. */
  68894. export class RetryStrategy {
  68895. /**
  68896. * Function used to defines an exponential back off strategy
  68897. * @param maxRetries defines the maximum number of retries (3 by default)
  68898. * @param baseInterval defines the interval between retries
  68899. * @returns the strategy function to use
  68900. */
  68901. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * @hidden
  68907. */
  68908. export class FileTools {
  68909. /**
  68910. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68911. */
  68912. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68913. /**
  68914. * Gets or sets the base URL to use to load assets
  68915. */
  68916. static BaseUrl: string;
  68917. /**
  68918. * Default behaviour for cors in the application.
  68919. * It can be a string if the expected behavior is identical in the entire app.
  68920. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68921. */
  68922. static CorsBehavior: string | ((url: string | string[]) => string);
  68923. /**
  68924. * Gets or sets a function used to pre-process url before using them to load assets
  68925. */
  68926. static PreprocessUrl: (url: string) => string;
  68927. /**
  68928. * Removes unwanted characters from an url
  68929. * @param url defines the url to clean
  68930. * @returns the cleaned url
  68931. */
  68932. private static _CleanUrl;
  68933. /**
  68934. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68935. * @param url define the url we are trying
  68936. * @param element define the dom element where to configure the cors policy
  68937. */
  68938. static SetCorsBehavior(url: string | string[], element: {
  68939. crossOrigin: string | null;
  68940. }): void;
  68941. /**
  68942. * Loads an image as an HTMLImageElement.
  68943. * @param input url string, ArrayBuffer, or Blob to load
  68944. * @param onLoad callback called when the image successfully loads
  68945. * @param onError callback called when the image fails to load
  68946. * @param offlineProvider offline provider for caching
  68947. * @returns the HTMLImageElement of the loaded image
  68948. */
  68949. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68950. /**
  68951. * Loads a file
  68952. * @param fileToLoad defines the file to load
  68953. * @param callback defines the callback to call when data is loaded
  68954. * @param progressCallBack defines the callback to call during loading process
  68955. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68956. * @returns a file request object
  68957. */
  68958. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68959. /**
  68960. * Loads a file
  68961. * @param url url string, ArrayBuffer, or Blob to load
  68962. * @param onSuccess callback called when the file successfully loads
  68963. * @param onProgress callback called while file is loading (if the server supports this mode)
  68964. * @param offlineProvider defines the offline provider for caching
  68965. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68966. * @param onError callback called when the file fails to load
  68967. * @returns a file request object
  68968. */
  68969. 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;
  68970. /**
  68971. * Checks if the loaded document was accessed via `file:`-Protocol.
  68972. * @returns boolean
  68973. */
  68974. static IsFileURL(): boolean;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /** @hidden */
  68979. export class ShaderProcessor {
  68980. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68981. private static _ProcessPrecision;
  68982. private static _ExtractOperation;
  68983. private static _BuildSubExpression;
  68984. private static _BuildExpression;
  68985. private static _MoveCursorWithinIf;
  68986. private static _MoveCursor;
  68987. private static _EvaluatePreProcessors;
  68988. private static _PreparePreProcessors;
  68989. private static _ProcessShaderConversion;
  68990. private static _ProcessIncludes;
  68991. }
  68992. }
  68993. declare module BABYLON {
  68994. /**
  68995. * Class used to hold a RBG color
  68996. */
  68997. export class Color3 {
  68998. /**
  68999. * Defines the red component (between 0 and 1, default is 0)
  69000. */
  69001. r: number;
  69002. /**
  69003. * Defines the green component (between 0 and 1, default is 0)
  69004. */
  69005. g: number;
  69006. /**
  69007. * Defines the blue component (between 0 and 1, default is 0)
  69008. */
  69009. b: number;
  69010. /**
  69011. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69012. * @param r defines the red component (between 0 and 1, default is 0)
  69013. * @param g defines the green component (between 0 and 1, default is 0)
  69014. * @param b defines the blue component (between 0 and 1, default is 0)
  69015. */
  69016. constructor(
  69017. /**
  69018. * Defines the red component (between 0 and 1, default is 0)
  69019. */
  69020. r?: number,
  69021. /**
  69022. * Defines the green component (between 0 and 1, default is 0)
  69023. */
  69024. g?: number,
  69025. /**
  69026. * Defines the blue component (between 0 and 1, default is 0)
  69027. */
  69028. b?: number);
  69029. /**
  69030. * Creates a string with the Color3 current values
  69031. * @returns the string representation of the Color3 object
  69032. */
  69033. toString(): string;
  69034. /**
  69035. * Returns the string "Color3"
  69036. * @returns "Color3"
  69037. */
  69038. getClassName(): string;
  69039. /**
  69040. * Compute the Color3 hash code
  69041. * @returns an unique number that can be used to hash Color3 objects
  69042. */
  69043. getHashCode(): number;
  69044. /**
  69045. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69046. * @param array defines the array where to store the r,g,b components
  69047. * @param index defines an optional index in the target array to define where to start storing values
  69048. * @returns the current Color3 object
  69049. */
  69050. toArray(array: FloatArray, index?: number): Color3;
  69051. /**
  69052. * Returns a new Color4 object from the current Color3 and the given alpha
  69053. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69054. * @returns a new Color4 object
  69055. */
  69056. toColor4(alpha?: number): Color4;
  69057. /**
  69058. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69059. * @returns the new array
  69060. */
  69061. asArray(): number[];
  69062. /**
  69063. * Returns the luminance value
  69064. * @returns a float value
  69065. */
  69066. toLuminance(): number;
  69067. /**
  69068. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69069. * @param otherColor defines the second operand
  69070. * @returns the new Color3 object
  69071. */
  69072. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69073. /**
  69074. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69075. * @param otherColor defines the second operand
  69076. * @param result defines the Color3 object where to store the result
  69077. * @returns the current Color3
  69078. */
  69079. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69080. /**
  69081. * Determines equality between Color3 objects
  69082. * @param otherColor defines the second operand
  69083. * @returns true if the rgb values are equal to the given ones
  69084. */
  69085. equals(otherColor: DeepImmutable<Color3>): boolean;
  69086. /**
  69087. * Determines equality between the current Color3 object and a set of r,b,g values
  69088. * @param r defines the red component to check
  69089. * @param g defines the green component to check
  69090. * @param b defines the blue component to check
  69091. * @returns true if the rgb values are equal to the given ones
  69092. */
  69093. equalsFloats(r: number, g: number, b: number): boolean;
  69094. /**
  69095. * Multiplies in place each rgb value by scale
  69096. * @param scale defines the scaling factor
  69097. * @returns the updated Color3
  69098. */
  69099. scale(scale: number): Color3;
  69100. /**
  69101. * Multiplies the rgb values by scale and stores the result into "result"
  69102. * @param scale defines the scaling factor
  69103. * @param result defines the Color3 object where to store the result
  69104. * @returns the unmodified current Color3
  69105. */
  69106. scaleToRef(scale: number, result: Color3): Color3;
  69107. /**
  69108. * Scale the current Color3 values by a factor and add the result to a given Color3
  69109. * @param scale defines the scale factor
  69110. * @param result defines color to store the result into
  69111. * @returns the unmodified current Color3
  69112. */
  69113. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69114. /**
  69115. * Clamps the rgb values by the min and max values and stores the result into "result"
  69116. * @param min defines minimum clamping value (default is 0)
  69117. * @param max defines maximum clamping value (default is 1)
  69118. * @param result defines color to store the result into
  69119. * @returns the original Color3
  69120. */
  69121. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69122. /**
  69123. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69124. * @param otherColor defines the second operand
  69125. * @returns the new Color3
  69126. */
  69127. add(otherColor: DeepImmutable<Color3>): Color3;
  69128. /**
  69129. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69130. * @param otherColor defines the second operand
  69131. * @param result defines Color3 object to store the result into
  69132. * @returns the unmodified current Color3
  69133. */
  69134. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69135. /**
  69136. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69137. * @param otherColor defines the second operand
  69138. * @returns the new Color3
  69139. */
  69140. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69141. /**
  69142. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69143. * @param otherColor defines the second operand
  69144. * @param result defines Color3 object to store the result into
  69145. * @returns the unmodified current Color3
  69146. */
  69147. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69148. /**
  69149. * Copy the current object
  69150. * @returns a new Color3 copied the current one
  69151. */
  69152. clone(): Color3;
  69153. /**
  69154. * Copies the rgb values from the source in the current Color3
  69155. * @param source defines the source Color3 object
  69156. * @returns the updated Color3 object
  69157. */
  69158. copyFrom(source: DeepImmutable<Color3>): Color3;
  69159. /**
  69160. * Updates the Color3 rgb values from the given floats
  69161. * @param r defines the red component to read from
  69162. * @param g defines the green component to read from
  69163. * @param b defines the blue component to read from
  69164. * @returns the current Color3 object
  69165. */
  69166. copyFromFloats(r: number, g: number, b: number): Color3;
  69167. /**
  69168. * Updates the Color3 rgb values from the given floats
  69169. * @param r defines the red component to read from
  69170. * @param g defines the green component to read from
  69171. * @param b defines the blue component to read from
  69172. * @returns the current Color3 object
  69173. */
  69174. set(r: number, g: number, b: number): Color3;
  69175. /**
  69176. * Compute the Color3 hexadecimal code as a string
  69177. * @returns a string containing the hexadecimal representation of the Color3 object
  69178. */
  69179. toHexString(): string;
  69180. /**
  69181. * Computes a new Color3 converted from the current one to linear space
  69182. * @returns a new Color3 object
  69183. */
  69184. toLinearSpace(): Color3;
  69185. /**
  69186. * Converts current color in rgb space to HSV values
  69187. * @returns a new color3 representing the HSV values
  69188. */
  69189. toHSV(): Color3;
  69190. /**
  69191. * Converts current color in rgb space to HSV values
  69192. * @param result defines the Color3 where to store the HSV values
  69193. */
  69194. toHSVToRef(result: Color3): void;
  69195. /**
  69196. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69197. * @param convertedColor defines the Color3 object where to store the linear space version
  69198. * @returns the unmodified Color3
  69199. */
  69200. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69201. /**
  69202. * Computes a new Color3 converted from the current one to gamma space
  69203. * @returns a new Color3 object
  69204. */
  69205. toGammaSpace(): Color3;
  69206. /**
  69207. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69208. * @param convertedColor defines the Color3 object where to store the gamma space version
  69209. * @returns the unmodified Color3
  69210. */
  69211. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69212. private static _BlackReadOnly;
  69213. /**
  69214. * Convert Hue, saturation and value to a Color3 (RGB)
  69215. * @param hue defines the hue
  69216. * @param saturation defines the saturation
  69217. * @param value defines the value
  69218. * @param result defines the Color3 where to store the RGB values
  69219. */
  69220. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69221. /**
  69222. * Creates a new Color3 from the string containing valid hexadecimal values
  69223. * @param hex defines a string containing valid hexadecimal values
  69224. * @returns a new Color3 object
  69225. */
  69226. static FromHexString(hex: string): Color3;
  69227. /**
  69228. * Creates a new Color3 from the starting index of the given array
  69229. * @param array defines the source array
  69230. * @param offset defines an offset in the source array
  69231. * @returns a new Color3 object
  69232. */
  69233. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69234. /**
  69235. * Creates a new Color3 from integer values (< 256)
  69236. * @param r defines the red component to read from (value between 0 and 255)
  69237. * @param g defines the green component to read from (value between 0 and 255)
  69238. * @param b defines the blue component to read from (value between 0 and 255)
  69239. * @returns a new Color3 object
  69240. */
  69241. static FromInts(r: number, g: number, b: number): Color3;
  69242. /**
  69243. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69244. * @param start defines the start Color3 value
  69245. * @param end defines the end Color3 value
  69246. * @param amount defines the gradient value between start and end
  69247. * @returns a new Color3 object
  69248. */
  69249. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69250. /**
  69251. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69252. * @param left defines the start value
  69253. * @param right defines the end value
  69254. * @param amount defines the gradient factor
  69255. * @param result defines the Color3 object where to store the result
  69256. */
  69257. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69258. /**
  69259. * Returns a Color3 value containing a red color
  69260. * @returns a new Color3 object
  69261. */
  69262. static Red(): Color3;
  69263. /**
  69264. * Returns a Color3 value containing a green color
  69265. * @returns a new Color3 object
  69266. */
  69267. static Green(): Color3;
  69268. /**
  69269. * Returns a Color3 value containing a blue color
  69270. * @returns a new Color3 object
  69271. */
  69272. static Blue(): Color3;
  69273. /**
  69274. * Returns a Color3 value containing a black color
  69275. * @returns a new Color3 object
  69276. */
  69277. static Black(): Color3;
  69278. /**
  69279. * Gets a Color3 value containing a black color that must not be updated
  69280. */
  69281. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69282. /**
  69283. * Returns a Color3 value containing a white color
  69284. * @returns a new Color3 object
  69285. */
  69286. static White(): Color3;
  69287. /**
  69288. * Returns a Color3 value containing a purple color
  69289. * @returns a new Color3 object
  69290. */
  69291. static Purple(): Color3;
  69292. /**
  69293. * Returns a Color3 value containing a magenta color
  69294. * @returns a new Color3 object
  69295. */
  69296. static Magenta(): Color3;
  69297. /**
  69298. * Returns a Color3 value containing a yellow color
  69299. * @returns a new Color3 object
  69300. */
  69301. static Yellow(): Color3;
  69302. /**
  69303. * Returns a Color3 value containing a gray color
  69304. * @returns a new Color3 object
  69305. */
  69306. static Gray(): Color3;
  69307. /**
  69308. * Returns a Color3 value containing a teal color
  69309. * @returns a new Color3 object
  69310. */
  69311. static Teal(): Color3;
  69312. /**
  69313. * Returns a Color3 value containing a random color
  69314. * @returns a new Color3 object
  69315. */
  69316. static Random(): Color3;
  69317. }
  69318. /**
  69319. * Class used to hold a RBGA color
  69320. */
  69321. export class Color4 {
  69322. /**
  69323. * Defines the red component (between 0 and 1, default is 0)
  69324. */
  69325. r: number;
  69326. /**
  69327. * Defines the green component (between 0 and 1, default is 0)
  69328. */
  69329. g: number;
  69330. /**
  69331. * Defines the blue component (between 0 and 1, default is 0)
  69332. */
  69333. b: number;
  69334. /**
  69335. * Defines the alpha component (between 0 and 1, default is 1)
  69336. */
  69337. a: number;
  69338. /**
  69339. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69340. * @param r defines the red component (between 0 and 1, default is 0)
  69341. * @param g defines the green component (between 0 and 1, default is 0)
  69342. * @param b defines the blue component (between 0 and 1, default is 0)
  69343. * @param a defines the alpha component (between 0 and 1, default is 1)
  69344. */
  69345. constructor(
  69346. /**
  69347. * Defines the red component (between 0 and 1, default is 0)
  69348. */
  69349. r?: number,
  69350. /**
  69351. * Defines the green component (between 0 and 1, default is 0)
  69352. */
  69353. g?: number,
  69354. /**
  69355. * Defines the blue component (between 0 and 1, default is 0)
  69356. */
  69357. b?: number,
  69358. /**
  69359. * Defines the alpha component (between 0 and 1, default is 1)
  69360. */
  69361. a?: number);
  69362. /**
  69363. * Adds in place the given Color4 values to the current Color4 object
  69364. * @param right defines the second operand
  69365. * @returns the current updated Color4 object
  69366. */
  69367. addInPlace(right: DeepImmutable<Color4>): Color4;
  69368. /**
  69369. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69370. * @returns the new array
  69371. */
  69372. asArray(): number[];
  69373. /**
  69374. * Stores from the starting index in the given array the Color4 successive values
  69375. * @param array defines the array where to store the r,g,b components
  69376. * @param index defines an optional index in the target array to define where to start storing values
  69377. * @returns the current Color4 object
  69378. */
  69379. toArray(array: number[], index?: number): Color4;
  69380. /**
  69381. * Determines equality between Color4 objects
  69382. * @param otherColor defines the second operand
  69383. * @returns true if the rgba values are equal to the given ones
  69384. */
  69385. equals(otherColor: DeepImmutable<Color4>): boolean;
  69386. /**
  69387. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69388. * @param right defines the second operand
  69389. * @returns a new Color4 object
  69390. */
  69391. add(right: DeepImmutable<Color4>): Color4;
  69392. /**
  69393. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69394. * @param right defines the second operand
  69395. * @returns a new Color4 object
  69396. */
  69397. subtract(right: DeepImmutable<Color4>): Color4;
  69398. /**
  69399. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69400. * @param right defines the second operand
  69401. * @param result defines the Color4 object where to store the result
  69402. * @returns the current Color4 object
  69403. */
  69404. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69405. /**
  69406. * Creates a new Color4 with the current Color4 values multiplied by scale
  69407. * @param scale defines the scaling factor to apply
  69408. * @returns a new Color4 object
  69409. */
  69410. scale(scale: number): Color4;
  69411. /**
  69412. * Multiplies the current Color4 values by scale and stores the result in "result"
  69413. * @param scale defines the scaling factor to apply
  69414. * @param result defines the Color4 object where to store the result
  69415. * @returns the current unmodified Color4
  69416. */
  69417. scaleToRef(scale: number, result: Color4): Color4;
  69418. /**
  69419. * Scale the current Color4 values by a factor and add the result to a given Color4
  69420. * @param scale defines the scale factor
  69421. * @param result defines the Color4 object where to store the result
  69422. * @returns the unmodified current Color4
  69423. */
  69424. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69425. /**
  69426. * Clamps the rgb values by the min and max values and stores the result into "result"
  69427. * @param min defines minimum clamping value (default is 0)
  69428. * @param max defines maximum clamping value (default is 1)
  69429. * @param result defines color to store the result into.
  69430. * @returns the cuurent Color4
  69431. */
  69432. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69433. /**
  69434. * Multipy an Color4 value by another and return a new Color4 object
  69435. * @param color defines the Color4 value to multiply by
  69436. * @returns a new Color4 object
  69437. */
  69438. multiply(color: Color4): Color4;
  69439. /**
  69440. * Multipy a Color4 value by another and push the result in a reference value
  69441. * @param color defines the Color4 value to multiply by
  69442. * @param result defines the Color4 to fill the result in
  69443. * @returns the result Color4
  69444. */
  69445. multiplyToRef(color: Color4, result: Color4): Color4;
  69446. /**
  69447. * Creates a string with the Color4 current values
  69448. * @returns the string representation of the Color4 object
  69449. */
  69450. toString(): string;
  69451. /**
  69452. * Returns the string "Color4"
  69453. * @returns "Color4"
  69454. */
  69455. getClassName(): string;
  69456. /**
  69457. * Compute the Color4 hash code
  69458. * @returns an unique number that can be used to hash Color4 objects
  69459. */
  69460. getHashCode(): number;
  69461. /**
  69462. * Creates a new Color4 copied from the current one
  69463. * @returns a new Color4 object
  69464. */
  69465. clone(): Color4;
  69466. /**
  69467. * Copies the given Color4 values into the current one
  69468. * @param source defines the source Color4 object
  69469. * @returns the current updated Color4 object
  69470. */
  69471. copyFrom(source: Color4): Color4;
  69472. /**
  69473. * Copies the given float values into the current one
  69474. * @param r defines the red component to read from
  69475. * @param g defines the green component to read from
  69476. * @param b defines the blue component to read from
  69477. * @param a defines the alpha component to read from
  69478. * @returns the current updated Color4 object
  69479. */
  69480. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69481. /**
  69482. * Copies the given float values into the current one
  69483. * @param r defines the red component to read from
  69484. * @param g defines the green component to read from
  69485. * @param b defines the blue component to read from
  69486. * @param a defines the alpha component to read from
  69487. * @returns the current updated Color4 object
  69488. */
  69489. set(r: number, g: number, b: number, a: number): Color4;
  69490. /**
  69491. * Compute the Color4 hexadecimal code as a string
  69492. * @returns a string containing the hexadecimal representation of the Color4 object
  69493. */
  69494. toHexString(): string;
  69495. /**
  69496. * Computes a new Color4 converted from the current one to linear space
  69497. * @returns a new Color4 object
  69498. */
  69499. toLinearSpace(): Color4;
  69500. /**
  69501. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69502. * @param convertedColor defines the Color4 object where to store the linear space version
  69503. * @returns the unmodified Color4
  69504. */
  69505. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69506. /**
  69507. * Computes a new Color4 converted from the current one to gamma space
  69508. * @returns a new Color4 object
  69509. */
  69510. toGammaSpace(): Color4;
  69511. /**
  69512. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69513. * @param convertedColor defines the Color4 object where to store the gamma space version
  69514. * @returns the unmodified Color4
  69515. */
  69516. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69517. /**
  69518. * Creates a new Color4 from the string containing valid hexadecimal values
  69519. * @param hex defines a string containing valid hexadecimal values
  69520. * @returns a new Color4 object
  69521. */
  69522. static FromHexString(hex: string): Color4;
  69523. /**
  69524. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69525. * @param left defines the start value
  69526. * @param right defines the end value
  69527. * @param amount defines the gradient factor
  69528. * @returns a new Color4 object
  69529. */
  69530. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69531. /**
  69532. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69533. * @param left defines the start value
  69534. * @param right defines the end value
  69535. * @param amount defines the gradient factor
  69536. * @param result defines the Color4 object where to store data
  69537. */
  69538. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69539. /**
  69540. * Creates a new Color4 from a Color3 and an alpha value
  69541. * @param color3 defines the source Color3 to read from
  69542. * @param alpha defines the alpha component (1.0 by default)
  69543. * @returns a new Color4 object
  69544. */
  69545. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69546. /**
  69547. * Creates a new Color4 from the starting index element of the given array
  69548. * @param array defines the source array to read from
  69549. * @param offset defines the offset in the source array
  69550. * @returns a new Color4 object
  69551. */
  69552. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69553. /**
  69554. * Creates a new Color3 from integer values (< 256)
  69555. * @param r defines the red component to read from (value between 0 and 255)
  69556. * @param g defines the green component to read from (value between 0 and 255)
  69557. * @param b defines the blue component to read from (value between 0 and 255)
  69558. * @param a defines the alpha component to read from (value between 0 and 255)
  69559. * @returns a new Color3 object
  69560. */
  69561. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69562. /**
  69563. * Check the content of a given array and convert it to an array containing RGBA data
  69564. * If the original array was already containing count * 4 values then it is returned directly
  69565. * @param colors defines the array to check
  69566. * @param count defines the number of RGBA data to expect
  69567. * @returns an array containing count * 4 values (RGBA)
  69568. */
  69569. static CheckColors4(colors: number[], count: number): number[];
  69570. }
  69571. /**
  69572. * @hidden
  69573. */
  69574. export class TmpColors {
  69575. static Color3: Color3[];
  69576. static Color4: Color4[];
  69577. }
  69578. }
  69579. declare module BABYLON {
  69580. /**
  69581. * Class representing spherical harmonics coefficients to the 3rd degree
  69582. */
  69583. export class SphericalHarmonics {
  69584. /**
  69585. * Defines whether or not the harmonics have been prescaled for rendering.
  69586. */
  69587. preScaled: boolean;
  69588. /**
  69589. * The l0,0 coefficients of the spherical harmonics
  69590. */
  69591. l00: Vector3;
  69592. /**
  69593. * The l1,-1 coefficients of the spherical harmonics
  69594. */
  69595. l1_1: Vector3;
  69596. /**
  69597. * The l1,0 coefficients of the spherical harmonics
  69598. */
  69599. l10: Vector3;
  69600. /**
  69601. * The l1,1 coefficients of the spherical harmonics
  69602. */
  69603. l11: Vector3;
  69604. /**
  69605. * The l2,-2 coefficients of the spherical harmonics
  69606. */
  69607. l2_2: Vector3;
  69608. /**
  69609. * The l2,-1 coefficients of the spherical harmonics
  69610. */
  69611. l2_1: Vector3;
  69612. /**
  69613. * The l2,0 coefficients of the spherical harmonics
  69614. */
  69615. l20: Vector3;
  69616. /**
  69617. * The l2,1 coefficients of the spherical harmonics
  69618. */
  69619. l21: Vector3;
  69620. /**
  69621. * The l2,2 coefficients of the spherical harmonics
  69622. */
  69623. l22: Vector3;
  69624. /**
  69625. * Adds a light to the spherical harmonics
  69626. * @param direction the direction of the light
  69627. * @param color the color of the light
  69628. * @param deltaSolidAngle the delta solid angle of the light
  69629. */
  69630. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69631. /**
  69632. * Scales the spherical harmonics by the given amount
  69633. * @param scale the amount to scale
  69634. */
  69635. scaleInPlace(scale: number): void;
  69636. /**
  69637. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69638. *
  69639. * ```
  69640. * E_lm = A_l * L_lm
  69641. * ```
  69642. *
  69643. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69644. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69645. * the scaling factors are given in equation 9.
  69646. */
  69647. convertIncidentRadianceToIrradiance(): void;
  69648. /**
  69649. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69650. *
  69651. * ```
  69652. * L = (1/pi) * E * rho
  69653. * ```
  69654. *
  69655. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69656. */
  69657. convertIrradianceToLambertianRadiance(): void;
  69658. /**
  69659. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69660. * required operations at run time.
  69661. *
  69662. * This is simply done by scaling back the SH with Ylm constants parameter.
  69663. * The trigonometric part being applied by the shader at run time.
  69664. */
  69665. preScaleForRendering(): void;
  69666. /**
  69667. * Constructs a spherical harmonics from an array.
  69668. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69669. * @returns the spherical harmonics
  69670. */
  69671. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69672. /**
  69673. * Gets the spherical harmonics from polynomial
  69674. * @param polynomial the spherical polynomial
  69675. * @returns the spherical harmonics
  69676. */
  69677. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69678. }
  69679. /**
  69680. * Class representing spherical polynomial coefficients to the 3rd degree
  69681. */
  69682. export class SphericalPolynomial {
  69683. private _harmonics;
  69684. /**
  69685. * The spherical harmonics used to create the polynomials.
  69686. */
  69687. readonly preScaledHarmonics: SphericalHarmonics;
  69688. /**
  69689. * The x coefficients of the spherical polynomial
  69690. */
  69691. x: Vector3;
  69692. /**
  69693. * The y coefficients of the spherical polynomial
  69694. */
  69695. y: Vector3;
  69696. /**
  69697. * The z coefficients of the spherical polynomial
  69698. */
  69699. z: Vector3;
  69700. /**
  69701. * The xx coefficients of the spherical polynomial
  69702. */
  69703. xx: Vector3;
  69704. /**
  69705. * The yy coefficients of the spherical polynomial
  69706. */
  69707. yy: Vector3;
  69708. /**
  69709. * The zz coefficients of the spherical polynomial
  69710. */
  69711. zz: Vector3;
  69712. /**
  69713. * The xy coefficients of the spherical polynomial
  69714. */
  69715. xy: Vector3;
  69716. /**
  69717. * The yz coefficients of the spherical polynomial
  69718. */
  69719. yz: Vector3;
  69720. /**
  69721. * The zx coefficients of the spherical polynomial
  69722. */
  69723. zx: Vector3;
  69724. /**
  69725. * Adds an ambient color to the spherical polynomial
  69726. * @param color the color to add
  69727. */
  69728. addAmbient(color: Color3): void;
  69729. /**
  69730. * Scales the spherical polynomial by the given amount
  69731. * @param scale the amount to scale
  69732. */
  69733. scaleInPlace(scale: number): void;
  69734. /**
  69735. * Gets the spherical polynomial from harmonics
  69736. * @param harmonics the spherical harmonics
  69737. * @returns the spherical polynomial
  69738. */
  69739. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69740. /**
  69741. * Constructs a spherical polynomial from an array.
  69742. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69743. * @returns the spherical polynomial
  69744. */
  69745. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69746. }
  69747. }
  69748. declare module BABYLON {
  69749. /**
  69750. * Define options used to create a render target texture
  69751. */
  69752. export class RenderTargetCreationOptions {
  69753. /**
  69754. * Specifies is mipmaps must be generated
  69755. */
  69756. generateMipMaps?: boolean;
  69757. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69758. generateDepthBuffer?: boolean;
  69759. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69760. generateStencilBuffer?: boolean;
  69761. /** Defines texture type (int by default) */
  69762. type?: number;
  69763. /** Defines sampling mode (trilinear by default) */
  69764. samplingMode?: number;
  69765. /** Defines format (RGBA by default) */
  69766. format?: number;
  69767. }
  69768. }
  69769. declare module BABYLON {
  69770. /**
  69771. * @hidden
  69772. **/
  69773. export class _AlphaState {
  69774. private _isAlphaBlendDirty;
  69775. private _isBlendFunctionParametersDirty;
  69776. private _isBlendEquationParametersDirty;
  69777. private _isBlendConstantsDirty;
  69778. private _alphaBlend;
  69779. private _blendFunctionParameters;
  69780. private _blendEquationParameters;
  69781. private _blendConstants;
  69782. /**
  69783. * Initializes the state.
  69784. */
  69785. constructor();
  69786. readonly isDirty: boolean;
  69787. alphaBlend: boolean;
  69788. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69789. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69790. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69791. reset(): void;
  69792. apply(gl: WebGLRenderingContext): void;
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /**
  69797. * @hidden
  69798. **/
  69799. export class _DepthCullingState {
  69800. private _isDepthTestDirty;
  69801. private _isDepthMaskDirty;
  69802. private _isDepthFuncDirty;
  69803. private _isCullFaceDirty;
  69804. private _isCullDirty;
  69805. private _isZOffsetDirty;
  69806. private _isFrontFaceDirty;
  69807. private _depthTest;
  69808. private _depthMask;
  69809. private _depthFunc;
  69810. private _cull;
  69811. private _cullFace;
  69812. private _zOffset;
  69813. private _frontFace;
  69814. /**
  69815. * Initializes the state.
  69816. */
  69817. constructor();
  69818. readonly isDirty: boolean;
  69819. zOffset: number;
  69820. cullFace: Nullable<number>;
  69821. cull: Nullable<boolean>;
  69822. depthFunc: Nullable<number>;
  69823. depthMask: boolean;
  69824. depthTest: boolean;
  69825. frontFace: Nullable<number>;
  69826. reset(): void;
  69827. apply(gl: WebGLRenderingContext): void;
  69828. }
  69829. }
  69830. declare module BABYLON {
  69831. /**
  69832. * @hidden
  69833. **/
  69834. export class _StencilState {
  69835. /** 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 */
  69836. static readonly ALWAYS: number;
  69837. /** Passed to stencilOperation to specify that stencil value must be kept */
  69838. static readonly KEEP: number;
  69839. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69840. static readonly REPLACE: number;
  69841. private _isStencilTestDirty;
  69842. private _isStencilMaskDirty;
  69843. private _isStencilFuncDirty;
  69844. private _isStencilOpDirty;
  69845. private _stencilTest;
  69846. private _stencilMask;
  69847. private _stencilFunc;
  69848. private _stencilFuncRef;
  69849. private _stencilFuncMask;
  69850. private _stencilOpStencilFail;
  69851. private _stencilOpDepthFail;
  69852. private _stencilOpStencilDepthPass;
  69853. readonly isDirty: boolean;
  69854. stencilFunc: number;
  69855. stencilFuncRef: number;
  69856. stencilFuncMask: number;
  69857. stencilOpStencilFail: number;
  69858. stencilOpDepthFail: number;
  69859. stencilOpStencilDepthPass: number;
  69860. stencilMask: number;
  69861. stencilTest: boolean;
  69862. constructor();
  69863. reset(): void;
  69864. apply(gl: WebGLRenderingContext): void;
  69865. }
  69866. }
  69867. declare module BABYLON {
  69868. /**
  69869. * @hidden
  69870. **/
  69871. export class _TimeToken {
  69872. _startTimeQuery: Nullable<WebGLQuery>;
  69873. _endTimeQuery: Nullable<WebGLQuery>;
  69874. _timeElapsedQuery: Nullable<WebGLQuery>;
  69875. _timeElapsedQueryEnded: boolean;
  69876. }
  69877. }
  69878. declare module BABYLON {
  69879. /**
  69880. * Class used to evalaute queries containing `and` and `or` operators
  69881. */
  69882. export class AndOrNotEvaluator {
  69883. /**
  69884. * Evaluate a query
  69885. * @param query defines the query to evaluate
  69886. * @param evaluateCallback defines the callback used to filter result
  69887. * @returns true if the query matches
  69888. */
  69889. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69890. private static _HandleParenthesisContent;
  69891. private static _SimplifyNegation;
  69892. }
  69893. }
  69894. declare module BABYLON {
  69895. /**
  69896. * Class used to store custom tags
  69897. */
  69898. export class Tags {
  69899. /**
  69900. * Adds support for tags on the given object
  69901. * @param obj defines the object to use
  69902. */
  69903. static EnableFor(obj: any): void;
  69904. /**
  69905. * Removes tags support
  69906. * @param obj defines the object to use
  69907. */
  69908. static DisableFor(obj: any): void;
  69909. /**
  69910. * Gets a boolean indicating if the given object has tags
  69911. * @param obj defines the object to use
  69912. * @returns a boolean
  69913. */
  69914. static HasTags(obj: any): boolean;
  69915. /**
  69916. * Gets the tags available on a given object
  69917. * @param obj defines the object to use
  69918. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69919. * @returns the tags
  69920. */
  69921. static GetTags(obj: any, asString?: boolean): any;
  69922. /**
  69923. * Adds tags to an object
  69924. * @param obj defines the object to use
  69925. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69926. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69927. */
  69928. static AddTagsTo(obj: any, tagsString: string): void;
  69929. /**
  69930. * @hidden
  69931. */
  69932. static _AddTagTo(obj: any, tag: string): void;
  69933. /**
  69934. * Removes specific tags from a specific object
  69935. * @param obj defines the object to use
  69936. * @param tagsString defines the tags to remove
  69937. */
  69938. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69939. /**
  69940. * @hidden
  69941. */
  69942. static _RemoveTagFrom(obj: any, tag: string): void;
  69943. /**
  69944. * Defines if tags hosted on an object match a given query
  69945. * @param obj defines the object to use
  69946. * @param tagsQuery defines the tag query
  69947. * @returns a boolean
  69948. */
  69949. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69950. }
  69951. }
  69952. declare module BABYLON {
  69953. /**
  69954. * Defines potential orientation for back face culling
  69955. */
  69956. export enum Orientation {
  69957. /**
  69958. * Clockwise
  69959. */
  69960. CW = 0,
  69961. /** Counter clockwise */
  69962. CCW = 1
  69963. }
  69964. /** Class used to represent a Bezier curve */
  69965. export class BezierCurve {
  69966. /**
  69967. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69968. * @param t defines the time
  69969. * @param x1 defines the left coordinate on X axis
  69970. * @param y1 defines the left coordinate on Y axis
  69971. * @param x2 defines the right coordinate on X axis
  69972. * @param y2 defines the right coordinate on Y axis
  69973. * @returns the interpolated value
  69974. */
  69975. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69976. }
  69977. /**
  69978. * Defines angle representation
  69979. */
  69980. export class Angle {
  69981. private _radians;
  69982. /**
  69983. * Creates an Angle object of "radians" radians (float).
  69984. * @param radians the angle in radians
  69985. */
  69986. constructor(radians: number);
  69987. /**
  69988. * Get value in degrees
  69989. * @returns the Angle value in degrees (float)
  69990. */
  69991. degrees(): number;
  69992. /**
  69993. * Get value in radians
  69994. * @returns the Angle value in radians (float)
  69995. */
  69996. radians(): number;
  69997. /**
  69998. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69999. * @param a defines first vector
  70000. * @param b defines second vector
  70001. * @returns a new Angle
  70002. */
  70003. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70004. /**
  70005. * Gets a new Angle object from the given float in radians
  70006. * @param radians defines the angle value in radians
  70007. * @returns a new Angle
  70008. */
  70009. static FromRadians(radians: number): Angle;
  70010. /**
  70011. * Gets a new Angle object from the given float in degrees
  70012. * @param degrees defines the angle value in degrees
  70013. * @returns a new Angle
  70014. */
  70015. static FromDegrees(degrees: number): Angle;
  70016. }
  70017. /**
  70018. * This represents an arc in a 2d space.
  70019. */
  70020. export class Arc2 {
  70021. /** Defines the start point of the arc */
  70022. startPoint: Vector2;
  70023. /** Defines the mid point of the arc */
  70024. midPoint: Vector2;
  70025. /** Defines the end point of the arc */
  70026. endPoint: Vector2;
  70027. /**
  70028. * Defines the center point of the arc.
  70029. */
  70030. centerPoint: Vector2;
  70031. /**
  70032. * Defines the radius of the arc.
  70033. */
  70034. radius: number;
  70035. /**
  70036. * Defines the angle of the arc (from mid point to end point).
  70037. */
  70038. angle: Angle;
  70039. /**
  70040. * Defines the start angle of the arc (from start point to middle point).
  70041. */
  70042. startAngle: Angle;
  70043. /**
  70044. * Defines the orientation of the arc (clock wise/counter clock wise).
  70045. */
  70046. orientation: Orientation;
  70047. /**
  70048. * Creates an Arc object from the three given points : start, middle and end.
  70049. * @param startPoint Defines the start point of the arc
  70050. * @param midPoint Defines the midlle point of the arc
  70051. * @param endPoint Defines the end point of the arc
  70052. */
  70053. constructor(
  70054. /** Defines the start point of the arc */
  70055. startPoint: Vector2,
  70056. /** Defines the mid point of the arc */
  70057. midPoint: Vector2,
  70058. /** Defines the end point of the arc */
  70059. endPoint: Vector2);
  70060. }
  70061. /**
  70062. * Represents a 2D path made up of multiple 2D points
  70063. */
  70064. export class Path2 {
  70065. private _points;
  70066. private _length;
  70067. /**
  70068. * If the path start and end point are the same
  70069. */
  70070. closed: boolean;
  70071. /**
  70072. * Creates a Path2 object from the starting 2D coordinates x and y.
  70073. * @param x the starting points x value
  70074. * @param y the starting points y value
  70075. */
  70076. constructor(x: number, y: number);
  70077. /**
  70078. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70079. * @param x the added points x value
  70080. * @param y the added points y value
  70081. * @returns the updated Path2.
  70082. */
  70083. addLineTo(x: number, y: number): Path2;
  70084. /**
  70085. * 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.
  70086. * @param midX middle point x value
  70087. * @param midY middle point y value
  70088. * @param endX end point x value
  70089. * @param endY end point y value
  70090. * @param numberOfSegments (default: 36)
  70091. * @returns the updated Path2.
  70092. */
  70093. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70094. /**
  70095. * Closes the Path2.
  70096. * @returns the Path2.
  70097. */
  70098. close(): Path2;
  70099. /**
  70100. * Gets the sum of the distance between each sequential point in the path
  70101. * @returns the Path2 total length (float).
  70102. */
  70103. length(): number;
  70104. /**
  70105. * Gets the points which construct the path
  70106. * @returns the Path2 internal array of points.
  70107. */
  70108. getPoints(): Vector2[];
  70109. /**
  70110. * Retreives the point at the distance aways from the starting point
  70111. * @param normalizedLengthPosition the length along the path to retreive the point from
  70112. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70113. */
  70114. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70115. /**
  70116. * Creates a new path starting from an x and y position
  70117. * @param x starting x value
  70118. * @param y starting y value
  70119. * @returns a new Path2 starting at the coordinates (x, y).
  70120. */
  70121. static StartingAt(x: number, y: number): Path2;
  70122. }
  70123. /**
  70124. * Represents a 3D path made up of multiple 3D points
  70125. */
  70126. export class Path3D {
  70127. /**
  70128. * an array of Vector3, the curve axis of the Path3D
  70129. */
  70130. path: Vector3[];
  70131. private _curve;
  70132. private _distances;
  70133. private _tangents;
  70134. private _normals;
  70135. private _binormals;
  70136. private _raw;
  70137. /**
  70138. * new Path3D(path, normal, raw)
  70139. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70140. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70141. * @param path an array of Vector3, the curve axis of the Path3D
  70142. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70143. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70144. */
  70145. constructor(
  70146. /**
  70147. * an array of Vector3, the curve axis of the Path3D
  70148. */
  70149. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70150. /**
  70151. * Returns the Path3D array of successive Vector3 designing its curve.
  70152. * @returns the Path3D array of successive Vector3 designing its curve.
  70153. */
  70154. getCurve(): Vector3[];
  70155. /**
  70156. * Returns an array populated with tangent vectors on each Path3D curve point.
  70157. * @returns an array populated with tangent vectors on each Path3D curve point.
  70158. */
  70159. getTangents(): Vector3[];
  70160. /**
  70161. * Returns an array populated with normal vectors on each Path3D curve point.
  70162. * @returns an array populated with normal vectors on each Path3D curve point.
  70163. */
  70164. getNormals(): Vector3[];
  70165. /**
  70166. * Returns an array populated with binormal vectors on each Path3D curve point.
  70167. * @returns an array populated with binormal vectors on each Path3D curve point.
  70168. */
  70169. getBinormals(): Vector3[];
  70170. /**
  70171. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70172. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70173. */
  70174. getDistances(): number[];
  70175. /**
  70176. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70177. * @param path path which all values are copied into the curves points
  70178. * @param firstNormal which should be projected onto the curve
  70179. * @returns the same object updated.
  70180. */
  70181. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70182. private _compute;
  70183. private _getFirstNonNullVector;
  70184. private _getLastNonNullVector;
  70185. private _normalVector;
  70186. }
  70187. /**
  70188. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70189. * A Curve3 is designed from a series of successive Vector3.
  70190. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70191. */
  70192. export class Curve3 {
  70193. private _points;
  70194. private _length;
  70195. /**
  70196. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70197. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70198. * @param v1 (Vector3) the control point
  70199. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70200. * @param nbPoints (integer) the wanted number of points in the curve
  70201. * @returns the created Curve3
  70202. */
  70203. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70204. /**
  70205. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70206. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70207. * @param v1 (Vector3) the first control point
  70208. * @param v2 (Vector3) the second control point
  70209. * @param v3 (Vector3) the end point of the Cubic Bezier
  70210. * @param nbPoints (integer) the wanted number of points in the curve
  70211. * @returns the created Curve3
  70212. */
  70213. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70214. /**
  70215. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70216. * @param p1 (Vector3) the origin point of the Hermite Spline
  70217. * @param t1 (Vector3) the tangent vector at the origin point
  70218. * @param p2 (Vector3) the end point of the Hermite Spline
  70219. * @param t2 (Vector3) the tangent vector at the end point
  70220. * @param nbPoints (integer) the wanted number of points in the curve
  70221. * @returns the created Curve3
  70222. */
  70223. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70224. /**
  70225. * Returns a Curve3 object along a CatmullRom Spline curve :
  70226. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70227. * @param nbPoints (integer) the wanted number of points between each curve control points
  70228. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70229. * @returns the created Curve3
  70230. */
  70231. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70232. /**
  70233. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70234. * A Curve3 is designed from a series of successive Vector3.
  70235. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70236. * @param points points which make up the curve
  70237. */
  70238. constructor(points: Vector3[]);
  70239. /**
  70240. * @returns the Curve3 stored array of successive Vector3
  70241. */
  70242. getPoints(): Vector3[];
  70243. /**
  70244. * @returns the computed length (float) of the curve.
  70245. */
  70246. length(): number;
  70247. /**
  70248. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70249. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70250. * curveA and curveB keep unchanged.
  70251. * @param curve the curve to continue from this curve
  70252. * @returns the newly constructed curve
  70253. */
  70254. continue(curve: DeepImmutable<Curve3>): Curve3;
  70255. private _computeLength;
  70256. }
  70257. }
  70258. declare module BABYLON {
  70259. /**
  70260. * This represents the main contract an easing function should follow.
  70261. * Easing functions are used throughout the animation system.
  70262. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70263. */
  70264. export interface IEasingFunction {
  70265. /**
  70266. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70267. * of the easing function.
  70268. * The link below provides some of the most common examples of easing functions.
  70269. * @see https://easings.net/
  70270. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70271. * @returns the corresponding value on the curve defined by the easing function
  70272. */
  70273. ease(gradient: number): number;
  70274. }
  70275. /**
  70276. * Base class used for every default easing function.
  70277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70278. */
  70279. export class EasingFunction implements IEasingFunction {
  70280. /**
  70281. * Interpolation follows the mathematical formula associated with the easing function.
  70282. */
  70283. static readonly EASINGMODE_EASEIN: number;
  70284. /**
  70285. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70286. */
  70287. static readonly EASINGMODE_EASEOUT: number;
  70288. /**
  70289. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70290. */
  70291. static readonly EASINGMODE_EASEINOUT: number;
  70292. private _easingMode;
  70293. /**
  70294. * Sets the easing mode of the current function.
  70295. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70296. */
  70297. setEasingMode(easingMode: number): void;
  70298. /**
  70299. * Gets the current easing mode.
  70300. * @returns the easing mode
  70301. */
  70302. getEasingMode(): number;
  70303. /**
  70304. * @hidden
  70305. */
  70306. easeInCore(gradient: number): number;
  70307. /**
  70308. * Given an input gradient between 0 and 1, this returns the corresponding value
  70309. * of the easing function.
  70310. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70311. * @returns the corresponding value on the curve defined by the easing function
  70312. */
  70313. ease(gradient: number): number;
  70314. }
  70315. /**
  70316. * Easing function with a circle shape (see link below).
  70317. * @see https://easings.net/#easeInCirc
  70318. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70319. */
  70320. export class CircleEase extends EasingFunction implements IEasingFunction {
  70321. /** @hidden */
  70322. easeInCore(gradient: number): number;
  70323. }
  70324. /**
  70325. * Easing function with a ease back shape (see link below).
  70326. * @see https://easings.net/#easeInBack
  70327. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70328. */
  70329. export class BackEase extends EasingFunction implements IEasingFunction {
  70330. /** Defines the amplitude of the function */
  70331. amplitude: number;
  70332. /**
  70333. * Instantiates a back ease easing
  70334. * @see https://easings.net/#easeInBack
  70335. * @param amplitude Defines the amplitude of the function
  70336. */
  70337. constructor(
  70338. /** Defines the amplitude of the function */
  70339. amplitude?: number);
  70340. /** @hidden */
  70341. easeInCore(gradient: number): number;
  70342. }
  70343. /**
  70344. * Easing function with a bouncing shape (see link below).
  70345. * @see https://easings.net/#easeInBounce
  70346. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70347. */
  70348. export class BounceEase extends EasingFunction implements IEasingFunction {
  70349. /** Defines the number of bounces */
  70350. bounces: number;
  70351. /** Defines the amplitude of the bounce */
  70352. bounciness: number;
  70353. /**
  70354. * Instantiates a bounce easing
  70355. * @see https://easings.net/#easeInBounce
  70356. * @param bounces Defines the number of bounces
  70357. * @param bounciness Defines the amplitude of the bounce
  70358. */
  70359. constructor(
  70360. /** Defines the number of bounces */
  70361. bounces?: number,
  70362. /** Defines the amplitude of the bounce */
  70363. bounciness?: number);
  70364. /** @hidden */
  70365. easeInCore(gradient: number): number;
  70366. }
  70367. /**
  70368. * Easing function with a power of 3 shape (see link below).
  70369. * @see https://easings.net/#easeInCubic
  70370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70371. */
  70372. export class CubicEase extends EasingFunction implements IEasingFunction {
  70373. /** @hidden */
  70374. easeInCore(gradient: number): number;
  70375. }
  70376. /**
  70377. * Easing function with an elastic shape (see link below).
  70378. * @see https://easings.net/#easeInElastic
  70379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70380. */
  70381. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70382. /** Defines the number of oscillations*/
  70383. oscillations: number;
  70384. /** Defines the amplitude of the oscillations*/
  70385. springiness: number;
  70386. /**
  70387. * Instantiates an elastic easing function
  70388. * @see https://easings.net/#easeInElastic
  70389. * @param oscillations Defines the number of oscillations
  70390. * @param springiness Defines the amplitude of the oscillations
  70391. */
  70392. constructor(
  70393. /** Defines the number of oscillations*/
  70394. oscillations?: number,
  70395. /** Defines the amplitude of the oscillations*/
  70396. springiness?: number);
  70397. /** @hidden */
  70398. easeInCore(gradient: number): number;
  70399. }
  70400. /**
  70401. * Easing function with an exponential shape (see link below).
  70402. * @see https://easings.net/#easeInExpo
  70403. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70404. */
  70405. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70406. /** Defines the exponent of the function */
  70407. exponent: number;
  70408. /**
  70409. * Instantiates an exponential easing function
  70410. * @see https://easings.net/#easeInExpo
  70411. * @param exponent Defines the exponent of the function
  70412. */
  70413. constructor(
  70414. /** Defines the exponent of the function */
  70415. exponent?: number);
  70416. /** @hidden */
  70417. easeInCore(gradient: number): number;
  70418. }
  70419. /**
  70420. * Easing function with a power shape (see link below).
  70421. * @see https://easings.net/#easeInQuad
  70422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70423. */
  70424. export class PowerEase extends EasingFunction implements IEasingFunction {
  70425. /** Defines the power of the function */
  70426. power: number;
  70427. /**
  70428. * Instantiates an power base easing function
  70429. * @see https://easings.net/#easeInQuad
  70430. * @param power Defines the power of the function
  70431. */
  70432. constructor(
  70433. /** Defines the power of the function */
  70434. power?: number);
  70435. /** @hidden */
  70436. easeInCore(gradient: number): number;
  70437. }
  70438. /**
  70439. * Easing function with a power of 2 shape (see link below).
  70440. * @see https://easings.net/#easeInQuad
  70441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70442. */
  70443. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70444. /** @hidden */
  70445. easeInCore(gradient: number): number;
  70446. }
  70447. /**
  70448. * Easing function with a power of 4 shape (see link below).
  70449. * @see https://easings.net/#easeInQuart
  70450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70451. */
  70452. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70453. /** @hidden */
  70454. easeInCore(gradient: number): number;
  70455. }
  70456. /**
  70457. * Easing function with a power of 5 shape (see link below).
  70458. * @see https://easings.net/#easeInQuint
  70459. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70460. */
  70461. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70462. /** @hidden */
  70463. easeInCore(gradient: number): number;
  70464. }
  70465. /**
  70466. * Easing function with a sin shape (see link below).
  70467. * @see https://easings.net/#easeInSine
  70468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70469. */
  70470. export class SineEase extends EasingFunction implements IEasingFunction {
  70471. /** @hidden */
  70472. easeInCore(gradient: number): number;
  70473. }
  70474. /**
  70475. * Easing function with a bezier shape (see link below).
  70476. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70477. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70478. */
  70479. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70480. /** Defines the x component of the start tangent in the bezier curve */
  70481. x1: number;
  70482. /** Defines the y component of the start tangent in the bezier curve */
  70483. y1: number;
  70484. /** Defines the x component of the end tangent in the bezier curve */
  70485. x2: number;
  70486. /** Defines the y component of the end tangent in the bezier curve */
  70487. y2: number;
  70488. /**
  70489. * Instantiates a bezier function
  70490. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70491. * @param x1 Defines the x component of the start tangent in the bezier curve
  70492. * @param y1 Defines the y component of the start tangent in the bezier curve
  70493. * @param x2 Defines the x component of the end tangent in the bezier curve
  70494. * @param y2 Defines the y component of the end tangent in the bezier curve
  70495. */
  70496. constructor(
  70497. /** Defines the x component of the start tangent in the bezier curve */
  70498. x1?: number,
  70499. /** Defines the y component of the start tangent in the bezier curve */
  70500. y1?: number,
  70501. /** Defines the x component of the end tangent in the bezier curve */
  70502. x2?: number,
  70503. /** Defines the y component of the end tangent in the bezier curve */
  70504. y2?: number);
  70505. /** @hidden */
  70506. easeInCore(gradient: number): number;
  70507. }
  70508. }
  70509. declare module BABYLON {
  70510. /**
  70511. * Defines an interface which represents an animation key frame
  70512. */
  70513. export interface IAnimationKey {
  70514. /**
  70515. * Frame of the key frame
  70516. */
  70517. frame: number;
  70518. /**
  70519. * Value at the specifies key frame
  70520. */
  70521. value: any;
  70522. /**
  70523. * The input tangent for the cubic hermite spline
  70524. */
  70525. inTangent?: any;
  70526. /**
  70527. * The output tangent for the cubic hermite spline
  70528. */
  70529. outTangent?: any;
  70530. /**
  70531. * The animation interpolation type
  70532. */
  70533. interpolation?: AnimationKeyInterpolation;
  70534. }
  70535. /**
  70536. * Enum for the animation key frame interpolation type
  70537. */
  70538. export enum AnimationKeyInterpolation {
  70539. /**
  70540. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70541. */
  70542. STEP = 1
  70543. }
  70544. }
  70545. declare module BABYLON {
  70546. /**
  70547. * Represents the range of an animation
  70548. */
  70549. export class AnimationRange {
  70550. /**The name of the animation range**/
  70551. name: string;
  70552. /**The starting frame of the animation */
  70553. from: number;
  70554. /**The ending frame of the animation*/
  70555. to: number;
  70556. /**
  70557. * Initializes the range of an animation
  70558. * @param name The name of the animation range
  70559. * @param from The starting frame of the animation
  70560. * @param to The ending frame of the animation
  70561. */
  70562. constructor(
  70563. /**The name of the animation range**/
  70564. name: string,
  70565. /**The starting frame of the animation */
  70566. from: number,
  70567. /**The ending frame of the animation*/
  70568. to: number);
  70569. /**
  70570. * Makes a copy of the animation range
  70571. * @returns A copy of the animation range
  70572. */
  70573. clone(): AnimationRange;
  70574. }
  70575. }
  70576. declare module BABYLON {
  70577. /**
  70578. * Composed of a frame, and an action function
  70579. */
  70580. export class AnimationEvent {
  70581. /** The frame for which the event is triggered **/
  70582. frame: number;
  70583. /** The event to perform when triggered **/
  70584. action: (currentFrame: number) => void;
  70585. /** Specifies if the event should be triggered only once**/
  70586. onlyOnce?: boolean | undefined;
  70587. /**
  70588. * Specifies if the animation event is done
  70589. */
  70590. isDone: boolean;
  70591. /**
  70592. * Initializes the animation event
  70593. * @param frame The frame for which the event is triggered
  70594. * @param action The event to perform when triggered
  70595. * @param onlyOnce Specifies if the event should be triggered only once
  70596. */
  70597. constructor(
  70598. /** The frame for which the event is triggered **/
  70599. frame: number,
  70600. /** The event to perform when triggered **/
  70601. action: (currentFrame: number) => void,
  70602. /** Specifies if the event should be triggered only once**/
  70603. onlyOnce?: boolean | undefined);
  70604. /** @hidden */
  70605. _clone(): AnimationEvent;
  70606. }
  70607. }
  70608. declare module BABYLON {
  70609. /**
  70610. * Interface used to define a behavior
  70611. */
  70612. export interface Behavior<T> {
  70613. /** gets or sets behavior's name */
  70614. name: string;
  70615. /**
  70616. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70617. */
  70618. init(): void;
  70619. /**
  70620. * Called when the behavior is attached to a target
  70621. * @param target defines the target where the behavior is attached to
  70622. */
  70623. attach(target: T): void;
  70624. /**
  70625. * Called when the behavior is detached from its target
  70626. */
  70627. detach(): void;
  70628. }
  70629. /**
  70630. * Interface implemented by classes supporting behaviors
  70631. */
  70632. export interface IBehaviorAware<T> {
  70633. /**
  70634. * Attach a behavior
  70635. * @param behavior defines the behavior to attach
  70636. * @returns the current host
  70637. */
  70638. addBehavior(behavior: Behavior<T>): T;
  70639. /**
  70640. * Remove a behavior from the current object
  70641. * @param behavior defines the behavior to detach
  70642. * @returns the current host
  70643. */
  70644. removeBehavior(behavior: Behavior<T>): T;
  70645. /**
  70646. * Gets a behavior using its name to search
  70647. * @param name defines the name to search
  70648. * @returns the behavior or null if not found
  70649. */
  70650. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70651. }
  70652. }
  70653. declare module BABYLON {
  70654. /**
  70655. * Defines an array and its length.
  70656. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70657. */
  70658. export interface ISmartArrayLike<T> {
  70659. /**
  70660. * The data of the array.
  70661. */
  70662. data: Array<T>;
  70663. /**
  70664. * The active length of the array.
  70665. */
  70666. length: number;
  70667. }
  70668. /**
  70669. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70670. */
  70671. export class SmartArray<T> implements ISmartArrayLike<T> {
  70672. /**
  70673. * The full set of data from the array.
  70674. */
  70675. data: Array<T>;
  70676. /**
  70677. * The active length of the array.
  70678. */
  70679. length: number;
  70680. protected _id: number;
  70681. /**
  70682. * Instantiates a Smart Array.
  70683. * @param capacity defines the default capacity of the array.
  70684. */
  70685. constructor(capacity: number);
  70686. /**
  70687. * Pushes a value at the end of the active data.
  70688. * @param value defines the object to push in the array.
  70689. */
  70690. push(value: T): void;
  70691. /**
  70692. * Iterates over the active data and apply the lambda to them.
  70693. * @param func defines the action to apply on each value.
  70694. */
  70695. forEach(func: (content: T) => void): void;
  70696. /**
  70697. * Sorts the full sets of data.
  70698. * @param compareFn defines the comparison function to apply.
  70699. */
  70700. sort(compareFn: (a: T, b: T) => number): void;
  70701. /**
  70702. * Resets the active data to an empty array.
  70703. */
  70704. reset(): void;
  70705. /**
  70706. * Releases all the data from the array as well as the array.
  70707. */
  70708. dispose(): void;
  70709. /**
  70710. * Concats the active data with a given array.
  70711. * @param array defines the data to concatenate with.
  70712. */
  70713. concat(array: any): void;
  70714. /**
  70715. * Returns the position of a value in the active data.
  70716. * @param value defines the value to find the index for
  70717. * @returns the index if found in the active data otherwise -1
  70718. */
  70719. indexOf(value: T): number;
  70720. /**
  70721. * Returns whether an element is part of the active data.
  70722. * @param value defines the value to look for
  70723. * @returns true if found in the active data otherwise false
  70724. */
  70725. contains(value: T): boolean;
  70726. private static _GlobalId;
  70727. }
  70728. /**
  70729. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70730. * The data in this array can only be present once
  70731. */
  70732. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70733. private _duplicateId;
  70734. /**
  70735. * Pushes a value at the end of the active data.
  70736. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70737. * @param value defines the object to push in the array.
  70738. */
  70739. push(value: T): void;
  70740. /**
  70741. * Pushes a value at the end of the active data.
  70742. * If the data is already present, it won t be added again
  70743. * @param value defines the object to push in the array.
  70744. * @returns true if added false if it was already present
  70745. */
  70746. pushNoDuplicate(value: T): boolean;
  70747. /**
  70748. * Resets the active data to an empty array.
  70749. */
  70750. reset(): void;
  70751. /**
  70752. * Concats the active data with a given array.
  70753. * This ensures no dupplicate will be present in the result.
  70754. * @param array defines the data to concatenate with.
  70755. */
  70756. concatWithNoDuplicate(array: any): void;
  70757. }
  70758. }
  70759. declare module BABYLON {
  70760. /**
  70761. * @ignore
  70762. * This is a list of all the different input types that are available in the application.
  70763. * Fo instance: ArcRotateCameraGamepadInput...
  70764. */
  70765. export var CameraInputTypes: {};
  70766. /**
  70767. * This is the contract to implement in order to create a new input class.
  70768. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70769. */
  70770. export interface ICameraInput<TCamera extends Camera> {
  70771. /**
  70772. * Defines the camera the input is attached to.
  70773. */
  70774. camera: Nullable<TCamera>;
  70775. /**
  70776. * Gets the class name of the current intput.
  70777. * @returns the class name
  70778. */
  70779. getClassName(): string;
  70780. /**
  70781. * Get the friendly name associated with the input class.
  70782. * @returns the input friendly name
  70783. */
  70784. getSimpleName(): string;
  70785. /**
  70786. * Attach the input controls to a specific dom element to get the input from.
  70787. * @param element Defines the element the controls should be listened from
  70788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70789. */
  70790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70791. /**
  70792. * Detach the current controls from the specified dom element.
  70793. * @param element Defines the element to stop listening the inputs from
  70794. */
  70795. detachControl(element: Nullable<HTMLElement>): void;
  70796. /**
  70797. * Update the current camera state depending on the inputs that have been used this frame.
  70798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70799. */
  70800. checkInputs?: () => void;
  70801. }
  70802. /**
  70803. * Represents a map of input types to input instance or input index to input instance.
  70804. */
  70805. export interface CameraInputsMap<TCamera extends Camera> {
  70806. /**
  70807. * Accessor to the input by input type.
  70808. */
  70809. [name: string]: ICameraInput<TCamera>;
  70810. /**
  70811. * Accessor to the input by input index.
  70812. */
  70813. [idx: number]: ICameraInput<TCamera>;
  70814. }
  70815. /**
  70816. * This represents the input manager used within a camera.
  70817. * It helps dealing with all the different kind of input attached to a camera.
  70818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70819. */
  70820. export class CameraInputsManager<TCamera extends Camera> {
  70821. /**
  70822. * Defines the list of inputs attahed to the camera.
  70823. */
  70824. attached: CameraInputsMap<TCamera>;
  70825. /**
  70826. * Defines the dom element the camera is collecting inputs from.
  70827. * This is null if the controls have not been attached.
  70828. */
  70829. attachedElement: Nullable<HTMLElement>;
  70830. /**
  70831. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70832. */
  70833. noPreventDefault: boolean;
  70834. /**
  70835. * Defined the camera the input manager belongs to.
  70836. */
  70837. camera: TCamera;
  70838. /**
  70839. * Update the current camera state depending on the inputs that have been used this frame.
  70840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70841. */
  70842. checkInputs: () => void;
  70843. /**
  70844. * Instantiate a new Camera Input Manager.
  70845. * @param camera Defines the camera the input manager blongs to
  70846. */
  70847. constructor(camera: TCamera);
  70848. /**
  70849. * Add an input method to a camera
  70850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70851. * @param input camera input method
  70852. */
  70853. add(input: ICameraInput<TCamera>): void;
  70854. /**
  70855. * Remove a specific input method from a camera
  70856. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70857. * @param inputToRemove camera input method
  70858. */
  70859. remove(inputToRemove: ICameraInput<TCamera>): void;
  70860. /**
  70861. * Remove a specific input type from a camera
  70862. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70863. * @param inputType the type of the input to remove
  70864. */
  70865. removeByType(inputType: string): void;
  70866. private _addCheckInputs;
  70867. /**
  70868. * Attach the input controls to the currently attached dom element to listen the events from.
  70869. * @param input Defines the input to attach
  70870. */
  70871. attachInput(input: ICameraInput<TCamera>): void;
  70872. /**
  70873. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70874. * @param element Defines the dom element to collect the events from
  70875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70876. */
  70877. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70878. /**
  70879. * Detach the current manager inputs controls from a specific dom element.
  70880. * @param element Defines the dom element to collect the events from
  70881. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70882. */
  70883. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70884. /**
  70885. * Rebuild the dynamic inputCheck function from the current list of
  70886. * defined inputs in the manager.
  70887. */
  70888. rebuildInputCheck(): void;
  70889. /**
  70890. * Remove all attached input methods from a camera
  70891. */
  70892. clear(): void;
  70893. /**
  70894. * Serialize the current input manager attached to a camera.
  70895. * This ensures than once parsed,
  70896. * the input associated to the camera will be identical to the current ones
  70897. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70898. */
  70899. serialize(serializedCamera: any): void;
  70900. /**
  70901. * Parses an input manager serialized JSON to restore the previous list of inputs
  70902. * and states associated to a camera.
  70903. * @param parsedCamera Defines the JSON to parse
  70904. */
  70905. parse(parsedCamera: any): void;
  70906. }
  70907. }
  70908. declare module BABYLON {
  70909. /**
  70910. * @hidden
  70911. */
  70912. export class IntersectionInfo {
  70913. bu: Nullable<number>;
  70914. bv: Nullable<number>;
  70915. distance: number;
  70916. faceId: number;
  70917. subMeshId: number;
  70918. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70919. }
  70920. }
  70921. declare module BABYLON {
  70922. /**
  70923. * Represens a plane by the equation ax + by + cz + d = 0
  70924. */
  70925. export class Plane {
  70926. private static _TmpMatrix;
  70927. /**
  70928. * Normal of the plane (a,b,c)
  70929. */
  70930. normal: Vector3;
  70931. /**
  70932. * d component of the plane
  70933. */
  70934. d: number;
  70935. /**
  70936. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70937. * @param a a component of the plane
  70938. * @param b b component of the plane
  70939. * @param c c component of the plane
  70940. * @param d d component of the plane
  70941. */
  70942. constructor(a: number, b: number, c: number, d: number);
  70943. /**
  70944. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70945. */
  70946. asArray(): number[];
  70947. /**
  70948. * @returns a new plane copied from the current Plane.
  70949. */
  70950. clone(): Plane;
  70951. /**
  70952. * @returns the string "Plane".
  70953. */
  70954. getClassName(): string;
  70955. /**
  70956. * @returns the Plane hash code.
  70957. */
  70958. getHashCode(): number;
  70959. /**
  70960. * Normalize the current Plane in place.
  70961. * @returns the updated Plane.
  70962. */
  70963. normalize(): Plane;
  70964. /**
  70965. * Applies a transformation the plane and returns the result
  70966. * @param transformation the transformation matrix to be applied to the plane
  70967. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70968. */
  70969. transform(transformation: DeepImmutable<Matrix>): Plane;
  70970. /**
  70971. * Calcualtte the dot product between the point and the plane normal
  70972. * @param point point to calculate the dot product with
  70973. * @returns the dot product (float) of the point coordinates and the plane normal.
  70974. */
  70975. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70976. /**
  70977. * Updates the current Plane from the plane defined by the three given points.
  70978. * @param point1 one of the points used to contruct the plane
  70979. * @param point2 one of the points used to contruct the plane
  70980. * @param point3 one of the points used to contruct the plane
  70981. * @returns the updated Plane.
  70982. */
  70983. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70984. /**
  70985. * Checks if the plane is facing a given direction
  70986. * @param direction the direction to check if the plane is facing
  70987. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70988. * @returns True is the vector "direction" is the same side than the plane normal.
  70989. */
  70990. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70991. /**
  70992. * Calculates the distance to a point
  70993. * @param point point to calculate distance to
  70994. * @returns the signed distance (float) from the given point to the Plane.
  70995. */
  70996. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70997. /**
  70998. * Creates a plane from an array
  70999. * @param array the array to create a plane from
  71000. * @returns a new Plane from the given array.
  71001. */
  71002. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71003. /**
  71004. * Creates a plane from three points
  71005. * @param point1 point used to create the plane
  71006. * @param point2 point used to create the plane
  71007. * @param point3 point used to create the plane
  71008. * @returns a new Plane defined by the three given points.
  71009. */
  71010. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71011. /**
  71012. * Creates a plane from an origin point and a normal
  71013. * @param origin origin of the plane to be constructed
  71014. * @param normal normal of the plane to be constructed
  71015. * @returns a new Plane the normal vector to this plane at the given origin point.
  71016. * Note : the vector "normal" is updated because normalized.
  71017. */
  71018. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71019. /**
  71020. * Calculates the distance from a plane and a point
  71021. * @param origin origin of the plane to be constructed
  71022. * @param normal normal of the plane to be constructed
  71023. * @param point point to calculate distance to
  71024. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71025. */
  71026. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. /**
  71031. * Class used to store bounding sphere information
  71032. */
  71033. export class BoundingSphere {
  71034. /**
  71035. * Gets the center of the bounding sphere in local space
  71036. */
  71037. readonly center: Vector3;
  71038. /**
  71039. * Radius of the bounding sphere in local space
  71040. */
  71041. radius: number;
  71042. /**
  71043. * Gets the center of the bounding sphere in world space
  71044. */
  71045. readonly centerWorld: Vector3;
  71046. /**
  71047. * Radius of the bounding sphere in world space
  71048. */
  71049. radiusWorld: number;
  71050. /**
  71051. * Gets the minimum vector in local space
  71052. */
  71053. readonly minimum: Vector3;
  71054. /**
  71055. * Gets the maximum vector in local space
  71056. */
  71057. readonly maximum: Vector3;
  71058. private _worldMatrix;
  71059. private static readonly TmpVector3;
  71060. /**
  71061. * Creates a new bounding sphere
  71062. * @param min defines the minimum vector (in local space)
  71063. * @param max defines the maximum vector (in local space)
  71064. * @param worldMatrix defines the new world matrix
  71065. */
  71066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71067. /**
  71068. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71069. * @param min defines the new minimum vector (in local space)
  71070. * @param max defines the new maximum vector (in local space)
  71071. * @param worldMatrix defines the new world matrix
  71072. */
  71073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71074. /**
  71075. * Scale the current bounding sphere by applying a scale factor
  71076. * @param factor defines the scale factor to apply
  71077. * @returns the current bounding box
  71078. */
  71079. scale(factor: number): BoundingSphere;
  71080. /**
  71081. * Gets the world matrix of the bounding box
  71082. * @returns a matrix
  71083. */
  71084. getWorldMatrix(): DeepImmutable<Matrix>;
  71085. /** @hidden */
  71086. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71087. /**
  71088. * Tests if the bounding sphere is intersecting the frustum planes
  71089. * @param frustumPlanes defines the frustum planes to test
  71090. * @returns true if there is an intersection
  71091. */
  71092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71093. /**
  71094. * Tests if the bounding sphere center is in between the frustum planes.
  71095. * Used for optimistic fast inclusion.
  71096. * @param frustumPlanes defines the frustum planes to test
  71097. * @returns true if the sphere center is in between the frustum planes
  71098. */
  71099. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71100. /**
  71101. * Tests if a point is inside the bounding sphere
  71102. * @param point defines the point to test
  71103. * @returns true if the point is inside the bounding sphere
  71104. */
  71105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71106. /**
  71107. * Checks if two sphere intersct
  71108. * @param sphere0 sphere 0
  71109. * @param sphere1 sphere 1
  71110. * @returns true if the speres intersect
  71111. */
  71112. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71113. }
  71114. }
  71115. declare module BABYLON {
  71116. /**
  71117. * Class used to store bounding box information
  71118. */
  71119. export class BoundingBox implements ICullable {
  71120. /**
  71121. * Gets the 8 vectors representing the bounding box in local space
  71122. */
  71123. readonly vectors: Vector3[];
  71124. /**
  71125. * Gets the center of the bounding box in local space
  71126. */
  71127. readonly center: Vector3;
  71128. /**
  71129. * Gets the center of the bounding box in world space
  71130. */
  71131. readonly centerWorld: Vector3;
  71132. /**
  71133. * Gets the extend size in local space
  71134. */
  71135. readonly extendSize: Vector3;
  71136. /**
  71137. * Gets the extend size in world space
  71138. */
  71139. readonly extendSizeWorld: Vector3;
  71140. /**
  71141. * Gets the OBB (object bounding box) directions
  71142. */
  71143. readonly directions: Vector3[];
  71144. /**
  71145. * Gets the 8 vectors representing the bounding box in world space
  71146. */
  71147. readonly vectorsWorld: Vector3[];
  71148. /**
  71149. * Gets the minimum vector in world space
  71150. */
  71151. readonly minimumWorld: Vector3;
  71152. /**
  71153. * Gets the maximum vector in world space
  71154. */
  71155. readonly maximumWorld: Vector3;
  71156. /**
  71157. * Gets the minimum vector in local space
  71158. */
  71159. readonly minimum: Vector3;
  71160. /**
  71161. * Gets the maximum vector in local space
  71162. */
  71163. readonly maximum: Vector3;
  71164. private _worldMatrix;
  71165. private static readonly TmpVector3;
  71166. /**
  71167. * @hidden
  71168. */
  71169. _tag: number;
  71170. /**
  71171. * Creates a new bounding box
  71172. * @param min defines the minimum vector (in local space)
  71173. * @param max defines the maximum vector (in local space)
  71174. * @param worldMatrix defines the new world matrix
  71175. */
  71176. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71177. /**
  71178. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71179. * @param min defines the new minimum vector (in local space)
  71180. * @param max defines the new maximum vector (in local space)
  71181. * @param worldMatrix defines the new world matrix
  71182. */
  71183. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71184. /**
  71185. * Scale the current bounding box by applying a scale factor
  71186. * @param factor defines the scale factor to apply
  71187. * @returns the current bounding box
  71188. */
  71189. scale(factor: number): BoundingBox;
  71190. /**
  71191. * Gets the world matrix of the bounding box
  71192. * @returns a matrix
  71193. */
  71194. getWorldMatrix(): DeepImmutable<Matrix>;
  71195. /** @hidden */
  71196. _update(world: DeepImmutable<Matrix>): void;
  71197. /**
  71198. * Tests if the bounding box is intersecting the frustum planes
  71199. * @param frustumPlanes defines the frustum planes to test
  71200. * @returns true if there is an intersection
  71201. */
  71202. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71203. /**
  71204. * Tests if the bounding box is entirely inside the frustum planes
  71205. * @param frustumPlanes defines the frustum planes to test
  71206. * @returns true if there is an inclusion
  71207. */
  71208. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71209. /**
  71210. * Tests if a point is inside the bounding box
  71211. * @param point defines the point to test
  71212. * @returns true if the point is inside the bounding box
  71213. */
  71214. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71215. /**
  71216. * Tests if the bounding box intersects with a bounding sphere
  71217. * @param sphere defines the sphere to test
  71218. * @returns true if there is an intersection
  71219. */
  71220. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71221. /**
  71222. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71223. * @param min defines the min vector to use
  71224. * @param max defines the max vector to use
  71225. * @returns true if there is an intersection
  71226. */
  71227. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71228. /**
  71229. * Tests if two bounding boxes are intersections
  71230. * @param box0 defines the first box to test
  71231. * @param box1 defines the second box to test
  71232. * @returns true if there is an intersection
  71233. */
  71234. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71235. /**
  71236. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71237. * @param minPoint defines the minimum vector of the bounding box
  71238. * @param maxPoint defines the maximum vector of the bounding box
  71239. * @param sphereCenter defines the sphere center
  71240. * @param sphereRadius defines the sphere radius
  71241. * @returns true if there is an intersection
  71242. */
  71243. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71244. /**
  71245. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71246. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71247. * @param frustumPlanes defines the frustum planes to test
  71248. * @return true if there is an inclusion
  71249. */
  71250. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71251. /**
  71252. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71253. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71254. * @param frustumPlanes defines the frustum planes to test
  71255. * @return true if there is an intersection
  71256. */
  71257. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71258. }
  71259. }
  71260. declare module BABYLON {
  71261. /** @hidden */
  71262. export class Collider {
  71263. /** Define if a collision was found */
  71264. collisionFound: boolean;
  71265. /**
  71266. * Define last intersection point in local space
  71267. */
  71268. intersectionPoint: Vector3;
  71269. /**
  71270. * Define last collided mesh
  71271. */
  71272. collidedMesh: Nullable<AbstractMesh>;
  71273. private _collisionPoint;
  71274. private _planeIntersectionPoint;
  71275. private _tempVector;
  71276. private _tempVector2;
  71277. private _tempVector3;
  71278. private _tempVector4;
  71279. private _edge;
  71280. private _baseToVertex;
  71281. private _destinationPoint;
  71282. private _slidePlaneNormal;
  71283. private _displacementVector;
  71284. /** @hidden */
  71285. _radius: Vector3;
  71286. /** @hidden */
  71287. _retry: number;
  71288. private _velocity;
  71289. private _basePoint;
  71290. private _epsilon;
  71291. /** @hidden */
  71292. _velocityWorldLength: number;
  71293. /** @hidden */
  71294. _basePointWorld: Vector3;
  71295. private _velocityWorld;
  71296. private _normalizedVelocity;
  71297. /** @hidden */
  71298. _initialVelocity: Vector3;
  71299. /** @hidden */
  71300. _initialPosition: Vector3;
  71301. private _nearestDistance;
  71302. private _collisionMask;
  71303. collisionMask: number;
  71304. /**
  71305. * Gets the plane normal used to compute the sliding response (in local space)
  71306. */
  71307. readonly slidePlaneNormal: Vector3;
  71308. /** @hidden */
  71309. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71310. /** @hidden */
  71311. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71312. /** @hidden */
  71313. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71314. /** @hidden */
  71315. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71316. /** @hidden */
  71317. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71318. /** @hidden */
  71319. _getResponse(pos: Vector3, vel: Vector3): void;
  71320. }
  71321. }
  71322. declare module BABYLON {
  71323. /**
  71324. * Interface for cullable objects
  71325. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71326. */
  71327. export interface ICullable {
  71328. /**
  71329. * Checks if the object or part of the object is in the frustum
  71330. * @param frustumPlanes Camera near/planes
  71331. * @returns true if the object is in frustum otherwise false
  71332. */
  71333. isInFrustum(frustumPlanes: Plane[]): boolean;
  71334. /**
  71335. * Checks if a cullable object (mesh...) is in the camera frustum
  71336. * Unlike isInFrustum this cheks the full bounding box
  71337. * @param frustumPlanes Camera near/planes
  71338. * @returns true if the object is in frustum otherwise false
  71339. */
  71340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71341. }
  71342. /**
  71343. * Info for a bounding data of a mesh
  71344. */
  71345. export class BoundingInfo implements ICullable {
  71346. /**
  71347. * Bounding box for the mesh
  71348. */
  71349. readonly boundingBox: BoundingBox;
  71350. /**
  71351. * Bounding sphere for the mesh
  71352. */
  71353. readonly boundingSphere: BoundingSphere;
  71354. private _isLocked;
  71355. private static readonly TmpVector3;
  71356. /**
  71357. * Constructs bounding info
  71358. * @param minimum min vector of the bounding box/sphere
  71359. * @param maximum max vector of the bounding box/sphere
  71360. * @param worldMatrix defines the new world matrix
  71361. */
  71362. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71363. /**
  71364. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71365. * @param min defines the new minimum vector (in local space)
  71366. * @param max defines the new maximum vector (in local space)
  71367. * @param worldMatrix defines the new world matrix
  71368. */
  71369. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71370. /**
  71371. * min vector of the bounding box/sphere
  71372. */
  71373. readonly minimum: Vector3;
  71374. /**
  71375. * max vector of the bounding box/sphere
  71376. */
  71377. readonly maximum: Vector3;
  71378. /**
  71379. * If the info is locked and won't be updated to avoid perf overhead
  71380. */
  71381. isLocked: boolean;
  71382. /**
  71383. * Updates the bounding sphere and box
  71384. * @param world world matrix to be used to update
  71385. */
  71386. update(world: DeepImmutable<Matrix>): void;
  71387. /**
  71388. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71389. * @param center New center of the bounding info
  71390. * @param extend New extend of the bounding info
  71391. * @returns the current bounding info
  71392. */
  71393. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71394. /**
  71395. * Scale the current bounding info by applying a scale factor
  71396. * @param factor defines the scale factor to apply
  71397. * @returns the current bounding info
  71398. */
  71399. scale(factor: number): BoundingInfo;
  71400. /**
  71401. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71402. * @param frustumPlanes defines the frustum to test
  71403. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71404. * @returns true if the bounding info is in the frustum planes
  71405. */
  71406. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71407. /**
  71408. * Gets the world distance between the min and max points of the bounding box
  71409. */
  71410. readonly diagonalLength: number;
  71411. /**
  71412. * Checks if a cullable object (mesh...) is in the camera frustum
  71413. * Unlike isInFrustum this cheks the full bounding box
  71414. * @param frustumPlanes Camera near/planes
  71415. * @returns true if the object is in frustum otherwise false
  71416. */
  71417. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71418. /** @hidden */
  71419. _checkCollision(collider: Collider): boolean;
  71420. /**
  71421. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71422. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71423. * @param point the point to check intersection with
  71424. * @returns if the point intersects
  71425. */
  71426. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71427. /**
  71428. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71429. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71430. * @param boundingInfo the bounding info to check intersection with
  71431. * @param precise if the intersection should be done using OBB
  71432. * @returns if the bounding info intersects
  71433. */
  71434. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71435. }
  71436. }
  71437. declare module BABYLON {
  71438. /**
  71439. * Extracts minimum and maximum values from a list of indexed positions
  71440. * @param positions defines the positions to use
  71441. * @param indices defines the indices to the positions
  71442. * @param indexStart defines the start index
  71443. * @param indexCount defines the end index
  71444. * @param bias defines bias value to add to the result
  71445. * @return minimum and maximum values
  71446. */
  71447. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71448. minimum: Vector3;
  71449. maximum: Vector3;
  71450. };
  71451. /**
  71452. * Extracts minimum and maximum values from a list of positions
  71453. * @param positions defines the positions to use
  71454. * @param start defines the start index in the positions array
  71455. * @param count defines the number of positions to handle
  71456. * @param bias defines bias value to add to the result
  71457. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71458. * @return minimum and maximum values
  71459. */
  71460. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71461. minimum: Vector3;
  71462. maximum: Vector3;
  71463. };
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * Enum that determines the text-wrapping mode to use.
  71468. */
  71469. export enum InspectableType {
  71470. /**
  71471. * Checkbox for booleans
  71472. */
  71473. Checkbox = 0,
  71474. /**
  71475. * Sliders for numbers
  71476. */
  71477. Slider = 1,
  71478. /**
  71479. * Vector3
  71480. */
  71481. Vector3 = 2,
  71482. /**
  71483. * Quaternions
  71484. */
  71485. Quaternion = 3,
  71486. /**
  71487. * Color3
  71488. */
  71489. Color3 = 4,
  71490. /**
  71491. * String
  71492. */
  71493. String = 5
  71494. }
  71495. /**
  71496. * Interface used to define custom inspectable properties.
  71497. * This interface is used by the inspector to display custom property grids
  71498. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71499. */
  71500. export interface IInspectable {
  71501. /**
  71502. * Gets the label to display
  71503. */
  71504. label: string;
  71505. /**
  71506. * Gets the name of the property to edit
  71507. */
  71508. propertyName: string;
  71509. /**
  71510. * Gets the type of the editor to use
  71511. */
  71512. type: InspectableType;
  71513. /**
  71514. * Gets the minimum value of the property when using in "slider" mode
  71515. */
  71516. min?: number;
  71517. /**
  71518. * Gets the maximum value of the property when using in "slider" mode
  71519. */
  71520. max?: number;
  71521. /**
  71522. * Gets the setp to use when using in "slider" mode
  71523. */
  71524. step?: number;
  71525. }
  71526. }
  71527. declare module BABYLON {
  71528. /**
  71529. * Class used to provide helper for timing
  71530. */
  71531. export class TimingTools {
  71532. /**
  71533. * Polyfill for setImmediate
  71534. * @param action defines the action to execute after the current execution block
  71535. */
  71536. static SetImmediate(action: () => void): void;
  71537. }
  71538. }
  71539. declare module BABYLON {
  71540. /**
  71541. * Class used to enable instatition of objects by class name
  71542. */
  71543. export class InstantiationTools {
  71544. /**
  71545. * Use this object to register external classes like custom textures or material
  71546. * to allow the laoders to instantiate them
  71547. */
  71548. static RegisteredExternalClasses: {
  71549. [key: string]: Object;
  71550. };
  71551. /**
  71552. * Tries to instantiate a new object from a given class name
  71553. * @param className defines the class name to instantiate
  71554. * @returns the new object or null if the system was not able to do the instantiation
  71555. */
  71556. static Instantiate(className: string): any;
  71557. }
  71558. }
  71559. declare module BABYLON {
  71560. /**
  71561. * This represents the required contract to create a new type of texture loader.
  71562. */
  71563. export interface IInternalTextureLoader {
  71564. /**
  71565. * Defines wether the loader supports cascade loading the different faces.
  71566. */
  71567. supportCascades: boolean;
  71568. /**
  71569. * This returns if the loader support the current file information.
  71570. * @param extension defines the file extension of the file being loaded
  71571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71572. * @param fallback defines the fallback internal texture if any
  71573. * @param isBase64 defines whether the texture is encoded as a base64
  71574. * @param isBuffer defines whether the texture data are stored as a buffer
  71575. * @returns true if the loader can load the specified file
  71576. */
  71577. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71578. /**
  71579. * Transform the url before loading if required.
  71580. * @param rootUrl the url of the texture
  71581. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71582. * @returns the transformed texture
  71583. */
  71584. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71585. /**
  71586. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71587. * @param rootUrl the url of the texture
  71588. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71589. * @returns the fallback texture
  71590. */
  71591. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71592. /**
  71593. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71594. * @param data contains the texture data
  71595. * @param texture defines the BabylonJS internal texture
  71596. * @param createPolynomials will be true if polynomials have been requested
  71597. * @param onLoad defines the callback to trigger once the texture is ready
  71598. * @param onError defines the callback to trigger in case of error
  71599. */
  71600. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71601. /**
  71602. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71603. * @param data contains the texture data
  71604. * @param texture defines the BabylonJS internal texture
  71605. * @param callback defines the method to call once ready to upload
  71606. */
  71607. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71608. }
  71609. }
  71610. declare module BABYLON {
  71611. interface Engine {
  71612. /**
  71613. * Creates a depth stencil cube texture.
  71614. * This is only available in WebGL 2.
  71615. * @param size The size of face edge in the cube texture.
  71616. * @param options The options defining the cube texture.
  71617. * @returns The cube texture
  71618. */
  71619. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71620. /**
  71621. * Creates a cube texture
  71622. * @param rootUrl defines the url where the files to load is located
  71623. * @param scene defines the current scene
  71624. * @param files defines the list of files to load (1 per face)
  71625. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71626. * @param onLoad defines an optional callback raised when the texture is loaded
  71627. * @param onError defines an optional callback raised if there is an issue to load the texture
  71628. * @param format defines the format of the data
  71629. * @param forcedExtension defines the extension to use to pick the right loader
  71630. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71631. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71632. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71633. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71634. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71635. * @returns the cube texture as an InternalTexture
  71636. */
  71637. 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;
  71638. /**
  71639. * Creates a cube texture
  71640. * @param rootUrl defines the url where the files to load is located
  71641. * @param scene defines the current scene
  71642. * @param files defines the list of files to load (1 per face)
  71643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71644. * @param onLoad defines an optional callback raised when the texture is loaded
  71645. * @param onError defines an optional callback raised if there is an issue to load the texture
  71646. * @param format defines the format of the data
  71647. * @param forcedExtension defines the extension to use to pick the right loader
  71648. * @returns the cube texture as an InternalTexture
  71649. */
  71650. 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;
  71651. /**
  71652. * Creates a cube texture
  71653. * @param rootUrl defines the url where the files to load is located
  71654. * @param scene defines the current scene
  71655. * @param files defines the list of files to load (1 per face)
  71656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71657. * @param onLoad defines an optional callback raised when the texture is loaded
  71658. * @param onError defines an optional callback raised if there is an issue to load the texture
  71659. * @param format defines the format of the data
  71660. * @param forcedExtension defines the extension to use to pick the right loader
  71661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71664. * @returns the cube texture as an InternalTexture
  71665. */
  71666. 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;
  71667. /** @hidden */
  71668. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71669. /** @hidden */
  71670. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71671. /** @hidden */
  71672. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71673. /** @hidden */
  71674. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71675. }
  71676. }
  71677. declare module BABYLON {
  71678. /**
  71679. * Class for creating a cube texture
  71680. */
  71681. export class CubeTexture extends BaseTexture {
  71682. private _delayedOnLoad;
  71683. /**
  71684. * The url of the texture
  71685. */
  71686. url: string;
  71687. /**
  71688. * Gets or sets the center of the bounding box associated with the cube texture.
  71689. * It must define where the camera used to render the texture was set
  71690. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71691. */
  71692. boundingBoxPosition: Vector3;
  71693. private _boundingBoxSize;
  71694. /**
  71695. * Gets or sets the size of the bounding box associated with the cube texture
  71696. * When defined, the cubemap will switch to local mode
  71697. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71698. * @example https://www.babylonjs-playground.com/#RNASML
  71699. */
  71700. /**
  71701. * Returns the bounding box size
  71702. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71703. */
  71704. boundingBoxSize: Vector3;
  71705. protected _rotationY: number;
  71706. /**
  71707. * Sets texture matrix rotation angle around Y axis in radians.
  71708. */
  71709. /**
  71710. * Gets texture matrix rotation angle around Y axis radians.
  71711. */
  71712. rotationY: number;
  71713. /**
  71714. * Are mip maps generated for this texture or not.
  71715. */
  71716. readonly noMipmap: boolean;
  71717. private _noMipmap;
  71718. private _files;
  71719. private _extensions;
  71720. private _textureMatrix;
  71721. private _format;
  71722. private _createPolynomials;
  71723. /** @hidden */
  71724. _prefiltered: boolean;
  71725. /**
  71726. * Creates a cube texture from an array of image urls
  71727. * @param files defines an array of image urls
  71728. * @param scene defines the hosting scene
  71729. * @param noMipmap specifies if mip maps are not used
  71730. * @returns a cube texture
  71731. */
  71732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71733. /**
  71734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71735. * @param url defines the url of the prefiltered texture
  71736. * @param scene defines the scene the texture is attached to
  71737. * @param forcedExtension defines the extension of the file if different from the url
  71738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71739. * @return the prefiltered texture
  71740. */
  71741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71742. /**
  71743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71744. * as prefiltered data.
  71745. * @param rootUrl defines the url of the texture or the root name of the six images
  71746. * @param scene defines the scene the texture is attached to
  71747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71748. * @param noMipmap defines if mipmaps should be created or not
  71749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71751. * @param onError defines a callback triggered in case of error during load
  71752. * @param format defines the internal format to use for the texture once loaded
  71753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71758. * @return the cube texture
  71759. */
  71760. 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);
  71761. /**
  71762. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71763. */
  71764. readonly isPrefiltered: boolean;
  71765. /**
  71766. * Get the current class name of the texture useful for serialization or dynamic coding.
  71767. * @returns "CubeTexture"
  71768. */
  71769. getClassName(): string;
  71770. /**
  71771. * Update the url (and optional buffer) of this texture if url was null during construction.
  71772. * @param url the url of the texture
  71773. * @param forcedExtension defines the extension to use
  71774. * @param onLoad callback called when the texture is loaded (defaults to null)
  71775. */
  71776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71777. /**
  71778. * Delays loading of the cube texture
  71779. * @param forcedExtension defines the extension to use
  71780. */
  71781. delayLoad(forcedExtension?: string): void;
  71782. /**
  71783. * Returns the reflection texture matrix
  71784. * @returns the reflection texture matrix
  71785. */
  71786. getReflectionTextureMatrix(): Matrix;
  71787. /**
  71788. * Sets the reflection texture matrix
  71789. * @param value Reflection texture matrix
  71790. */
  71791. setReflectionTextureMatrix(value: Matrix): void;
  71792. /**
  71793. * Parses text to create a cube texture
  71794. * @param parsedTexture define the serialized text to read from
  71795. * @param scene defines the hosting scene
  71796. * @param rootUrl defines the root url of the cube texture
  71797. * @returns a cube texture
  71798. */
  71799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71800. /**
  71801. * Makes a clone, or deep copy, of the cube texture
  71802. * @returns a new cube texture
  71803. */
  71804. clone(): CubeTexture;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * Manages the defines for the Material
  71810. */
  71811. export class MaterialDefines {
  71812. /** @hidden */
  71813. protected _keys: string[];
  71814. private _isDirty;
  71815. /** @hidden */
  71816. _renderId: number;
  71817. /** @hidden */
  71818. _areLightsDirty: boolean;
  71819. /** @hidden */
  71820. _areAttributesDirty: boolean;
  71821. /** @hidden */
  71822. _areTexturesDirty: boolean;
  71823. /** @hidden */
  71824. _areFresnelDirty: boolean;
  71825. /** @hidden */
  71826. _areMiscDirty: boolean;
  71827. /** @hidden */
  71828. _areImageProcessingDirty: boolean;
  71829. /** @hidden */
  71830. _normals: boolean;
  71831. /** @hidden */
  71832. _uvs: boolean;
  71833. /** @hidden */
  71834. _needNormals: boolean;
  71835. /** @hidden */
  71836. _needUVs: boolean;
  71837. [id: string]: any;
  71838. /**
  71839. * Specifies if the material needs to be re-calculated
  71840. */
  71841. readonly isDirty: boolean;
  71842. /**
  71843. * Marks the material to indicate that it has been re-calculated
  71844. */
  71845. markAsProcessed(): void;
  71846. /**
  71847. * Marks the material to indicate that it needs to be re-calculated
  71848. */
  71849. markAsUnprocessed(): void;
  71850. /**
  71851. * Marks the material to indicate all of its defines need to be re-calculated
  71852. */
  71853. markAllAsDirty(): void;
  71854. /**
  71855. * Marks the material to indicate that image processing needs to be re-calculated
  71856. */
  71857. markAsImageProcessingDirty(): void;
  71858. /**
  71859. * Marks the material to indicate the lights need to be re-calculated
  71860. */
  71861. markAsLightDirty(): void;
  71862. /**
  71863. * Marks the attribute state as changed
  71864. */
  71865. markAsAttributesDirty(): void;
  71866. /**
  71867. * Marks the texture state as changed
  71868. */
  71869. markAsTexturesDirty(): void;
  71870. /**
  71871. * Marks the fresnel state as changed
  71872. */
  71873. markAsFresnelDirty(): void;
  71874. /**
  71875. * Marks the misc state as changed
  71876. */
  71877. markAsMiscDirty(): void;
  71878. /**
  71879. * Rebuilds the material defines
  71880. */
  71881. rebuild(): void;
  71882. /**
  71883. * Specifies if two material defines are equal
  71884. * @param other - A material define instance to compare to
  71885. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71886. */
  71887. isEqual(other: MaterialDefines): boolean;
  71888. /**
  71889. * Clones this instance's defines to another instance
  71890. * @param other - material defines to clone values to
  71891. */
  71892. cloneTo(other: MaterialDefines): void;
  71893. /**
  71894. * Resets the material define values
  71895. */
  71896. reset(): void;
  71897. /**
  71898. * Converts the material define values to a string
  71899. * @returns - String of material define information
  71900. */
  71901. toString(): string;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /**
  71906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71908. * 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;
  71909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71910. */
  71911. export class ColorCurves {
  71912. private _dirty;
  71913. private _tempColor;
  71914. private _globalCurve;
  71915. private _highlightsCurve;
  71916. private _midtonesCurve;
  71917. private _shadowsCurve;
  71918. private _positiveCurve;
  71919. private _negativeCurve;
  71920. private _globalHue;
  71921. private _globalDensity;
  71922. private _globalSaturation;
  71923. private _globalExposure;
  71924. /**
  71925. * Gets the global Hue value.
  71926. * 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).
  71927. */
  71928. /**
  71929. * Sets the global Hue value.
  71930. * 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).
  71931. */
  71932. globalHue: number;
  71933. /**
  71934. * Gets the global Density value.
  71935. * 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.
  71936. * Values less than zero provide a filter of opposite hue.
  71937. */
  71938. /**
  71939. * Sets the global Density value.
  71940. * 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.
  71941. * Values less than zero provide a filter of opposite hue.
  71942. */
  71943. globalDensity: number;
  71944. /**
  71945. * Gets the global Saturation value.
  71946. * 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.
  71947. */
  71948. /**
  71949. * Sets the global Saturation value.
  71950. * 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.
  71951. */
  71952. globalSaturation: number;
  71953. /**
  71954. * Gets the global Exposure value.
  71955. * 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.
  71956. */
  71957. /**
  71958. * Sets the global Exposure value.
  71959. * 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.
  71960. */
  71961. globalExposure: number;
  71962. private _highlightsHue;
  71963. private _highlightsDensity;
  71964. private _highlightsSaturation;
  71965. private _highlightsExposure;
  71966. /**
  71967. * Gets the highlights Hue value.
  71968. * 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).
  71969. */
  71970. /**
  71971. * Sets the highlights Hue value.
  71972. * 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).
  71973. */
  71974. highlightsHue: number;
  71975. /**
  71976. * Gets the highlights Density value.
  71977. * 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.
  71978. * Values less than zero provide a filter of opposite hue.
  71979. */
  71980. /**
  71981. * Sets the highlights Density value.
  71982. * 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.
  71983. * Values less than zero provide a filter of opposite hue.
  71984. */
  71985. highlightsDensity: number;
  71986. /**
  71987. * Gets the highlights Saturation value.
  71988. * 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.
  71989. */
  71990. /**
  71991. * Sets the highlights Saturation value.
  71992. * 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.
  71993. */
  71994. highlightsSaturation: number;
  71995. /**
  71996. * Gets the highlights Exposure value.
  71997. * 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.
  71998. */
  71999. /**
  72000. * Sets the highlights Exposure value.
  72001. * 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.
  72002. */
  72003. highlightsExposure: number;
  72004. private _midtonesHue;
  72005. private _midtonesDensity;
  72006. private _midtonesSaturation;
  72007. private _midtonesExposure;
  72008. /**
  72009. * Gets the midtones Hue value.
  72010. * 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).
  72011. */
  72012. /**
  72013. * Sets the midtones Hue value.
  72014. * 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).
  72015. */
  72016. midtonesHue: number;
  72017. /**
  72018. * Gets the midtones Density value.
  72019. * 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.
  72020. * Values less than zero provide a filter of opposite hue.
  72021. */
  72022. /**
  72023. * Sets the midtones Density value.
  72024. * 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.
  72025. * Values less than zero provide a filter of opposite hue.
  72026. */
  72027. midtonesDensity: number;
  72028. /**
  72029. * Gets the midtones Saturation value.
  72030. * 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.
  72031. */
  72032. /**
  72033. * Sets the midtones Saturation value.
  72034. * 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.
  72035. */
  72036. midtonesSaturation: number;
  72037. /**
  72038. * Gets the midtones Exposure value.
  72039. * 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.
  72040. */
  72041. /**
  72042. * Sets the midtones Exposure value.
  72043. * 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.
  72044. */
  72045. midtonesExposure: number;
  72046. private _shadowsHue;
  72047. private _shadowsDensity;
  72048. private _shadowsSaturation;
  72049. private _shadowsExposure;
  72050. /**
  72051. * Gets the shadows Hue value.
  72052. * 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).
  72053. */
  72054. /**
  72055. * Sets the shadows Hue value.
  72056. * 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).
  72057. */
  72058. shadowsHue: number;
  72059. /**
  72060. * Gets the shadows Density value.
  72061. * 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.
  72062. * Values less than zero provide a filter of opposite hue.
  72063. */
  72064. /**
  72065. * Sets the shadows Density value.
  72066. * 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.
  72067. * Values less than zero provide a filter of opposite hue.
  72068. */
  72069. shadowsDensity: number;
  72070. /**
  72071. * Gets the shadows Saturation value.
  72072. * 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.
  72073. */
  72074. /**
  72075. * Sets the shadows Saturation value.
  72076. * 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.
  72077. */
  72078. shadowsSaturation: number;
  72079. /**
  72080. * Gets the shadows Exposure value.
  72081. * 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.
  72082. */
  72083. /**
  72084. * Sets the shadows Exposure value.
  72085. * 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.
  72086. */
  72087. shadowsExposure: number;
  72088. /**
  72089. * Returns the class name
  72090. * @returns The class name
  72091. */
  72092. getClassName(): string;
  72093. /**
  72094. * Binds the color curves to the shader.
  72095. * @param colorCurves The color curve to bind
  72096. * @param effect The effect to bind to
  72097. * @param positiveUniform The positive uniform shader parameter
  72098. * @param neutralUniform The neutral uniform shader parameter
  72099. * @param negativeUniform The negative uniform shader parameter
  72100. */
  72101. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72102. /**
  72103. * Prepare the list of uniforms associated with the ColorCurves effects.
  72104. * @param uniformsList The list of uniforms used in the effect
  72105. */
  72106. static PrepareUniforms(uniformsList: string[]): void;
  72107. /**
  72108. * Returns color grading data based on a hue, density, saturation and exposure value.
  72109. * @param filterHue The hue of the color filter.
  72110. * @param filterDensity The density of the color filter.
  72111. * @param saturation The saturation.
  72112. * @param exposure The exposure.
  72113. * @param result The result data container.
  72114. */
  72115. private getColorGradingDataToRef;
  72116. /**
  72117. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72118. * @param value The input slider value in range [-100,100].
  72119. * @returns Adjusted value.
  72120. */
  72121. private static applyColorGradingSliderNonlinear;
  72122. /**
  72123. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72124. * @param hue The hue (H) input.
  72125. * @param saturation The saturation (S) input.
  72126. * @param brightness The brightness (B) input.
  72127. * @result An RGBA color represented as Vector4.
  72128. */
  72129. private static fromHSBToRef;
  72130. /**
  72131. * Returns a value clamped between min and max
  72132. * @param value The value to clamp
  72133. * @param min The minimum of value
  72134. * @param max The maximum of value
  72135. * @returns The clamped value.
  72136. */
  72137. private static clamp;
  72138. /**
  72139. * Clones the current color curve instance.
  72140. * @return The cloned curves
  72141. */
  72142. clone(): ColorCurves;
  72143. /**
  72144. * Serializes the current color curve instance to a json representation.
  72145. * @return a JSON representation
  72146. */
  72147. serialize(): any;
  72148. /**
  72149. * Parses the color curve from a json representation.
  72150. * @param source the JSON source to parse
  72151. * @return The parsed curves
  72152. */
  72153. static Parse(source: any): ColorCurves;
  72154. }
  72155. }
  72156. declare module BABYLON {
  72157. /**
  72158. * Interface to follow in your material defines to integrate easily the
  72159. * Image proccessing functions.
  72160. * @hidden
  72161. */
  72162. export interface IImageProcessingConfigurationDefines {
  72163. IMAGEPROCESSING: boolean;
  72164. VIGNETTE: boolean;
  72165. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72166. VIGNETTEBLENDMODEOPAQUE: boolean;
  72167. TONEMAPPING: boolean;
  72168. TONEMAPPING_ACES: boolean;
  72169. CONTRAST: boolean;
  72170. EXPOSURE: boolean;
  72171. COLORCURVES: boolean;
  72172. COLORGRADING: boolean;
  72173. COLORGRADING3D: boolean;
  72174. SAMPLER3DGREENDEPTH: boolean;
  72175. SAMPLER3DBGRMAP: boolean;
  72176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72177. }
  72178. /**
  72179. * @hidden
  72180. */
  72181. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72182. IMAGEPROCESSING: boolean;
  72183. VIGNETTE: boolean;
  72184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72185. VIGNETTEBLENDMODEOPAQUE: boolean;
  72186. TONEMAPPING: boolean;
  72187. TONEMAPPING_ACES: boolean;
  72188. CONTRAST: boolean;
  72189. COLORCURVES: boolean;
  72190. COLORGRADING: boolean;
  72191. COLORGRADING3D: boolean;
  72192. SAMPLER3DGREENDEPTH: boolean;
  72193. SAMPLER3DBGRMAP: boolean;
  72194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72195. EXPOSURE: boolean;
  72196. constructor();
  72197. }
  72198. /**
  72199. * This groups together the common properties used for image processing either in direct forward pass
  72200. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72201. * or not.
  72202. */
  72203. export class ImageProcessingConfiguration {
  72204. /**
  72205. * Default tone mapping applied in BabylonJS.
  72206. */
  72207. static readonly TONEMAPPING_STANDARD: number;
  72208. /**
  72209. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72210. * to other engines rendering to increase portability.
  72211. */
  72212. static readonly TONEMAPPING_ACES: number;
  72213. /**
  72214. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72215. */
  72216. colorCurves: Nullable<ColorCurves>;
  72217. private _colorCurvesEnabled;
  72218. /**
  72219. * Gets wether the color curves effect is enabled.
  72220. */
  72221. /**
  72222. * Sets wether the color curves effect is enabled.
  72223. */
  72224. colorCurvesEnabled: boolean;
  72225. private _colorGradingTexture;
  72226. /**
  72227. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72228. */
  72229. /**
  72230. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72231. */
  72232. colorGradingTexture: Nullable<BaseTexture>;
  72233. private _colorGradingEnabled;
  72234. /**
  72235. * Gets wether the color grading effect is enabled.
  72236. */
  72237. /**
  72238. * Sets wether the color grading effect is enabled.
  72239. */
  72240. colorGradingEnabled: boolean;
  72241. private _colorGradingWithGreenDepth;
  72242. /**
  72243. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72244. */
  72245. /**
  72246. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72247. */
  72248. colorGradingWithGreenDepth: boolean;
  72249. private _colorGradingBGR;
  72250. /**
  72251. * Gets wether the color grading texture contains BGR values.
  72252. */
  72253. /**
  72254. * Sets wether the color grading texture contains BGR values.
  72255. */
  72256. colorGradingBGR: boolean;
  72257. /** @hidden */
  72258. _exposure: number;
  72259. /**
  72260. * Gets the Exposure used in the effect.
  72261. */
  72262. /**
  72263. * Sets the Exposure used in the effect.
  72264. */
  72265. exposure: number;
  72266. private _toneMappingEnabled;
  72267. /**
  72268. * Gets wether the tone mapping effect is enabled.
  72269. */
  72270. /**
  72271. * Sets wether the tone mapping effect is enabled.
  72272. */
  72273. toneMappingEnabled: boolean;
  72274. private _toneMappingType;
  72275. /**
  72276. * Gets the type of tone mapping effect.
  72277. */
  72278. /**
  72279. * Sets the type of tone mapping effect used in BabylonJS.
  72280. */
  72281. toneMappingType: number;
  72282. protected _contrast: number;
  72283. /**
  72284. * Gets the contrast used in the effect.
  72285. */
  72286. /**
  72287. * Sets the contrast used in the effect.
  72288. */
  72289. contrast: number;
  72290. /**
  72291. * Vignette stretch size.
  72292. */
  72293. vignetteStretch: number;
  72294. /**
  72295. * Vignette centre X Offset.
  72296. */
  72297. vignetteCentreX: number;
  72298. /**
  72299. * Vignette centre Y Offset.
  72300. */
  72301. vignetteCentreY: number;
  72302. /**
  72303. * Vignette weight or intensity of the vignette effect.
  72304. */
  72305. vignetteWeight: number;
  72306. /**
  72307. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72308. * if vignetteEnabled is set to true.
  72309. */
  72310. vignetteColor: Color4;
  72311. /**
  72312. * Camera field of view used by the Vignette effect.
  72313. */
  72314. vignetteCameraFov: number;
  72315. private _vignetteBlendMode;
  72316. /**
  72317. * Gets the vignette blend mode allowing different kind of effect.
  72318. */
  72319. /**
  72320. * Sets the vignette blend mode allowing different kind of effect.
  72321. */
  72322. vignetteBlendMode: number;
  72323. private _vignetteEnabled;
  72324. /**
  72325. * Gets wether the vignette effect is enabled.
  72326. */
  72327. /**
  72328. * Sets wether the vignette effect is enabled.
  72329. */
  72330. vignetteEnabled: boolean;
  72331. private _applyByPostProcess;
  72332. /**
  72333. * Gets wether the image processing is applied through a post process or not.
  72334. */
  72335. /**
  72336. * Sets wether the image processing is applied through a post process or not.
  72337. */
  72338. applyByPostProcess: boolean;
  72339. private _isEnabled;
  72340. /**
  72341. * Gets wether the image processing is enabled or not.
  72342. */
  72343. /**
  72344. * Sets wether the image processing is enabled or not.
  72345. */
  72346. isEnabled: boolean;
  72347. /**
  72348. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72349. */
  72350. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72351. /**
  72352. * Method called each time the image processing information changes requires to recompile the effect.
  72353. */
  72354. protected _updateParameters(): void;
  72355. /**
  72356. * Gets the current class name.
  72357. * @return "ImageProcessingConfiguration"
  72358. */
  72359. getClassName(): string;
  72360. /**
  72361. * Prepare the list of uniforms associated with the Image Processing effects.
  72362. * @param uniforms The list of uniforms used in the effect
  72363. * @param defines the list of defines currently in use
  72364. */
  72365. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72366. /**
  72367. * Prepare the list of samplers associated with the Image Processing effects.
  72368. * @param samplersList The list of uniforms used in the effect
  72369. * @param defines the list of defines currently in use
  72370. */
  72371. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72372. /**
  72373. * Prepare the list of defines associated to the shader.
  72374. * @param defines the list of defines to complete
  72375. * @param forPostProcess Define if we are currently in post process mode or not
  72376. */
  72377. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72378. /**
  72379. * Returns true if all the image processing information are ready.
  72380. * @returns True if ready, otherwise, false
  72381. */
  72382. isReady(): boolean;
  72383. /**
  72384. * Binds the image processing to the shader.
  72385. * @param effect The effect to bind to
  72386. * @param aspectRatio Define the current aspect ratio of the effect
  72387. */
  72388. bind(effect: Effect, aspectRatio?: number): void;
  72389. /**
  72390. * Clones the current image processing instance.
  72391. * @return The cloned image processing
  72392. */
  72393. clone(): ImageProcessingConfiguration;
  72394. /**
  72395. * Serializes the current image processing instance to a json representation.
  72396. * @return a JSON representation
  72397. */
  72398. serialize(): any;
  72399. /**
  72400. * Parses the image processing from a json representation.
  72401. * @param source the JSON source to parse
  72402. * @return The parsed image processing
  72403. */
  72404. static Parse(source: any): ImageProcessingConfiguration;
  72405. private static _VIGNETTEMODE_MULTIPLY;
  72406. private static _VIGNETTEMODE_OPAQUE;
  72407. /**
  72408. * Used to apply the vignette as a mix with the pixel color.
  72409. */
  72410. static readonly VIGNETTEMODE_MULTIPLY: number;
  72411. /**
  72412. * Used to apply the vignette as a replacement of the pixel color.
  72413. */
  72414. static readonly VIGNETTEMODE_OPAQUE: number;
  72415. }
  72416. }
  72417. declare module BABYLON {
  72418. /** @hidden */
  72419. export var postprocessVertexShader: {
  72420. name: string;
  72421. shader: string;
  72422. };
  72423. }
  72424. declare module BABYLON {
  72425. /** Defines supported spaces */
  72426. export enum Space {
  72427. /** Local (object) space */
  72428. LOCAL = 0,
  72429. /** World space */
  72430. WORLD = 1,
  72431. /** Bone space */
  72432. BONE = 2
  72433. }
  72434. /** Defines the 3 main axes */
  72435. export class Axis {
  72436. /** X axis */
  72437. static X: Vector3;
  72438. /** Y axis */
  72439. static Y: Vector3;
  72440. /** Z axis */
  72441. static Z: Vector3;
  72442. }
  72443. }
  72444. declare module BABYLON {
  72445. /**
  72446. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72447. * This is the base of the follow, arc rotate cameras and Free camera
  72448. * @see http://doc.babylonjs.com/features/cameras
  72449. */
  72450. export class TargetCamera extends Camera {
  72451. private static _RigCamTransformMatrix;
  72452. private static _TargetTransformMatrix;
  72453. private static _TargetFocalPoint;
  72454. /**
  72455. * Define the current direction the camera is moving to
  72456. */
  72457. cameraDirection: Vector3;
  72458. /**
  72459. * Define the current rotation the camera is rotating to
  72460. */
  72461. cameraRotation: Vector2;
  72462. /**
  72463. * When set, the up vector of the camera will be updated by the rotation of the camera
  72464. */
  72465. updateUpVectorFromRotation: boolean;
  72466. private _tmpQuaternion;
  72467. /**
  72468. * Define the current rotation of the camera
  72469. */
  72470. rotation: Vector3;
  72471. /**
  72472. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72473. */
  72474. rotationQuaternion: Quaternion;
  72475. /**
  72476. * Define the current speed of the camera
  72477. */
  72478. speed: number;
  72479. /**
  72480. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72481. * around all axis.
  72482. */
  72483. noRotationConstraint: boolean;
  72484. /**
  72485. * Define the current target of the camera as an object or a position.
  72486. */
  72487. lockedTarget: any;
  72488. /** @hidden */
  72489. _currentTarget: Vector3;
  72490. /** @hidden */
  72491. _initialFocalDistance: number;
  72492. /** @hidden */
  72493. _viewMatrix: Matrix;
  72494. /** @hidden */
  72495. _camMatrix: Matrix;
  72496. /** @hidden */
  72497. _cameraTransformMatrix: Matrix;
  72498. /** @hidden */
  72499. _cameraRotationMatrix: Matrix;
  72500. /** @hidden */
  72501. _referencePoint: Vector3;
  72502. /** @hidden */
  72503. _transformedReferencePoint: Vector3;
  72504. protected _globalCurrentTarget: Vector3;
  72505. protected _globalCurrentUpVector: Vector3;
  72506. /** @hidden */
  72507. _reset: () => void;
  72508. private _defaultUp;
  72509. /**
  72510. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72511. * This is the base of the follow, arc rotate cameras and Free camera
  72512. * @see http://doc.babylonjs.com/features/cameras
  72513. * @param name Defines the name of the camera in the scene
  72514. * @param position Defines the start position of the camera in the scene
  72515. * @param scene Defines the scene the camera belongs to
  72516. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72517. */
  72518. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72519. /**
  72520. * Gets the position in front of the camera at a given distance.
  72521. * @param distance The distance from the camera we want the position to be
  72522. * @returns the position
  72523. */
  72524. getFrontPosition(distance: number): Vector3;
  72525. /** @hidden */
  72526. _getLockedTargetPosition(): Nullable<Vector3>;
  72527. private _storedPosition;
  72528. private _storedRotation;
  72529. private _storedRotationQuaternion;
  72530. /**
  72531. * Store current camera state of the camera (fov, position, rotation, etc..)
  72532. * @returns the camera
  72533. */
  72534. storeState(): Camera;
  72535. /**
  72536. * Restored camera state. You must call storeState() first
  72537. * @returns whether it was successful or not
  72538. * @hidden
  72539. */
  72540. _restoreStateValues(): boolean;
  72541. /** @hidden */
  72542. _initCache(): void;
  72543. /** @hidden */
  72544. _updateCache(ignoreParentClass?: boolean): void;
  72545. /** @hidden */
  72546. _isSynchronizedViewMatrix(): boolean;
  72547. /** @hidden */
  72548. _computeLocalCameraSpeed(): number;
  72549. /**
  72550. * Defines the target the camera should look at.
  72551. * @param target Defines the new target as a Vector or a mesh
  72552. */
  72553. setTarget(target: Vector3): void;
  72554. /**
  72555. * Return the current target position of the camera. This value is expressed in local space.
  72556. * @returns the target position
  72557. */
  72558. getTarget(): Vector3;
  72559. /** @hidden */
  72560. _decideIfNeedsToMove(): boolean;
  72561. /** @hidden */
  72562. _updatePosition(): void;
  72563. /** @hidden */
  72564. _checkInputs(): void;
  72565. protected _updateCameraRotationMatrix(): void;
  72566. /**
  72567. * 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)
  72568. * @returns the current camera
  72569. */
  72570. private _rotateUpVectorWithCameraRotationMatrix;
  72571. private _cachedRotationZ;
  72572. private _cachedQuaternionRotationZ;
  72573. /** @hidden */
  72574. _getViewMatrix(): Matrix;
  72575. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72576. /**
  72577. * @hidden
  72578. */
  72579. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72580. /**
  72581. * @hidden
  72582. */
  72583. _updateRigCameras(): void;
  72584. private _getRigCamPositionAndTarget;
  72585. /**
  72586. * Gets the current object class name.
  72587. * @return the class name
  72588. */
  72589. getClassName(): string;
  72590. }
  72591. }
  72592. declare module BABYLON {
  72593. /**
  72594. * Gather the list of keyboard event types as constants.
  72595. */
  72596. export class KeyboardEventTypes {
  72597. /**
  72598. * The keydown event is fired when a key becomes active (pressed).
  72599. */
  72600. static readonly KEYDOWN: number;
  72601. /**
  72602. * The keyup event is fired when a key has been released.
  72603. */
  72604. static readonly KEYUP: number;
  72605. }
  72606. /**
  72607. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72608. */
  72609. export class KeyboardInfo {
  72610. /**
  72611. * Defines the type of event (KeyboardEventTypes)
  72612. */
  72613. type: number;
  72614. /**
  72615. * Defines the related dom event
  72616. */
  72617. event: KeyboardEvent;
  72618. /**
  72619. * Instantiates a new keyboard info.
  72620. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72621. * @param type Defines the type of event (KeyboardEventTypes)
  72622. * @param event Defines the related dom event
  72623. */
  72624. constructor(
  72625. /**
  72626. * Defines the type of event (KeyboardEventTypes)
  72627. */
  72628. type: number,
  72629. /**
  72630. * Defines the related dom event
  72631. */
  72632. event: KeyboardEvent);
  72633. }
  72634. /**
  72635. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72636. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72637. */
  72638. export class KeyboardInfoPre extends KeyboardInfo {
  72639. /**
  72640. * Defines the type of event (KeyboardEventTypes)
  72641. */
  72642. type: number;
  72643. /**
  72644. * Defines the related dom event
  72645. */
  72646. event: KeyboardEvent;
  72647. /**
  72648. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72649. */
  72650. skipOnPointerObservable: boolean;
  72651. /**
  72652. * Instantiates a new keyboard pre info.
  72653. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72654. * @param type Defines the type of event (KeyboardEventTypes)
  72655. * @param event Defines the related dom event
  72656. */
  72657. constructor(
  72658. /**
  72659. * Defines the type of event (KeyboardEventTypes)
  72660. */
  72661. type: number,
  72662. /**
  72663. * Defines the related dom event
  72664. */
  72665. event: KeyboardEvent);
  72666. }
  72667. }
  72668. declare module BABYLON {
  72669. /**
  72670. * Manage the keyboard inputs to control the movement of a free camera.
  72671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72672. */
  72673. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72674. /**
  72675. * Defines the camera the input is attached to.
  72676. */
  72677. camera: FreeCamera;
  72678. /**
  72679. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72680. */
  72681. keysUp: number[];
  72682. /**
  72683. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72684. */
  72685. keysDown: number[];
  72686. /**
  72687. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72688. */
  72689. keysLeft: number[];
  72690. /**
  72691. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72692. */
  72693. keysRight: number[];
  72694. private _keys;
  72695. private _onCanvasBlurObserver;
  72696. private _onKeyboardObserver;
  72697. private _engine;
  72698. private _scene;
  72699. /**
  72700. * Attach the input controls to a specific dom element to get the input from.
  72701. * @param element Defines the element the controls should be listened from
  72702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72703. */
  72704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72705. /**
  72706. * Detach the current controls from the specified dom element.
  72707. * @param element Defines the element to stop listening the inputs from
  72708. */
  72709. detachControl(element: Nullable<HTMLElement>): void;
  72710. /**
  72711. * Update the current camera state depending on the inputs that have been used this frame.
  72712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72713. */
  72714. checkInputs(): void;
  72715. /**
  72716. * Gets the class name of the current intput.
  72717. * @returns the class name
  72718. */
  72719. getClassName(): string;
  72720. /** @hidden */
  72721. _onLostFocus(): void;
  72722. /**
  72723. * Get the friendly name associated with the input class.
  72724. * @returns the input friendly name
  72725. */
  72726. getSimpleName(): string;
  72727. }
  72728. }
  72729. declare module BABYLON {
  72730. /**
  72731. * Interface describing all the common properties and methods a shadow light needs to implement.
  72732. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72733. * as well as binding the different shadow properties to the effects.
  72734. */
  72735. export interface IShadowLight extends Light {
  72736. /**
  72737. * The light id in the scene (used in scene.findLighById for instance)
  72738. */
  72739. id: string;
  72740. /**
  72741. * The position the shdow will be casted from.
  72742. */
  72743. position: Vector3;
  72744. /**
  72745. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72746. */
  72747. direction: Vector3;
  72748. /**
  72749. * The transformed position. Position of the light in world space taking parenting in account.
  72750. */
  72751. transformedPosition: Vector3;
  72752. /**
  72753. * The transformed direction. Direction of the light in world space taking parenting in account.
  72754. */
  72755. transformedDirection: Vector3;
  72756. /**
  72757. * The friendly name of the light in the scene.
  72758. */
  72759. name: string;
  72760. /**
  72761. * Defines the shadow projection clipping minimum z value.
  72762. */
  72763. shadowMinZ: number;
  72764. /**
  72765. * Defines the shadow projection clipping maximum z value.
  72766. */
  72767. shadowMaxZ: number;
  72768. /**
  72769. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72770. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72771. */
  72772. computeTransformedInformation(): boolean;
  72773. /**
  72774. * Gets the scene the light belongs to.
  72775. * @returns The scene
  72776. */
  72777. getScene(): Scene;
  72778. /**
  72779. * Callback defining a custom Projection Matrix Builder.
  72780. * This can be used to override the default projection matrix computation.
  72781. */
  72782. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72783. /**
  72784. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72785. * @param matrix The materix to updated with the projection information
  72786. * @param viewMatrix The transform matrix of the light
  72787. * @param renderList The list of mesh to render in the map
  72788. * @returns The current light
  72789. */
  72790. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72791. /**
  72792. * Gets the current depth scale used in ESM.
  72793. * @returns The scale
  72794. */
  72795. getDepthScale(): number;
  72796. /**
  72797. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72798. * @returns true if a cube texture needs to be use
  72799. */
  72800. needCube(): boolean;
  72801. /**
  72802. * Detects if the projection matrix requires to be recomputed this frame.
  72803. * @returns true if it requires to be recomputed otherwise, false.
  72804. */
  72805. needProjectionMatrixCompute(): boolean;
  72806. /**
  72807. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72808. */
  72809. forceProjectionMatrixCompute(): void;
  72810. /**
  72811. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72812. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72813. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72814. */
  72815. getShadowDirection(faceIndex?: number): Vector3;
  72816. /**
  72817. * Gets the minZ used for shadow according to both the scene and the light.
  72818. * @param activeCamera The camera we are returning the min for
  72819. * @returns the depth min z
  72820. */
  72821. getDepthMinZ(activeCamera: Camera): number;
  72822. /**
  72823. * Gets the maxZ used for shadow according to both the scene and the light.
  72824. * @param activeCamera The camera we are returning the max for
  72825. * @returns the depth max z
  72826. */
  72827. getDepthMaxZ(activeCamera: Camera): number;
  72828. }
  72829. /**
  72830. * Base implementation IShadowLight
  72831. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72832. */
  72833. export abstract class ShadowLight extends Light implements IShadowLight {
  72834. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72835. protected _position: Vector3;
  72836. protected _setPosition(value: Vector3): void;
  72837. /**
  72838. * Sets the position the shadow will be casted from. Also use as the light position for both
  72839. * point and spot lights.
  72840. */
  72841. /**
  72842. * Sets the position the shadow will be casted from. Also use as the light position for both
  72843. * point and spot lights.
  72844. */
  72845. position: Vector3;
  72846. protected _direction: Vector3;
  72847. protected _setDirection(value: Vector3): void;
  72848. /**
  72849. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72850. * Also use as the light direction on spot and directional lights.
  72851. */
  72852. /**
  72853. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72854. * Also use as the light direction on spot and directional lights.
  72855. */
  72856. direction: Vector3;
  72857. private _shadowMinZ;
  72858. /**
  72859. * Gets the shadow projection clipping minimum z value.
  72860. */
  72861. /**
  72862. * Sets the shadow projection clipping minimum z value.
  72863. */
  72864. shadowMinZ: number;
  72865. private _shadowMaxZ;
  72866. /**
  72867. * Sets the shadow projection clipping maximum z value.
  72868. */
  72869. /**
  72870. * Gets the shadow projection clipping maximum z value.
  72871. */
  72872. shadowMaxZ: number;
  72873. /**
  72874. * Callback defining a custom Projection Matrix Builder.
  72875. * This can be used to override the default projection matrix computation.
  72876. */
  72877. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72878. /**
  72879. * The transformed position. Position of the light in world space taking parenting in account.
  72880. */
  72881. transformedPosition: Vector3;
  72882. /**
  72883. * The transformed direction. Direction of the light in world space taking parenting in account.
  72884. */
  72885. transformedDirection: Vector3;
  72886. private _needProjectionMatrixCompute;
  72887. /**
  72888. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72889. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72890. */
  72891. computeTransformedInformation(): boolean;
  72892. /**
  72893. * Return the depth scale used for the shadow map.
  72894. * @returns the depth scale.
  72895. */
  72896. getDepthScale(): number;
  72897. /**
  72898. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72901. */
  72902. getShadowDirection(faceIndex?: number): Vector3;
  72903. /**
  72904. * Returns the ShadowLight absolute position in the World.
  72905. * @returns the position vector in world space
  72906. */
  72907. getAbsolutePosition(): Vector3;
  72908. /**
  72909. * Sets the ShadowLight direction toward the passed target.
  72910. * @param target The point to target in local space
  72911. * @returns the updated ShadowLight direction
  72912. */
  72913. setDirectionToTarget(target: Vector3): Vector3;
  72914. /**
  72915. * Returns the light rotation in euler definition.
  72916. * @returns the x y z rotation in local space.
  72917. */
  72918. getRotation(): Vector3;
  72919. /**
  72920. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72921. * @returns true if a cube texture needs to be use
  72922. */
  72923. needCube(): boolean;
  72924. /**
  72925. * Detects if the projection matrix requires to be recomputed this frame.
  72926. * @returns true if it requires to be recomputed otherwise, false.
  72927. */
  72928. needProjectionMatrixCompute(): boolean;
  72929. /**
  72930. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72931. */
  72932. forceProjectionMatrixCompute(): void;
  72933. /** @hidden */
  72934. _initCache(): void;
  72935. /** @hidden */
  72936. _isSynchronized(): boolean;
  72937. /**
  72938. * Computes the world matrix of the node
  72939. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72940. * @returns the world matrix
  72941. */
  72942. computeWorldMatrix(force?: boolean): Matrix;
  72943. /**
  72944. * Gets the minZ used for shadow according to both the scene and the light.
  72945. * @param activeCamera The camera we are returning the min for
  72946. * @returns the depth min z
  72947. */
  72948. getDepthMinZ(activeCamera: Camera): number;
  72949. /**
  72950. * Gets the maxZ used for shadow according to both the scene and the light.
  72951. * @param activeCamera The camera we are returning the max for
  72952. * @returns the depth max z
  72953. */
  72954. getDepthMaxZ(activeCamera: Camera): number;
  72955. /**
  72956. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72957. * @param matrix The materix to updated with the projection information
  72958. * @param viewMatrix The transform matrix of the light
  72959. * @param renderList The list of mesh to render in the map
  72960. * @returns The current light
  72961. */
  72962. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72963. }
  72964. }
  72965. declare module BABYLON {
  72966. /**
  72967. * "Static Class" containing the most commonly used helper while dealing with material for
  72968. * rendering purpose.
  72969. *
  72970. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72971. *
  72972. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72973. */
  72974. export class MaterialHelper {
  72975. /**
  72976. * Bind the current view position to an effect.
  72977. * @param effect The effect to be bound
  72978. * @param scene The scene the eyes position is used from
  72979. */
  72980. static BindEyePosition(effect: Effect, scene: Scene): void;
  72981. /**
  72982. * Helps preparing the defines values about the UVs in used in the effect.
  72983. * UVs are shared as much as we can accross channels in the shaders.
  72984. * @param texture The texture we are preparing the UVs for
  72985. * @param defines The defines to update
  72986. * @param key The channel key "diffuse", "specular"... used in the shader
  72987. */
  72988. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72989. /**
  72990. * Binds a texture matrix value to its corrsponding uniform
  72991. * @param texture The texture to bind the matrix for
  72992. * @param uniformBuffer The uniform buffer receivin the data
  72993. * @param key The channel key "diffuse", "specular"... used in the shader
  72994. */
  72995. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72996. /**
  72997. * Gets the current status of the fog (should it be enabled?)
  72998. * @param mesh defines the mesh to evaluate for fog support
  72999. * @param scene defines the hosting scene
  73000. * @returns true if fog must be enabled
  73001. */
  73002. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73003. /**
  73004. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73005. * @param mesh defines the current mesh
  73006. * @param scene defines the current scene
  73007. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73008. * @param pointsCloud defines if point cloud rendering has to be turned on
  73009. * @param fogEnabled defines if fog has to be turned on
  73010. * @param alphaTest defines if alpha testing has to be turned on
  73011. * @param defines defines the current list of defines
  73012. */
  73013. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73014. /**
  73015. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73016. * @param scene defines the current scene
  73017. * @param engine defines the current engine
  73018. * @param defines specifies the list of active defines
  73019. * @param useInstances defines if instances have to be turned on
  73020. * @param useClipPlane defines if clip plane have to be turned on
  73021. */
  73022. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73023. /**
  73024. * Prepares the defines for bones
  73025. * @param mesh The mesh containing the geometry data we will draw
  73026. * @param defines The defines to update
  73027. */
  73028. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73029. /**
  73030. * Prepares the defines for morph targets
  73031. * @param mesh The mesh containing the geometry data we will draw
  73032. * @param defines The defines to update
  73033. */
  73034. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73035. /**
  73036. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73037. * @param mesh The mesh containing the geometry data we will draw
  73038. * @param defines The defines to update
  73039. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73040. * @param useBones Precise whether bones should be used or not (override mesh info)
  73041. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73042. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73043. * @returns false if defines are considered not dirty and have not been checked
  73044. */
  73045. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73046. /**
  73047. * Prepares the defines related to multiview
  73048. * @param scene The scene we are intending to draw
  73049. * @param defines The defines to update
  73050. */
  73051. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73052. /**
  73053. * Prepares the defines related to the light information passed in parameter
  73054. * @param scene The scene we are intending to draw
  73055. * @param mesh The mesh the effect is compiling for
  73056. * @param light The light the effect is compiling for
  73057. * @param lightIndex The index of the light
  73058. * @param defines The defines to update
  73059. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73060. * @param state Defines the current state regarding what is needed (normals, etc...)
  73061. */
  73062. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73063. needNormals: boolean;
  73064. needRebuild: boolean;
  73065. shadowEnabled: boolean;
  73066. specularEnabled: boolean;
  73067. lightmapMode: boolean;
  73068. }): void;
  73069. /**
  73070. * Prepares the defines related to the light information passed in parameter
  73071. * @param scene The scene we are intending to draw
  73072. * @param mesh The mesh the effect is compiling for
  73073. * @param defines The defines to update
  73074. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73075. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73076. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73077. * @returns true if normals will be required for the rest of the effect
  73078. */
  73079. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73080. /**
  73081. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73082. * @param lightIndex defines the light index
  73083. * @param uniformsList The uniform list
  73084. * @param samplersList The sampler list
  73085. * @param projectedLightTexture defines if projected texture must be used
  73086. * @param uniformBuffersList defines an optional list of uniform buffers
  73087. */
  73088. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73089. /**
  73090. * Prepares the uniforms and samplers list to be used in the effect
  73091. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73092. * @param samplersList The sampler list
  73093. * @param defines The defines helping in the list generation
  73094. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73095. */
  73096. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73097. /**
  73098. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73099. * @param defines The defines to update while falling back
  73100. * @param fallbacks The authorized effect fallbacks
  73101. * @param maxSimultaneousLights The maximum number of lights allowed
  73102. * @param rank the current rank of the Effect
  73103. * @returns The newly affected rank
  73104. */
  73105. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73106. private static _TmpMorphInfluencers;
  73107. /**
  73108. * Prepares the list of attributes required for morph targets according to the effect defines.
  73109. * @param attribs The current list of supported attribs
  73110. * @param mesh The mesh to prepare the morph targets attributes for
  73111. * @param influencers The number of influencers
  73112. */
  73113. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73114. /**
  73115. * Prepares the list of attributes required for morph targets according to the effect defines.
  73116. * @param attribs The current list of supported attribs
  73117. * @param mesh The mesh to prepare the morph targets attributes for
  73118. * @param defines The current Defines of the effect
  73119. */
  73120. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73121. /**
  73122. * Prepares the list of attributes required for bones according to the effect defines.
  73123. * @param attribs The current list of supported attribs
  73124. * @param mesh The mesh to prepare the bones attributes for
  73125. * @param defines The current Defines of the effect
  73126. * @param fallbacks The current efffect fallback strategy
  73127. */
  73128. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73129. /**
  73130. * Check and prepare the list of attributes required for instances according to the effect defines.
  73131. * @param attribs The current list of supported attribs
  73132. * @param defines The current MaterialDefines of the effect
  73133. */
  73134. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73135. /**
  73136. * Add the list of attributes required for instances to the attribs array.
  73137. * @param attribs The current list of supported attribs
  73138. */
  73139. static PushAttributesForInstances(attribs: string[]): void;
  73140. /**
  73141. * Binds the light shadow information to the effect for the given mesh.
  73142. * @param light The light containing the generator
  73143. * @param scene The scene the lights belongs to
  73144. * @param mesh The mesh we are binding the information to render
  73145. * @param lightIndex The light index in the effect used to render the mesh
  73146. * @param effect The effect we are binding the data to
  73147. */
  73148. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73149. /**
  73150. * Binds the light information to the effect.
  73151. * @param light The light containing the generator
  73152. * @param effect The effect we are binding the data to
  73153. * @param lightIndex The light index in the effect used to render
  73154. */
  73155. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73156. /**
  73157. * Binds the lights information from the scene to the effect for the given mesh.
  73158. * @param light Light to bind
  73159. * @param lightIndex Light index
  73160. * @param scene The scene where the light belongs to
  73161. * @param mesh The mesh we are binding the information to render
  73162. * @param effect The effect we are binding the data to
  73163. * @param useSpecular Defines if specular is supported
  73164. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73165. */
  73166. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73167. /**
  73168. * Binds the lights information from the scene to the effect for the given mesh.
  73169. * @param scene The scene the lights belongs to
  73170. * @param mesh The mesh we are binding the information to render
  73171. * @param effect The effect we are binding the data to
  73172. * @param defines The generated defines for the effect
  73173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73175. */
  73176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73177. private static _tempFogColor;
  73178. /**
  73179. * Binds the fog information from the scene to the effect for the given mesh.
  73180. * @param scene The scene the lights belongs to
  73181. * @param mesh The mesh we are binding the information to render
  73182. * @param effect The effect we are binding the data to
  73183. * @param linearSpace Defines if the fog effect is applied in linear space
  73184. */
  73185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73186. /**
  73187. * Binds the bones information from the mesh to the effect.
  73188. * @param mesh The mesh we are binding the information to render
  73189. * @param effect The effect we are binding the data to
  73190. */
  73191. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73192. /**
  73193. * Binds the morph targets information from the mesh to the effect.
  73194. * @param abstractMesh The mesh we are binding the information to render
  73195. * @param effect The effect we are binding the data to
  73196. */
  73197. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73198. /**
  73199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73200. * @param defines The generated defines used in the effect
  73201. * @param effect The effect we are binding the data to
  73202. * @param scene The scene we are willing to render with logarithmic scale for
  73203. */
  73204. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73205. /**
  73206. * Binds the clip plane information from the scene to the effect.
  73207. * @param scene The scene the clip plane information are extracted from
  73208. * @param effect The effect we are binding the data to
  73209. */
  73210. static BindClipPlane(effect: Effect, scene: Scene): void;
  73211. }
  73212. }
  73213. declare module BABYLON {
  73214. /** @hidden */
  73215. export var packingFunctions: {
  73216. name: string;
  73217. shader: string;
  73218. };
  73219. }
  73220. declare module BABYLON {
  73221. /** @hidden */
  73222. export var shadowMapPixelShader: {
  73223. name: string;
  73224. shader: string;
  73225. };
  73226. }
  73227. declare module BABYLON {
  73228. /** @hidden */
  73229. export var bonesDeclaration: {
  73230. name: string;
  73231. shader: string;
  73232. };
  73233. }
  73234. declare module BABYLON {
  73235. /** @hidden */
  73236. export var morphTargetsVertexGlobalDeclaration: {
  73237. name: string;
  73238. shader: string;
  73239. };
  73240. }
  73241. declare module BABYLON {
  73242. /** @hidden */
  73243. export var morphTargetsVertexDeclaration: {
  73244. name: string;
  73245. shader: string;
  73246. };
  73247. }
  73248. declare module BABYLON {
  73249. /** @hidden */
  73250. export var instancesDeclaration: {
  73251. name: string;
  73252. shader: string;
  73253. };
  73254. }
  73255. declare module BABYLON {
  73256. /** @hidden */
  73257. export var helperFunctions: {
  73258. name: string;
  73259. shader: string;
  73260. };
  73261. }
  73262. declare module BABYLON {
  73263. /** @hidden */
  73264. export var morphTargetsVertex: {
  73265. name: string;
  73266. shader: string;
  73267. };
  73268. }
  73269. declare module BABYLON {
  73270. /** @hidden */
  73271. export var instancesVertex: {
  73272. name: string;
  73273. shader: string;
  73274. };
  73275. }
  73276. declare module BABYLON {
  73277. /** @hidden */
  73278. export var bonesVertex: {
  73279. name: string;
  73280. shader: string;
  73281. };
  73282. }
  73283. declare module BABYLON {
  73284. /** @hidden */
  73285. export var shadowMapVertexShader: {
  73286. name: string;
  73287. shader: string;
  73288. };
  73289. }
  73290. declare module BABYLON {
  73291. /** @hidden */
  73292. export var depthBoxBlurPixelShader: {
  73293. name: string;
  73294. shader: string;
  73295. };
  73296. }
  73297. declare module BABYLON {
  73298. /**
  73299. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73300. */
  73301. export interface ICustomShaderOptions {
  73302. /**
  73303. * Gets or sets the custom shader name to use
  73304. */
  73305. shaderName: string;
  73306. /**
  73307. * The list of attribute names used in the shader
  73308. */
  73309. attributes?: string[];
  73310. /**
  73311. * The list of unifrom names used in the shader
  73312. */
  73313. uniforms?: string[];
  73314. /**
  73315. * The list of sampler names used in the shader
  73316. */
  73317. samplers?: string[];
  73318. /**
  73319. * The list of defines used in the shader
  73320. */
  73321. defines?: string[];
  73322. }
  73323. /**
  73324. * Interface to implement to create a shadow generator compatible with BJS.
  73325. */
  73326. export interface IShadowGenerator {
  73327. /**
  73328. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73329. * @returns The render target texture if present otherwise, null
  73330. */
  73331. getShadowMap(): Nullable<RenderTargetTexture>;
  73332. /**
  73333. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73334. * @returns The render target texture if the shadow map is present otherwise, null
  73335. */
  73336. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73337. /**
  73338. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73339. * @param subMesh The submesh we want to render in the shadow map
  73340. * @param useInstances Defines wether will draw in the map using instances
  73341. * @returns true if ready otherwise, false
  73342. */
  73343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73344. /**
  73345. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73346. * @param defines Defines of the material we want to update
  73347. * @param lightIndex Index of the light in the enabled light list of the material
  73348. */
  73349. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73350. /**
  73351. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73352. * defined in the generator but impacting the effect).
  73353. * It implies the unifroms available on the materials are the standard BJS ones.
  73354. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73355. * @param effect The effect we are binfing the information for
  73356. */
  73357. bindShadowLight(lightIndex: string, effect: Effect): void;
  73358. /**
  73359. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73360. * (eq to shadow prjection matrix * light transform matrix)
  73361. * @returns The transform matrix used to create the shadow map
  73362. */
  73363. getTransformMatrix(): Matrix;
  73364. /**
  73365. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73366. * Cube and 2D textures for instance.
  73367. */
  73368. recreateShadowMap(): void;
  73369. /**
  73370. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73371. * @param onCompiled Callback triggered at the and of the effects compilation
  73372. * @param options Sets of optional options forcing the compilation with different modes
  73373. */
  73374. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73375. useInstances: boolean;
  73376. }>): void;
  73377. /**
  73378. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73379. * @param options Sets of optional options forcing the compilation with different modes
  73380. * @returns A promise that resolves when the compilation completes
  73381. */
  73382. forceCompilationAsync(options?: Partial<{
  73383. useInstances: boolean;
  73384. }>): Promise<void>;
  73385. /**
  73386. * Serializes the shadow generator setup to a json object.
  73387. * @returns The serialized JSON object
  73388. */
  73389. serialize(): any;
  73390. /**
  73391. * Disposes the Shadow map and related Textures and effects.
  73392. */
  73393. dispose(): void;
  73394. }
  73395. /**
  73396. * Default implementation IShadowGenerator.
  73397. * This is the main object responsible of generating shadows in the framework.
  73398. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73399. */
  73400. export class ShadowGenerator implements IShadowGenerator {
  73401. /**
  73402. * Shadow generator mode None: no filtering applied.
  73403. */
  73404. static readonly FILTER_NONE: number;
  73405. /**
  73406. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73407. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73408. */
  73409. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73410. /**
  73411. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73412. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73413. */
  73414. static readonly FILTER_POISSONSAMPLING: number;
  73415. /**
  73416. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73417. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73418. */
  73419. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73420. /**
  73421. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73422. * edge artifacts on steep falloff.
  73423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73424. */
  73425. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73426. /**
  73427. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73428. * edge artifacts on steep falloff.
  73429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73430. */
  73431. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73432. /**
  73433. * Shadow generator mode PCF: Percentage Closer Filtering
  73434. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73435. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73436. */
  73437. static readonly FILTER_PCF: number;
  73438. /**
  73439. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73440. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73441. * Contact Hardening
  73442. */
  73443. static readonly FILTER_PCSS: number;
  73444. /**
  73445. * Reserved for PCF and PCSS
  73446. * Highest Quality.
  73447. *
  73448. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73449. *
  73450. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73451. */
  73452. static readonly QUALITY_HIGH: number;
  73453. /**
  73454. * Reserved for PCF and PCSS
  73455. * Good tradeoff for quality/perf cross devices
  73456. *
  73457. * Execute PCF on a 3*3 kernel.
  73458. *
  73459. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73460. */
  73461. static readonly QUALITY_MEDIUM: number;
  73462. /**
  73463. * Reserved for PCF and PCSS
  73464. * The lowest quality but the fastest.
  73465. *
  73466. * Execute PCF on a 1*1 kernel.
  73467. *
  73468. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73469. */
  73470. static readonly QUALITY_LOW: number;
  73471. /** Gets or sets the custom shader name to use */
  73472. customShaderOptions: ICustomShaderOptions;
  73473. /**
  73474. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73475. */
  73476. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73477. /**
  73478. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73479. */
  73480. onAfterShadowMapRenderObservable: Observable<Effect>;
  73481. /**
  73482. * Observable triggered before a mesh is rendered in the shadow map.
  73483. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73484. */
  73485. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73486. /**
  73487. * Observable triggered after a mesh is rendered in the shadow map.
  73488. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73489. */
  73490. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73491. private _bias;
  73492. /**
  73493. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73494. */
  73495. /**
  73496. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73497. */
  73498. bias: number;
  73499. private _normalBias;
  73500. /**
  73501. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73502. */
  73503. /**
  73504. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73505. */
  73506. normalBias: number;
  73507. private _blurBoxOffset;
  73508. /**
  73509. * Gets the blur box offset: offset applied during the blur pass.
  73510. * Only useful if useKernelBlur = false
  73511. */
  73512. /**
  73513. * Sets the blur box offset: offset applied during the blur pass.
  73514. * Only useful if useKernelBlur = false
  73515. */
  73516. blurBoxOffset: number;
  73517. private _blurScale;
  73518. /**
  73519. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73520. * 2 means half of the size.
  73521. */
  73522. /**
  73523. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73524. * 2 means half of the size.
  73525. */
  73526. blurScale: number;
  73527. private _blurKernel;
  73528. /**
  73529. * Gets the blur kernel: kernel size of the blur pass.
  73530. * Only useful if useKernelBlur = true
  73531. */
  73532. /**
  73533. * Sets the blur kernel: kernel size of the blur pass.
  73534. * Only useful if useKernelBlur = true
  73535. */
  73536. blurKernel: number;
  73537. private _useKernelBlur;
  73538. /**
  73539. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73540. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73541. */
  73542. /**
  73543. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73544. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73545. */
  73546. useKernelBlur: boolean;
  73547. private _depthScale;
  73548. /**
  73549. * Gets the depth scale used in ESM mode.
  73550. */
  73551. /**
  73552. * Sets the depth scale used in ESM mode.
  73553. * This can override the scale stored on the light.
  73554. */
  73555. depthScale: number;
  73556. private _filter;
  73557. /**
  73558. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73559. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73560. */
  73561. /**
  73562. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73563. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73564. */
  73565. filter: number;
  73566. /**
  73567. * Gets if the current filter is set to Poisson Sampling.
  73568. */
  73569. /**
  73570. * Sets the current filter to Poisson Sampling.
  73571. */
  73572. usePoissonSampling: boolean;
  73573. /**
  73574. * Gets if the current filter is set to ESM.
  73575. */
  73576. /**
  73577. * Sets the current filter is to ESM.
  73578. */
  73579. useExponentialShadowMap: boolean;
  73580. /**
  73581. * Gets if the current filter is set to filtered ESM.
  73582. */
  73583. /**
  73584. * Gets if the current filter is set to filtered ESM.
  73585. */
  73586. useBlurExponentialShadowMap: boolean;
  73587. /**
  73588. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73589. * exponential to prevent steep falloff artifacts).
  73590. */
  73591. /**
  73592. * Sets the current filter to "close ESM" (using the inverse of the
  73593. * exponential to prevent steep falloff artifacts).
  73594. */
  73595. useCloseExponentialShadowMap: boolean;
  73596. /**
  73597. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73598. * exponential to prevent steep falloff artifacts).
  73599. */
  73600. /**
  73601. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73602. * exponential to prevent steep falloff artifacts).
  73603. */
  73604. useBlurCloseExponentialShadowMap: boolean;
  73605. /**
  73606. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73607. */
  73608. /**
  73609. * Sets the current filter to "PCF" (percentage closer filtering).
  73610. */
  73611. usePercentageCloserFiltering: boolean;
  73612. private _filteringQuality;
  73613. /**
  73614. * Gets the PCF or PCSS Quality.
  73615. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73616. */
  73617. /**
  73618. * Sets the PCF or PCSS Quality.
  73619. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73620. */
  73621. filteringQuality: number;
  73622. /**
  73623. * Gets if the current filter is set to "PCSS" (contact hardening).
  73624. */
  73625. /**
  73626. * Sets the current filter to "PCSS" (contact hardening).
  73627. */
  73628. useContactHardeningShadow: boolean;
  73629. private _contactHardeningLightSizeUVRatio;
  73630. /**
  73631. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73632. * Using a ratio helps keeping shape stability independently of the map size.
  73633. *
  73634. * It does not account for the light projection as it was having too much
  73635. * instability during the light setup or during light position changes.
  73636. *
  73637. * Only valid if useContactHardeningShadow is true.
  73638. */
  73639. /**
  73640. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73641. * Using a ratio helps keeping shape stability independently of the map size.
  73642. *
  73643. * It does not account for the light projection as it was having too much
  73644. * instability during the light setup or during light position changes.
  73645. *
  73646. * Only valid if useContactHardeningShadow is true.
  73647. */
  73648. contactHardeningLightSizeUVRatio: number;
  73649. private _darkness;
  73650. /** Gets or sets the actual darkness of a shadow */
  73651. darkness: number;
  73652. /**
  73653. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73654. * 0 means strongest and 1 would means no shadow.
  73655. * @returns the darkness.
  73656. */
  73657. getDarkness(): number;
  73658. /**
  73659. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73660. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73661. * @returns the shadow generator allowing fluent coding.
  73662. */
  73663. setDarkness(darkness: number): ShadowGenerator;
  73664. private _transparencyShadow;
  73665. /** Gets or sets the ability to have transparent shadow */
  73666. transparencyShadow: boolean;
  73667. /**
  73668. * Sets the ability to have transparent shadow (boolean).
  73669. * @param transparent True if transparent else False
  73670. * @returns the shadow generator allowing fluent coding
  73671. */
  73672. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73673. private _shadowMap;
  73674. private _shadowMap2;
  73675. /**
  73676. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73677. * @returns The render target texture if present otherwise, null
  73678. */
  73679. getShadowMap(): Nullable<RenderTargetTexture>;
  73680. /**
  73681. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73682. * @returns The render target texture if the shadow map is present otherwise, null
  73683. */
  73684. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73685. /**
  73686. * Gets the class name of that object
  73687. * @returns "ShadowGenerator"
  73688. */
  73689. getClassName(): string;
  73690. /**
  73691. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73692. * @param mesh Mesh to add
  73693. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73694. * @returns the Shadow Generator itself
  73695. */
  73696. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73697. /**
  73698. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73699. * @param mesh Mesh to remove
  73700. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73701. * @returns the Shadow Generator itself
  73702. */
  73703. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73704. /**
  73705. * Controls the extent to which the shadows fade out at the edge of the frustum
  73706. * Used only by directionals and spots
  73707. */
  73708. frustumEdgeFalloff: number;
  73709. private _light;
  73710. /**
  73711. * Returns the associated light object.
  73712. * @returns the light generating the shadow
  73713. */
  73714. getLight(): IShadowLight;
  73715. /**
  73716. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73717. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73718. * It might on the other hand introduce peter panning.
  73719. */
  73720. forceBackFacesOnly: boolean;
  73721. private _scene;
  73722. private _lightDirection;
  73723. private _effect;
  73724. private _viewMatrix;
  73725. private _projectionMatrix;
  73726. private _transformMatrix;
  73727. private _cachedPosition;
  73728. private _cachedDirection;
  73729. private _cachedDefines;
  73730. private _currentRenderID;
  73731. private _boxBlurPostprocess;
  73732. private _kernelBlurXPostprocess;
  73733. private _kernelBlurYPostprocess;
  73734. private _blurPostProcesses;
  73735. private _mapSize;
  73736. private _currentFaceIndex;
  73737. private _currentFaceIndexCache;
  73738. private _textureType;
  73739. private _defaultTextureMatrix;
  73740. /** @hidden */
  73741. static _SceneComponentInitialization: (scene: Scene) => void;
  73742. /**
  73743. * Creates a ShadowGenerator object.
  73744. * A ShadowGenerator is the required tool to use the shadows.
  73745. * Each light casting shadows needs to use its own ShadowGenerator.
  73746. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73747. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73748. * @param light The light object generating the shadows.
  73749. * @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.
  73750. */
  73751. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73752. private _initializeGenerator;
  73753. private _initializeShadowMap;
  73754. private _initializeBlurRTTAndPostProcesses;
  73755. private _renderForShadowMap;
  73756. private _renderSubMeshForShadowMap;
  73757. private _applyFilterValues;
  73758. /**
  73759. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73760. * @param onCompiled Callback triggered at the and of the effects compilation
  73761. * @param options Sets of optional options forcing the compilation with different modes
  73762. */
  73763. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73764. useInstances: boolean;
  73765. }>): void;
  73766. /**
  73767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73768. * @param options Sets of optional options forcing the compilation with different modes
  73769. * @returns A promise that resolves when the compilation completes
  73770. */
  73771. forceCompilationAsync(options?: Partial<{
  73772. useInstances: boolean;
  73773. }>): Promise<void>;
  73774. /**
  73775. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73776. * @param subMesh The submesh we want to render in the shadow map
  73777. * @param useInstances Defines wether will draw in the map using instances
  73778. * @returns true if ready otherwise, false
  73779. */
  73780. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73781. /**
  73782. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73783. * @param defines Defines of the material we want to update
  73784. * @param lightIndex Index of the light in the enabled light list of the material
  73785. */
  73786. prepareDefines(defines: any, lightIndex: number): void;
  73787. /**
  73788. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73789. * defined in the generator but impacting the effect).
  73790. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73791. * @param effect The effect we are binfing the information for
  73792. */
  73793. bindShadowLight(lightIndex: string, effect: Effect): void;
  73794. /**
  73795. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73796. * (eq to shadow prjection matrix * light transform matrix)
  73797. * @returns The transform matrix used to create the shadow map
  73798. */
  73799. getTransformMatrix(): Matrix;
  73800. /**
  73801. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73802. * Cube and 2D textures for instance.
  73803. */
  73804. recreateShadowMap(): void;
  73805. private _disposeBlurPostProcesses;
  73806. private _disposeRTTandPostProcesses;
  73807. /**
  73808. * Disposes the ShadowGenerator.
  73809. * Returns nothing.
  73810. */
  73811. dispose(): void;
  73812. /**
  73813. * Serializes the shadow generator setup to a json object.
  73814. * @returns The serialized JSON object
  73815. */
  73816. serialize(): any;
  73817. /**
  73818. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73819. * @param parsedShadowGenerator The JSON object to parse
  73820. * @param scene The scene to create the shadow map for
  73821. * @returns The parsed shadow generator
  73822. */
  73823. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73824. }
  73825. }
  73826. declare module BABYLON {
  73827. /**
  73828. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73829. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73830. * 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.
  73831. */
  73832. export abstract class Light extends Node {
  73833. /**
  73834. * Falloff Default: light is falling off following the material specification:
  73835. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73836. */
  73837. static readonly FALLOFF_DEFAULT: number;
  73838. /**
  73839. * Falloff Physical: light is falling off following the inverse squared distance law.
  73840. */
  73841. static readonly FALLOFF_PHYSICAL: number;
  73842. /**
  73843. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73844. * to enhance interoperability with other engines.
  73845. */
  73846. static readonly FALLOFF_GLTF: number;
  73847. /**
  73848. * Falloff Standard: light is falling off like in the standard material
  73849. * to enhance interoperability with other materials.
  73850. */
  73851. static readonly FALLOFF_STANDARD: number;
  73852. /**
  73853. * If every light affecting the material is in this lightmapMode,
  73854. * material.lightmapTexture adds or multiplies
  73855. * (depends on material.useLightmapAsShadowmap)
  73856. * after every other light calculations.
  73857. */
  73858. static readonly LIGHTMAP_DEFAULT: number;
  73859. /**
  73860. * material.lightmapTexture as only diffuse lighting from this light
  73861. * adds only specular lighting from this light
  73862. * adds dynamic shadows
  73863. */
  73864. static readonly LIGHTMAP_SPECULAR: number;
  73865. /**
  73866. * material.lightmapTexture as only lighting
  73867. * no light calculation from this light
  73868. * only adds dynamic shadows from this light
  73869. */
  73870. static readonly LIGHTMAP_SHADOWSONLY: number;
  73871. /**
  73872. * Each light type uses the default quantity according to its type:
  73873. * point/spot lights use luminous intensity
  73874. * directional lights use illuminance
  73875. */
  73876. static readonly INTENSITYMODE_AUTOMATIC: number;
  73877. /**
  73878. * lumen (lm)
  73879. */
  73880. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73881. /**
  73882. * candela (lm/sr)
  73883. */
  73884. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73885. /**
  73886. * lux (lm/m^2)
  73887. */
  73888. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73889. /**
  73890. * nit (cd/m^2)
  73891. */
  73892. static readonly INTENSITYMODE_LUMINANCE: number;
  73893. /**
  73894. * Light type const id of the point light.
  73895. */
  73896. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73897. /**
  73898. * Light type const id of the directional light.
  73899. */
  73900. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73901. /**
  73902. * Light type const id of the spot light.
  73903. */
  73904. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73905. /**
  73906. * Light type const id of the hemispheric light.
  73907. */
  73908. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73909. /**
  73910. * Diffuse gives the basic color to an object.
  73911. */
  73912. diffuse: Color3;
  73913. /**
  73914. * Specular produces a highlight color on an object.
  73915. * Note: This is note affecting PBR materials.
  73916. */
  73917. specular: Color3;
  73918. /**
  73919. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73920. * falling off base on range or angle.
  73921. * This can be set to any values in Light.FALLOFF_x.
  73922. *
  73923. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73924. * other types of materials.
  73925. */
  73926. falloffType: number;
  73927. /**
  73928. * Strength of the light.
  73929. * Note: By default it is define in the framework own unit.
  73930. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73931. */
  73932. intensity: number;
  73933. private _range;
  73934. protected _inverseSquaredRange: number;
  73935. /**
  73936. * Defines how far from the source the light is impacting in scene units.
  73937. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73938. */
  73939. /**
  73940. * Defines how far from the source the light is impacting in scene units.
  73941. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73942. */
  73943. range: number;
  73944. /**
  73945. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73946. * of light.
  73947. */
  73948. private _photometricScale;
  73949. private _intensityMode;
  73950. /**
  73951. * Gets the photometric scale used to interpret the intensity.
  73952. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73953. */
  73954. /**
  73955. * Sets the photometric scale used to interpret the intensity.
  73956. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73957. */
  73958. intensityMode: number;
  73959. private _radius;
  73960. /**
  73961. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73962. */
  73963. /**
  73964. * sets the light radius used by PBR Materials to simulate soft area lights.
  73965. */
  73966. radius: number;
  73967. private _renderPriority;
  73968. /**
  73969. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73970. * exceeding the number allowed of the materials.
  73971. */
  73972. renderPriority: number;
  73973. private _shadowEnabled;
  73974. /**
  73975. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73976. * the current shadow generator.
  73977. */
  73978. /**
  73979. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73980. * the current shadow generator.
  73981. */
  73982. shadowEnabled: boolean;
  73983. private _includedOnlyMeshes;
  73984. /**
  73985. * Gets the only meshes impacted by this light.
  73986. */
  73987. /**
  73988. * Sets the only meshes impacted by this light.
  73989. */
  73990. includedOnlyMeshes: AbstractMesh[];
  73991. private _excludedMeshes;
  73992. /**
  73993. * Gets the meshes not impacted by this light.
  73994. */
  73995. /**
  73996. * Sets the meshes not impacted by this light.
  73997. */
  73998. excludedMeshes: AbstractMesh[];
  73999. private _excludeWithLayerMask;
  74000. /**
  74001. * Gets the layer id use to find what meshes are not impacted by the light.
  74002. * Inactive if 0
  74003. */
  74004. /**
  74005. * Sets the layer id use to find what meshes are not impacted by the light.
  74006. * Inactive if 0
  74007. */
  74008. excludeWithLayerMask: number;
  74009. private _includeOnlyWithLayerMask;
  74010. /**
  74011. * Gets the layer id use to find what meshes are impacted by the light.
  74012. * Inactive if 0
  74013. */
  74014. /**
  74015. * Sets the layer id use to find what meshes are impacted by the light.
  74016. * Inactive if 0
  74017. */
  74018. includeOnlyWithLayerMask: number;
  74019. private _lightmapMode;
  74020. /**
  74021. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74022. */
  74023. /**
  74024. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74025. */
  74026. lightmapMode: number;
  74027. /**
  74028. * Shadow generator associted to the light.
  74029. * @hidden Internal use only.
  74030. */
  74031. _shadowGenerator: Nullable<IShadowGenerator>;
  74032. /**
  74033. * @hidden Internal use only.
  74034. */
  74035. _excludedMeshesIds: string[];
  74036. /**
  74037. * @hidden Internal use only.
  74038. */
  74039. _includedOnlyMeshesIds: string[];
  74040. /**
  74041. * The current light unifom buffer.
  74042. * @hidden Internal use only.
  74043. */
  74044. _uniformBuffer: UniformBuffer;
  74045. /**
  74046. * Creates a Light object in the scene.
  74047. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74048. * @param name The firendly name of the light
  74049. * @param scene The scene the light belongs too
  74050. */
  74051. constructor(name: string, scene: Scene);
  74052. protected abstract _buildUniformLayout(): void;
  74053. /**
  74054. * Sets the passed Effect "effect" with the Light information.
  74055. * @param effect The effect to update
  74056. * @param lightIndex The index of the light in the effect to update
  74057. * @returns The light
  74058. */
  74059. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74060. /**
  74061. * Returns the string "Light".
  74062. * @returns the class name
  74063. */
  74064. getClassName(): string;
  74065. /** @hidden */
  74066. readonly _isLight: boolean;
  74067. /**
  74068. * Converts the light information to a readable string for debug purpose.
  74069. * @param fullDetails Supports for multiple levels of logging within scene loading
  74070. * @returns the human readable light info
  74071. */
  74072. toString(fullDetails?: boolean): string;
  74073. /** @hidden */
  74074. protected _syncParentEnabledState(): void;
  74075. /**
  74076. * Set the enabled state of this node.
  74077. * @param value - the new enabled state
  74078. */
  74079. setEnabled(value: boolean): void;
  74080. /**
  74081. * Returns the Light associated shadow generator if any.
  74082. * @return the associated shadow generator.
  74083. */
  74084. getShadowGenerator(): Nullable<IShadowGenerator>;
  74085. /**
  74086. * Returns a Vector3, the absolute light position in the World.
  74087. * @returns the world space position of the light
  74088. */
  74089. getAbsolutePosition(): Vector3;
  74090. /**
  74091. * Specifies if the light will affect the passed mesh.
  74092. * @param mesh The mesh to test against the light
  74093. * @return true the mesh is affected otherwise, false.
  74094. */
  74095. canAffectMesh(mesh: AbstractMesh): boolean;
  74096. /**
  74097. * Sort function to order lights for rendering.
  74098. * @param a First Light object to compare to second.
  74099. * @param b Second Light object to compare first.
  74100. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74101. */
  74102. static CompareLightsPriority(a: Light, b: Light): number;
  74103. /**
  74104. * Releases resources associated with this node.
  74105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74107. */
  74108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74109. /**
  74110. * Returns the light type ID (integer).
  74111. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74112. */
  74113. getTypeID(): number;
  74114. /**
  74115. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74116. * @returns the scaled intensity in intensity mode unit
  74117. */
  74118. getScaledIntensity(): number;
  74119. /**
  74120. * Returns a new Light object, named "name", from the current one.
  74121. * @param name The name of the cloned light
  74122. * @returns the new created light
  74123. */
  74124. clone(name: string): Nullable<Light>;
  74125. /**
  74126. * Serializes the current light into a Serialization object.
  74127. * @returns the serialized object.
  74128. */
  74129. serialize(): any;
  74130. /**
  74131. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74132. * This new light is named "name" and added to the passed scene.
  74133. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74134. * @param name The friendly name of the light
  74135. * @param scene The scene the new light will belong to
  74136. * @returns the constructor function
  74137. */
  74138. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74139. /**
  74140. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74141. * @param parsedLight The JSON representation of the light
  74142. * @param scene The scene to create the parsed light in
  74143. * @returns the created light after parsing
  74144. */
  74145. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74146. private _hookArrayForExcluded;
  74147. private _hookArrayForIncludedOnly;
  74148. private _resyncMeshes;
  74149. /**
  74150. * Forces the meshes to update their light related information in their rendering used effects
  74151. * @hidden Internal Use Only
  74152. */
  74153. _markMeshesAsLightDirty(): void;
  74154. /**
  74155. * Recomputes the cached photometric scale if needed.
  74156. */
  74157. private _computePhotometricScale;
  74158. /**
  74159. * Returns the Photometric Scale according to the light type and intensity mode.
  74160. */
  74161. private _getPhotometricScale;
  74162. /**
  74163. * Reorder the light in the scene according to their defined priority.
  74164. * @hidden Internal Use Only
  74165. */
  74166. _reorderLightsInScene(): void;
  74167. /**
  74168. * Prepares the list of defines specific to the light type.
  74169. * @param defines the list of defines
  74170. * @param lightIndex defines the index of the light for the effect
  74171. */
  74172. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74173. }
  74174. }
  74175. declare module BABYLON {
  74176. /**
  74177. * Interface used to define Action
  74178. */
  74179. export interface IAction {
  74180. /**
  74181. * Trigger for the action
  74182. */
  74183. trigger: number;
  74184. /** Options of the trigger */
  74185. triggerOptions: any;
  74186. /**
  74187. * Gets the trigger parameters
  74188. * @returns the trigger parameters
  74189. */
  74190. getTriggerParameter(): any;
  74191. /**
  74192. * Internal only - executes current action event
  74193. * @hidden
  74194. */
  74195. _executeCurrent(evt?: ActionEvent): void;
  74196. /**
  74197. * Serialize placeholder for child classes
  74198. * @param parent of child
  74199. * @returns the serialized object
  74200. */
  74201. serialize(parent: any): any;
  74202. /**
  74203. * Internal only
  74204. * @hidden
  74205. */
  74206. _prepare(): void;
  74207. /**
  74208. * Internal only - manager for action
  74209. * @hidden
  74210. */
  74211. _actionManager: AbstractActionManager;
  74212. /**
  74213. * Adds action to chain of actions, may be a DoNothingAction
  74214. * @param action defines the next action to execute
  74215. * @returns The action passed in
  74216. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74217. */
  74218. then(action: IAction): IAction;
  74219. }
  74220. /**
  74221. * The action to be carried out following a trigger
  74222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74223. */
  74224. export class Action implements IAction {
  74225. /** the trigger, with or without parameters, for the action */
  74226. triggerOptions: any;
  74227. /**
  74228. * Trigger for the action
  74229. */
  74230. trigger: number;
  74231. /**
  74232. * Internal only - manager for action
  74233. * @hidden
  74234. */
  74235. _actionManager: ActionManager;
  74236. private _nextActiveAction;
  74237. private _child;
  74238. private _condition?;
  74239. private _triggerParameter;
  74240. /**
  74241. * An event triggered prior to action being executed.
  74242. */
  74243. onBeforeExecuteObservable: Observable<Action>;
  74244. /**
  74245. * Creates a new Action
  74246. * @param triggerOptions the trigger, with or without parameters, for the action
  74247. * @param condition an optional determinant of action
  74248. */
  74249. constructor(
  74250. /** the trigger, with or without parameters, for the action */
  74251. triggerOptions: any, condition?: Condition);
  74252. /**
  74253. * Internal only
  74254. * @hidden
  74255. */
  74256. _prepare(): void;
  74257. /**
  74258. * Gets the trigger parameters
  74259. * @returns the trigger parameters
  74260. */
  74261. getTriggerParameter(): any;
  74262. /**
  74263. * Internal only - executes current action event
  74264. * @hidden
  74265. */
  74266. _executeCurrent(evt?: ActionEvent): void;
  74267. /**
  74268. * Execute placeholder for child classes
  74269. * @param evt optional action event
  74270. */
  74271. execute(evt?: ActionEvent): void;
  74272. /**
  74273. * Skips to next active action
  74274. */
  74275. skipToNextActiveAction(): void;
  74276. /**
  74277. * Adds action to chain of actions, may be a DoNothingAction
  74278. * @param action defines the next action to execute
  74279. * @returns The action passed in
  74280. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74281. */
  74282. then(action: Action): Action;
  74283. /**
  74284. * Internal only
  74285. * @hidden
  74286. */
  74287. _getProperty(propertyPath: string): string;
  74288. /**
  74289. * Internal only
  74290. * @hidden
  74291. */
  74292. _getEffectiveTarget(target: any, propertyPath: string): any;
  74293. /**
  74294. * Serialize placeholder for child classes
  74295. * @param parent of child
  74296. * @returns the serialized object
  74297. */
  74298. serialize(parent: any): any;
  74299. /**
  74300. * Internal only called by serialize
  74301. * @hidden
  74302. */
  74303. protected _serialize(serializedAction: any, parent?: any): any;
  74304. /**
  74305. * Internal only
  74306. * @hidden
  74307. */
  74308. static _SerializeValueAsString: (value: any) => string;
  74309. /**
  74310. * Internal only
  74311. * @hidden
  74312. */
  74313. static _GetTargetProperty: (target: Node | Scene) => {
  74314. name: string;
  74315. targetType: string;
  74316. value: string;
  74317. };
  74318. }
  74319. }
  74320. declare module BABYLON {
  74321. /**
  74322. * A Condition applied to an Action
  74323. */
  74324. export class Condition {
  74325. /**
  74326. * Internal only - manager for action
  74327. * @hidden
  74328. */
  74329. _actionManager: ActionManager;
  74330. /**
  74331. * Internal only
  74332. * @hidden
  74333. */
  74334. _evaluationId: number;
  74335. /**
  74336. * Internal only
  74337. * @hidden
  74338. */
  74339. _currentResult: boolean;
  74340. /**
  74341. * Creates a new Condition
  74342. * @param actionManager the manager of the action the condition is applied to
  74343. */
  74344. constructor(actionManager: ActionManager);
  74345. /**
  74346. * Check if the current condition is valid
  74347. * @returns a boolean
  74348. */
  74349. isValid(): boolean;
  74350. /**
  74351. * Internal only
  74352. * @hidden
  74353. */
  74354. _getProperty(propertyPath: string): string;
  74355. /**
  74356. * Internal only
  74357. * @hidden
  74358. */
  74359. _getEffectiveTarget(target: any, propertyPath: string): any;
  74360. /**
  74361. * Serialize placeholder for child classes
  74362. * @returns the serialized object
  74363. */
  74364. serialize(): any;
  74365. /**
  74366. * Internal only
  74367. * @hidden
  74368. */
  74369. protected _serialize(serializedCondition: any): any;
  74370. }
  74371. /**
  74372. * Defines specific conditional operators as extensions of Condition
  74373. */
  74374. export class ValueCondition extends Condition {
  74375. /** path to specify the property of the target the conditional operator uses */
  74376. propertyPath: string;
  74377. /** the value compared by the conditional operator against the current value of the property */
  74378. value: any;
  74379. /** the conditional operator, default ValueCondition.IsEqual */
  74380. operator: number;
  74381. /**
  74382. * Internal only
  74383. * @hidden
  74384. */
  74385. private static _IsEqual;
  74386. /**
  74387. * Internal only
  74388. * @hidden
  74389. */
  74390. private static _IsDifferent;
  74391. /**
  74392. * Internal only
  74393. * @hidden
  74394. */
  74395. private static _IsGreater;
  74396. /**
  74397. * Internal only
  74398. * @hidden
  74399. */
  74400. private static _IsLesser;
  74401. /**
  74402. * returns the number for IsEqual
  74403. */
  74404. static readonly IsEqual: number;
  74405. /**
  74406. * Returns the number for IsDifferent
  74407. */
  74408. static readonly IsDifferent: number;
  74409. /**
  74410. * Returns the number for IsGreater
  74411. */
  74412. static readonly IsGreater: number;
  74413. /**
  74414. * Returns the number for IsLesser
  74415. */
  74416. static readonly IsLesser: number;
  74417. /**
  74418. * Internal only The action manager for the condition
  74419. * @hidden
  74420. */
  74421. _actionManager: ActionManager;
  74422. /**
  74423. * Internal only
  74424. * @hidden
  74425. */
  74426. private _target;
  74427. /**
  74428. * Internal only
  74429. * @hidden
  74430. */
  74431. private _effectiveTarget;
  74432. /**
  74433. * Internal only
  74434. * @hidden
  74435. */
  74436. private _property;
  74437. /**
  74438. * Creates a new ValueCondition
  74439. * @param actionManager manager for the action the condition applies to
  74440. * @param target for the action
  74441. * @param propertyPath path to specify the property of the target the conditional operator uses
  74442. * @param value the value compared by the conditional operator against the current value of the property
  74443. * @param operator the conditional operator, default ValueCondition.IsEqual
  74444. */
  74445. constructor(actionManager: ActionManager, target: any,
  74446. /** path to specify the property of the target the conditional operator uses */
  74447. propertyPath: string,
  74448. /** the value compared by the conditional operator against the current value of the property */
  74449. value: any,
  74450. /** the conditional operator, default ValueCondition.IsEqual */
  74451. operator?: number);
  74452. /**
  74453. * Compares the given value with the property value for the specified conditional operator
  74454. * @returns the result of the comparison
  74455. */
  74456. isValid(): boolean;
  74457. /**
  74458. * Serialize the ValueCondition into a JSON compatible object
  74459. * @returns serialization object
  74460. */
  74461. serialize(): any;
  74462. /**
  74463. * Gets the name of the conditional operator for the ValueCondition
  74464. * @param operator the conditional operator
  74465. * @returns the name
  74466. */
  74467. static GetOperatorName(operator: number): string;
  74468. }
  74469. /**
  74470. * Defines a predicate condition as an extension of Condition
  74471. */
  74472. export class PredicateCondition extends Condition {
  74473. /** defines the predicate function used to validate the condition */
  74474. predicate: () => boolean;
  74475. /**
  74476. * Internal only - manager for action
  74477. * @hidden
  74478. */
  74479. _actionManager: ActionManager;
  74480. /**
  74481. * Creates a new PredicateCondition
  74482. * @param actionManager manager for the action the condition applies to
  74483. * @param predicate defines the predicate function used to validate the condition
  74484. */
  74485. constructor(actionManager: ActionManager,
  74486. /** defines the predicate function used to validate the condition */
  74487. predicate: () => boolean);
  74488. /**
  74489. * @returns the validity of the predicate condition
  74490. */
  74491. isValid(): boolean;
  74492. }
  74493. /**
  74494. * Defines a state condition as an extension of Condition
  74495. */
  74496. export class StateCondition extends Condition {
  74497. /** Value to compare with target state */
  74498. value: string;
  74499. /**
  74500. * Internal only - manager for action
  74501. * @hidden
  74502. */
  74503. _actionManager: ActionManager;
  74504. /**
  74505. * Internal only
  74506. * @hidden
  74507. */
  74508. private _target;
  74509. /**
  74510. * Creates a new StateCondition
  74511. * @param actionManager manager for the action the condition applies to
  74512. * @param target of the condition
  74513. * @param value to compare with target state
  74514. */
  74515. constructor(actionManager: ActionManager, target: any,
  74516. /** Value to compare with target state */
  74517. value: string);
  74518. /**
  74519. * Gets a boolean indicating if the current condition is met
  74520. * @returns the validity of the state
  74521. */
  74522. isValid(): boolean;
  74523. /**
  74524. * Serialize the StateCondition into a JSON compatible object
  74525. * @returns serialization object
  74526. */
  74527. serialize(): any;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /**
  74532. * This defines an action responsible to toggle a boolean once triggered.
  74533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74534. */
  74535. export class SwitchBooleanAction extends Action {
  74536. /**
  74537. * The path to the boolean property in the target object
  74538. */
  74539. propertyPath: string;
  74540. private _target;
  74541. private _effectiveTarget;
  74542. private _property;
  74543. /**
  74544. * Instantiate the action
  74545. * @param triggerOptions defines the trigger options
  74546. * @param target defines the object containing the boolean
  74547. * @param propertyPath defines the path to the boolean property in the target object
  74548. * @param condition defines the trigger related conditions
  74549. */
  74550. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74551. /** @hidden */
  74552. _prepare(): void;
  74553. /**
  74554. * Execute the action toggle the boolean value.
  74555. */
  74556. execute(): void;
  74557. /**
  74558. * Serializes the actions and its related information.
  74559. * @param parent defines the object to serialize in
  74560. * @returns the serialized object
  74561. */
  74562. serialize(parent: any): any;
  74563. }
  74564. /**
  74565. * This defines an action responsible to set a the state field of the target
  74566. * to a desired value once triggered.
  74567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74568. */
  74569. export class SetStateAction extends Action {
  74570. /**
  74571. * The value to store in the state field.
  74572. */
  74573. value: string;
  74574. private _target;
  74575. /**
  74576. * Instantiate the action
  74577. * @param triggerOptions defines the trigger options
  74578. * @param target defines the object containing the state property
  74579. * @param value defines the value to store in the state field
  74580. * @param condition defines the trigger related conditions
  74581. */
  74582. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74583. /**
  74584. * Execute the action and store the value on the target state property.
  74585. */
  74586. execute(): void;
  74587. /**
  74588. * Serializes the actions and its related information.
  74589. * @param parent defines the object to serialize in
  74590. * @returns the serialized object
  74591. */
  74592. serialize(parent: any): any;
  74593. }
  74594. /**
  74595. * This defines an action responsible to set a property of the target
  74596. * to a desired value once triggered.
  74597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74598. */
  74599. export class SetValueAction extends Action {
  74600. /**
  74601. * The path of the property to set in the target.
  74602. */
  74603. propertyPath: string;
  74604. /**
  74605. * The value to set in the property
  74606. */
  74607. value: any;
  74608. private _target;
  74609. private _effectiveTarget;
  74610. private _property;
  74611. /**
  74612. * Instantiate the action
  74613. * @param triggerOptions defines the trigger options
  74614. * @param target defines the object containing the property
  74615. * @param propertyPath defines the path of the property to set in the target
  74616. * @param value defines the value to set in the property
  74617. * @param condition defines the trigger related conditions
  74618. */
  74619. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74620. /** @hidden */
  74621. _prepare(): void;
  74622. /**
  74623. * Execute the action and set the targetted property to the desired value.
  74624. */
  74625. execute(): void;
  74626. /**
  74627. * Serializes the actions and its related information.
  74628. * @param parent defines the object to serialize in
  74629. * @returns the serialized object
  74630. */
  74631. serialize(parent: any): any;
  74632. }
  74633. /**
  74634. * This defines an action responsible to increment the target value
  74635. * to a desired value once triggered.
  74636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74637. */
  74638. export class IncrementValueAction extends Action {
  74639. /**
  74640. * The path of the property to increment in the target.
  74641. */
  74642. propertyPath: string;
  74643. /**
  74644. * The value we should increment the property by.
  74645. */
  74646. value: any;
  74647. private _target;
  74648. private _effectiveTarget;
  74649. private _property;
  74650. /**
  74651. * Instantiate the action
  74652. * @param triggerOptions defines the trigger options
  74653. * @param target defines the object containing the property
  74654. * @param propertyPath defines the path of the property to increment in the target
  74655. * @param value defines the value value we should increment the property by
  74656. * @param condition defines the trigger related conditions
  74657. */
  74658. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74659. /** @hidden */
  74660. _prepare(): void;
  74661. /**
  74662. * Execute the action and increment the target of the value amount.
  74663. */
  74664. execute(): void;
  74665. /**
  74666. * Serializes the actions and its related information.
  74667. * @param parent defines the object to serialize in
  74668. * @returns the serialized object
  74669. */
  74670. serialize(parent: any): any;
  74671. }
  74672. /**
  74673. * This defines an action responsible to start an animation once triggered.
  74674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74675. */
  74676. export class PlayAnimationAction extends Action {
  74677. /**
  74678. * Where the animation should start (animation frame)
  74679. */
  74680. from: number;
  74681. /**
  74682. * Where the animation should stop (animation frame)
  74683. */
  74684. to: number;
  74685. /**
  74686. * Define if the animation should loop or stop after the first play.
  74687. */
  74688. loop?: boolean;
  74689. private _target;
  74690. /**
  74691. * Instantiate the action
  74692. * @param triggerOptions defines the trigger options
  74693. * @param target defines the target animation or animation name
  74694. * @param from defines from where the animation should start (animation frame)
  74695. * @param end defines where the animation should stop (animation frame)
  74696. * @param loop defines if the animation should loop or stop after the first play
  74697. * @param condition defines the trigger related conditions
  74698. */
  74699. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74700. /** @hidden */
  74701. _prepare(): void;
  74702. /**
  74703. * Execute the action and play the animation.
  74704. */
  74705. execute(): void;
  74706. /**
  74707. * Serializes the actions and its related information.
  74708. * @param parent defines the object to serialize in
  74709. * @returns the serialized object
  74710. */
  74711. serialize(parent: any): any;
  74712. }
  74713. /**
  74714. * This defines an action responsible to stop an animation once triggered.
  74715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74716. */
  74717. export class StopAnimationAction extends Action {
  74718. private _target;
  74719. /**
  74720. * Instantiate the action
  74721. * @param triggerOptions defines the trigger options
  74722. * @param target defines the target animation or animation name
  74723. * @param condition defines the trigger related conditions
  74724. */
  74725. constructor(triggerOptions: any, target: any, condition?: Condition);
  74726. /** @hidden */
  74727. _prepare(): void;
  74728. /**
  74729. * Execute the action and stop the animation.
  74730. */
  74731. execute(): void;
  74732. /**
  74733. * Serializes the actions and its related information.
  74734. * @param parent defines the object to serialize in
  74735. * @returns the serialized object
  74736. */
  74737. serialize(parent: any): any;
  74738. }
  74739. /**
  74740. * This defines an action responsible that does nothing once triggered.
  74741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74742. */
  74743. export class DoNothingAction extends Action {
  74744. /**
  74745. * Instantiate the action
  74746. * @param triggerOptions defines the trigger options
  74747. * @param condition defines the trigger related conditions
  74748. */
  74749. constructor(triggerOptions?: any, condition?: Condition);
  74750. /**
  74751. * Execute the action and do nothing.
  74752. */
  74753. execute(): void;
  74754. /**
  74755. * Serializes the actions and its related information.
  74756. * @param parent defines the object to serialize in
  74757. * @returns the serialized object
  74758. */
  74759. serialize(parent: any): any;
  74760. }
  74761. /**
  74762. * This defines an action responsible to trigger several actions once triggered.
  74763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74764. */
  74765. export class CombineAction extends Action {
  74766. /**
  74767. * The list of aggregated animations to run.
  74768. */
  74769. children: Action[];
  74770. /**
  74771. * Instantiate the action
  74772. * @param triggerOptions defines the trigger options
  74773. * @param children defines the list of aggregated animations to run
  74774. * @param condition defines the trigger related conditions
  74775. */
  74776. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74777. /** @hidden */
  74778. _prepare(): void;
  74779. /**
  74780. * Execute the action and executes all the aggregated actions.
  74781. */
  74782. execute(evt: ActionEvent): void;
  74783. /**
  74784. * Serializes the actions and its related information.
  74785. * @param parent defines the object to serialize in
  74786. * @returns the serialized object
  74787. */
  74788. serialize(parent: any): any;
  74789. }
  74790. /**
  74791. * This defines an action responsible to run code (external event) once triggered.
  74792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74793. */
  74794. export class ExecuteCodeAction extends Action {
  74795. /**
  74796. * The callback function to run.
  74797. */
  74798. func: (evt: ActionEvent) => void;
  74799. /**
  74800. * Instantiate the action
  74801. * @param triggerOptions defines the trigger options
  74802. * @param func defines the callback function to run
  74803. * @param condition defines the trigger related conditions
  74804. */
  74805. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74806. /**
  74807. * Execute the action and run the attached code.
  74808. */
  74809. execute(evt: ActionEvent): void;
  74810. }
  74811. /**
  74812. * This defines an action responsible to set the parent property of the target once triggered.
  74813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74814. */
  74815. export class SetParentAction extends Action {
  74816. private _parent;
  74817. private _target;
  74818. /**
  74819. * Instantiate the action
  74820. * @param triggerOptions defines the trigger options
  74821. * @param target defines the target containing the parent property
  74822. * @param parent defines from where the animation should start (animation frame)
  74823. * @param condition defines the trigger related conditions
  74824. */
  74825. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74826. /** @hidden */
  74827. _prepare(): void;
  74828. /**
  74829. * Execute the action and set the parent property.
  74830. */
  74831. execute(): void;
  74832. /**
  74833. * Serializes the actions and its related information.
  74834. * @param parent defines the object to serialize in
  74835. * @returns the serialized object
  74836. */
  74837. serialize(parent: any): any;
  74838. }
  74839. }
  74840. declare module BABYLON {
  74841. /**
  74842. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74843. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74845. */
  74846. export class ActionManager extends AbstractActionManager {
  74847. /**
  74848. * Nothing
  74849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74850. */
  74851. static readonly NothingTrigger: number;
  74852. /**
  74853. * On pick
  74854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74855. */
  74856. static readonly OnPickTrigger: number;
  74857. /**
  74858. * On left pick
  74859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74860. */
  74861. static readonly OnLeftPickTrigger: number;
  74862. /**
  74863. * On right pick
  74864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74865. */
  74866. static readonly OnRightPickTrigger: number;
  74867. /**
  74868. * On center pick
  74869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74870. */
  74871. static readonly OnCenterPickTrigger: number;
  74872. /**
  74873. * On pick down
  74874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74875. */
  74876. static readonly OnPickDownTrigger: number;
  74877. /**
  74878. * On double pick
  74879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74880. */
  74881. static readonly OnDoublePickTrigger: number;
  74882. /**
  74883. * On pick up
  74884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74885. */
  74886. static readonly OnPickUpTrigger: number;
  74887. /**
  74888. * On pick out.
  74889. * This trigger will only be raised if you also declared a OnPickDown
  74890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74891. */
  74892. static readonly OnPickOutTrigger: number;
  74893. /**
  74894. * On long press
  74895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74896. */
  74897. static readonly OnLongPressTrigger: number;
  74898. /**
  74899. * On pointer over
  74900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74901. */
  74902. static readonly OnPointerOverTrigger: number;
  74903. /**
  74904. * On pointer out
  74905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74906. */
  74907. static readonly OnPointerOutTrigger: number;
  74908. /**
  74909. * On every frame
  74910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74911. */
  74912. static readonly OnEveryFrameTrigger: number;
  74913. /**
  74914. * On intersection enter
  74915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74916. */
  74917. static readonly OnIntersectionEnterTrigger: number;
  74918. /**
  74919. * On intersection exit
  74920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74921. */
  74922. static readonly OnIntersectionExitTrigger: number;
  74923. /**
  74924. * On key down
  74925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74926. */
  74927. static readonly OnKeyDownTrigger: number;
  74928. /**
  74929. * On key up
  74930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74931. */
  74932. static readonly OnKeyUpTrigger: number;
  74933. private _scene;
  74934. /**
  74935. * Creates a new action manager
  74936. * @param scene defines the hosting scene
  74937. */
  74938. constructor(scene: Scene);
  74939. /**
  74940. * Releases all associated resources
  74941. */
  74942. dispose(): void;
  74943. /**
  74944. * Gets hosting scene
  74945. * @returns the hosting scene
  74946. */
  74947. getScene(): Scene;
  74948. /**
  74949. * Does this action manager handles actions of any of the given triggers
  74950. * @param triggers defines the triggers to be tested
  74951. * @return a boolean indicating whether one (or more) of the triggers is handled
  74952. */
  74953. hasSpecificTriggers(triggers: number[]): boolean;
  74954. /**
  74955. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74956. * speed.
  74957. * @param triggerA defines the trigger to be tested
  74958. * @param triggerB defines the trigger to be tested
  74959. * @return a boolean indicating whether one (or more) of the triggers is handled
  74960. */
  74961. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74962. /**
  74963. * Does this action manager handles actions of a given trigger
  74964. * @param trigger defines the trigger to be tested
  74965. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74966. * @return whether the trigger is handled
  74967. */
  74968. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74969. /**
  74970. * Does this action manager has pointer triggers
  74971. */
  74972. readonly hasPointerTriggers: boolean;
  74973. /**
  74974. * Does this action manager has pick triggers
  74975. */
  74976. readonly hasPickTriggers: boolean;
  74977. /**
  74978. * Registers an action to this action manager
  74979. * @param action defines the action to be registered
  74980. * @return the action amended (prepared) after registration
  74981. */
  74982. registerAction(action: IAction): Nullable<IAction>;
  74983. /**
  74984. * Unregisters an action to this action manager
  74985. * @param action defines the action to be unregistered
  74986. * @return a boolean indicating whether the action has been unregistered
  74987. */
  74988. unregisterAction(action: IAction): Boolean;
  74989. /**
  74990. * Process a specific trigger
  74991. * @param trigger defines the trigger to process
  74992. * @param evt defines the event details to be processed
  74993. */
  74994. processTrigger(trigger: number, evt?: IActionEvent): void;
  74995. /** @hidden */
  74996. _getEffectiveTarget(target: any, propertyPath: string): any;
  74997. /** @hidden */
  74998. _getProperty(propertyPath: string): string;
  74999. /**
  75000. * Serialize this manager to a JSON object
  75001. * @param name defines the property name to store this manager
  75002. * @returns a JSON representation of this manager
  75003. */
  75004. serialize(name: string): any;
  75005. /**
  75006. * Creates a new ActionManager from a JSON data
  75007. * @param parsedActions defines the JSON data to read from
  75008. * @param object defines the hosting mesh
  75009. * @param scene defines the hosting scene
  75010. */
  75011. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75012. /**
  75013. * Get a trigger name by index
  75014. * @param trigger defines the trigger index
  75015. * @returns a trigger name
  75016. */
  75017. static GetTriggerName(trigger: number): string;
  75018. }
  75019. }
  75020. declare module BABYLON {
  75021. /**
  75022. * Class representing a ray with position and direction
  75023. */
  75024. export class Ray {
  75025. /** origin point */
  75026. origin: Vector3;
  75027. /** direction */
  75028. direction: Vector3;
  75029. /** length of the ray */
  75030. length: number;
  75031. private static readonly TmpVector3;
  75032. private _tmpRay;
  75033. /**
  75034. * Creates a new ray
  75035. * @param origin origin point
  75036. * @param direction direction
  75037. * @param length length of the ray
  75038. */
  75039. constructor(
  75040. /** origin point */
  75041. origin: Vector3,
  75042. /** direction */
  75043. direction: Vector3,
  75044. /** length of the ray */
  75045. length?: number);
  75046. /**
  75047. * Checks if the ray intersects a box
  75048. * @param minimum bound of the box
  75049. * @param maximum bound of the box
  75050. * @param intersectionTreshold extra extend to be added to the box in all direction
  75051. * @returns if the box was hit
  75052. */
  75053. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75054. /**
  75055. * Checks if the ray intersects a box
  75056. * @param box the bounding box to check
  75057. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75058. * @returns if the box was hit
  75059. */
  75060. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75061. /**
  75062. * If the ray hits a sphere
  75063. * @param sphere the bounding sphere to check
  75064. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75065. * @returns true if it hits the sphere
  75066. */
  75067. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75068. /**
  75069. * If the ray hits a triange
  75070. * @param vertex0 triangle vertex
  75071. * @param vertex1 triangle vertex
  75072. * @param vertex2 triangle vertex
  75073. * @returns intersection information if hit
  75074. */
  75075. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75076. /**
  75077. * Checks if ray intersects a plane
  75078. * @param plane the plane to check
  75079. * @returns the distance away it was hit
  75080. */
  75081. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75082. /**
  75083. * Calculate the intercept of a ray on a given axis
  75084. * @param axis to check 'x' | 'y' | 'z'
  75085. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75086. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75087. */
  75088. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75089. /**
  75090. * Checks if ray intersects a mesh
  75091. * @param mesh the mesh to check
  75092. * @param fastCheck if only the bounding box should checked
  75093. * @returns picking info of the intersecton
  75094. */
  75095. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75096. /**
  75097. * Checks if ray intersects a mesh
  75098. * @param meshes the meshes to check
  75099. * @param fastCheck if only the bounding box should checked
  75100. * @param results array to store result in
  75101. * @returns Array of picking infos
  75102. */
  75103. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75104. private _comparePickingInfo;
  75105. private static smallnum;
  75106. private static rayl;
  75107. /**
  75108. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75109. * @param sega the first point of the segment to test the intersection against
  75110. * @param segb the second point of the segment to test the intersection against
  75111. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75112. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75113. */
  75114. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75115. /**
  75116. * Update the ray from viewport position
  75117. * @param x position
  75118. * @param y y position
  75119. * @param viewportWidth viewport width
  75120. * @param viewportHeight viewport height
  75121. * @param world world matrix
  75122. * @param view view matrix
  75123. * @param projection projection matrix
  75124. * @returns this ray updated
  75125. */
  75126. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75127. /**
  75128. * Creates a ray with origin and direction of 0,0,0
  75129. * @returns the new ray
  75130. */
  75131. static Zero(): Ray;
  75132. /**
  75133. * Creates a new ray from screen space and viewport
  75134. * @param x position
  75135. * @param y y position
  75136. * @param viewportWidth viewport width
  75137. * @param viewportHeight viewport height
  75138. * @param world world matrix
  75139. * @param view view matrix
  75140. * @param projection projection matrix
  75141. * @returns new ray
  75142. */
  75143. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75144. /**
  75145. * 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
  75146. * transformed to the given world matrix.
  75147. * @param origin The origin point
  75148. * @param end The end point
  75149. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75150. * @returns the new ray
  75151. */
  75152. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75153. /**
  75154. * Transforms a ray by a matrix
  75155. * @param ray ray to transform
  75156. * @param matrix matrix to apply
  75157. * @returns the resulting new ray
  75158. */
  75159. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75160. /**
  75161. * Transforms a ray by a matrix
  75162. * @param ray ray to transform
  75163. * @param matrix matrix to apply
  75164. * @param result ray to store result in
  75165. */
  75166. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75167. /**
  75168. * Unproject a ray from screen space to object space
  75169. * @param sourceX defines the screen space x coordinate to use
  75170. * @param sourceY defines the screen space y coordinate to use
  75171. * @param viewportWidth defines the current width of the viewport
  75172. * @param viewportHeight defines the current height of the viewport
  75173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75174. * @param view defines the view matrix to use
  75175. * @param projection defines the projection matrix to use
  75176. */
  75177. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75178. }
  75179. /**
  75180. * Type used to define predicate used to select faces when a mesh intersection is detected
  75181. */
  75182. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75183. interface Scene {
  75184. /** @hidden */
  75185. _tempPickingRay: Nullable<Ray>;
  75186. /** @hidden */
  75187. _cachedRayForTransform: Ray;
  75188. /** @hidden */
  75189. _pickWithRayInverseMatrix: Matrix;
  75190. /** @hidden */
  75191. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75192. /** @hidden */
  75193. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75194. }
  75195. }
  75196. declare module BABYLON {
  75197. /**
  75198. * Groups all the scene component constants in one place to ease maintenance.
  75199. * @hidden
  75200. */
  75201. export class SceneComponentConstants {
  75202. static readonly NAME_EFFECTLAYER: string;
  75203. static readonly NAME_LAYER: string;
  75204. static readonly NAME_LENSFLARESYSTEM: string;
  75205. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75206. static readonly NAME_PARTICLESYSTEM: string;
  75207. static readonly NAME_GAMEPAD: string;
  75208. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75209. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75210. static readonly NAME_DEPTHRENDERER: string;
  75211. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75212. static readonly NAME_SPRITE: string;
  75213. static readonly NAME_OUTLINERENDERER: string;
  75214. static readonly NAME_PROCEDURALTEXTURE: string;
  75215. static readonly NAME_SHADOWGENERATOR: string;
  75216. static readonly NAME_OCTREE: string;
  75217. static readonly NAME_PHYSICSENGINE: string;
  75218. static readonly NAME_AUDIO: string;
  75219. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75220. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75221. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75222. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75223. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75224. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75225. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75226. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75227. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75228. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75229. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75230. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75231. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75232. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75233. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75234. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75235. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75236. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75237. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75238. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75239. static readonly STEP_AFTERRENDER_AUDIO: number;
  75240. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75241. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75242. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75243. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75244. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75245. static readonly STEP_POINTERMOVE_SPRITE: number;
  75246. static readonly STEP_POINTERDOWN_SPRITE: number;
  75247. static readonly STEP_POINTERUP_SPRITE: number;
  75248. }
  75249. /**
  75250. * This represents a scene component.
  75251. *
  75252. * This is used to decouple the dependency the scene is having on the different workloads like
  75253. * layers, post processes...
  75254. */
  75255. export interface ISceneComponent {
  75256. /**
  75257. * The name of the component. Each component must have a unique name.
  75258. */
  75259. name: string;
  75260. /**
  75261. * The scene the component belongs to.
  75262. */
  75263. scene: Scene;
  75264. /**
  75265. * Register the component to one instance of a scene.
  75266. */
  75267. register(): void;
  75268. /**
  75269. * Rebuilds the elements related to this component in case of
  75270. * context lost for instance.
  75271. */
  75272. rebuild(): void;
  75273. /**
  75274. * Disposes the component and the associated ressources.
  75275. */
  75276. dispose(): void;
  75277. }
  75278. /**
  75279. * This represents a SERIALIZABLE scene component.
  75280. *
  75281. * This extends Scene Component to add Serialization methods on top.
  75282. */
  75283. export interface ISceneSerializableComponent extends ISceneComponent {
  75284. /**
  75285. * Adds all the elements from the container to the scene
  75286. * @param container the container holding the elements
  75287. */
  75288. addFromContainer(container: AbstractScene): void;
  75289. /**
  75290. * Removes all the elements in the container from the scene
  75291. * @param container contains the elements to remove
  75292. * @param dispose if the removed element should be disposed (default: false)
  75293. */
  75294. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75295. /**
  75296. * Serializes the component data to the specified json object
  75297. * @param serializationObject The object to serialize to
  75298. */
  75299. serialize(serializationObject: any): void;
  75300. }
  75301. /**
  75302. * Strong typing of a Mesh related stage step action
  75303. */
  75304. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75305. /**
  75306. * Strong typing of a Evaluate Sub Mesh related stage step action
  75307. */
  75308. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75309. /**
  75310. * Strong typing of a Active Mesh related stage step action
  75311. */
  75312. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75313. /**
  75314. * Strong typing of a Camera related stage step action
  75315. */
  75316. export type CameraStageAction = (camera: Camera) => void;
  75317. /**
  75318. * Strong typing of a Camera Frame buffer related stage step action
  75319. */
  75320. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75321. /**
  75322. * Strong typing of a Render Target related stage step action
  75323. */
  75324. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75325. /**
  75326. * Strong typing of a RenderingGroup related stage step action
  75327. */
  75328. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75329. /**
  75330. * Strong typing of a Mesh Render related stage step action
  75331. */
  75332. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75333. /**
  75334. * Strong typing of a simple stage step action
  75335. */
  75336. export type SimpleStageAction = () => void;
  75337. /**
  75338. * Strong typing of a render target action.
  75339. */
  75340. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75341. /**
  75342. * Strong typing of a pointer move action.
  75343. */
  75344. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75345. /**
  75346. * Strong typing of a pointer up/down action.
  75347. */
  75348. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75349. /**
  75350. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75351. * @hidden
  75352. */
  75353. export class Stage<T extends Function> extends Array<{
  75354. index: number;
  75355. component: ISceneComponent;
  75356. action: T;
  75357. }> {
  75358. /**
  75359. * Hide ctor from the rest of the world.
  75360. * @param items The items to add.
  75361. */
  75362. private constructor();
  75363. /**
  75364. * Creates a new Stage.
  75365. * @returns A new instance of a Stage
  75366. */
  75367. static Create<T extends Function>(): Stage<T>;
  75368. /**
  75369. * Registers a step in an ordered way in the targeted stage.
  75370. * @param index Defines the position to register the step in
  75371. * @param component Defines the component attached to the step
  75372. * @param action Defines the action to launch during the step
  75373. */
  75374. registerStep(index: number, component: ISceneComponent, action: T): void;
  75375. /**
  75376. * Clears all the steps from the stage.
  75377. */
  75378. clear(): void;
  75379. }
  75380. }
  75381. declare module BABYLON {
  75382. interface Scene {
  75383. /** @hidden */
  75384. _pointerOverSprite: Nullable<Sprite>;
  75385. /** @hidden */
  75386. _pickedDownSprite: Nullable<Sprite>;
  75387. /** @hidden */
  75388. _tempSpritePickingRay: Nullable<Ray>;
  75389. /**
  75390. * All of the sprite managers added to this scene
  75391. * @see http://doc.babylonjs.com/babylon101/sprites
  75392. */
  75393. spriteManagers: Array<ISpriteManager>;
  75394. /**
  75395. * An event triggered when sprites rendering is about to start
  75396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75397. */
  75398. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75399. /**
  75400. * An event triggered when sprites rendering is done
  75401. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75402. */
  75403. onAfterSpritesRenderingObservable: Observable<Scene>;
  75404. /** @hidden */
  75405. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75406. /** Launch a ray to try to pick a sprite in the scene
  75407. * @param x position on screen
  75408. * @param y position on screen
  75409. * @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
  75410. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75411. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75412. * @returns a PickingInfo
  75413. */
  75414. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75415. /** Use the given ray to pick a sprite in the scene
  75416. * @param ray The ray (in world space) to use to pick meshes
  75417. * @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
  75418. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75419. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75420. * @returns a PickingInfo
  75421. */
  75422. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75423. /**
  75424. * Force the sprite under the pointer
  75425. * @param sprite defines the sprite to use
  75426. */
  75427. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75428. /**
  75429. * Gets the sprite under the pointer
  75430. * @returns a Sprite or null if no sprite is under the pointer
  75431. */
  75432. getPointerOverSprite(): Nullable<Sprite>;
  75433. }
  75434. /**
  75435. * Defines the sprite scene component responsible to manage sprites
  75436. * in a given scene.
  75437. */
  75438. export class SpriteSceneComponent implements ISceneComponent {
  75439. /**
  75440. * The component name helpfull to identify the component in the list of scene components.
  75441. */
  75442. readonly name: string;
  75443. /**
  75444. * The scene the component belongs to.
  75445. */
  75446. scene: Scene;
  75447. /** @hidden */
  75448. private _spritePredicate;
  75449. /**
  75450. * Creates a new instance of the component for the given scene
  75451. * @param scene Defines the scene to register the component in
  75452. */
  75453. constructor(scene: Scene);
  75454. /**
  75455. * Registers the component in a given scene
  75456. */
  75457. register(): void;
  75458. /**
  75459. * Rebuilds the elements related to this component in case of
  75460. * context lost for instance.
  75461. */
  75462. rebuild(): void;
  75463. /**
  75464. * Disposes the component and the associated ressources.
  75465. */
  75466. dispose(): void;
  75467. private _pickSpriteButKeepRay;
  75468. private _pointerMove;
  75469. private _pointerDown;
  75470. private _pointerUp;
  75471. }
  75472. }
  75473. declare module BABYLON {
  75474. /** @hidden */
  75475. export var fogFragmentDeclaration: {
  75476. name: string;
  75477. shader: string;
  75478. };
  75479. }
  75480. declare module BABYLON {
  75481. /** @hidden */
  75482. export var fogFragment: {
  75483. name: string;
  75484. shader: string;
  75485. };
  75486. }
  75487. declare module BABYLON {
  75488. /** @hidden */
  75489. export var spritesPixelShader: {
  75490. name: string;
  75491. shader: string;
  75492. };
  75493. }
  75494. declare module BABYLON {
  75495. /** @hidden */
  75496. export var fogVertexDeclaration: {
  75497. name: string;
  75498. shader: string;
  75499. };
  75500. }
  75501. declare module BABYLON {
  75502. /** @hidden */
  75503. export var spritesVertexShader: {
  75504. name: string;
  75505. shader: string;
  75506. };
  75507. }
  75508. declare module BABYLON {
  75509. /**
  75510. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75511. */
  75512. export interface ISpriteManager extends IDisposable {
  75513. /**
  75514. * Restricts the camera to viewing objects with the same layerMask.
  75515. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75516. */
  75517. layerMask: number;
  75518. /**
  75519. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75520. */
  75521. isPickable: boolean;
  75522. /**
  75523. * Specifies the rendering group id for this mesh (0 by default)
  75524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75525. */
  75526. renderingGroupId: number;
  75527. /**
  75528. * Defines the list of sprites managed by the manager.
  75529. */
  75530. sprites: Array<Sprite>;
  75531. /**
  75532. * Tests the intersection of a sprite with a specific ray.
  75533. * @param ray The ray we are sending to test the collision
  75534. * @param camera The camera space we are sending rays in
  75535. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75536. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75537. * @returns picking info or null.
  75538. */
  75539. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75540. /**
  75541. * Renders the list of sprites on screen.
  75542. */
  75543. render(): void;
  75544. }
  75545. /**
  75546. * Class used to manage multiple sprites on the same spritesheet
  75547. * @see http://doc.babylonjs.com/babylon101/sprites
  75548. */
  75549. export class SpriteManager implements ISpriteManager {
  75550. /** defines the manager's name */
  75551. name: string;
  75552. /** Gets the list of sprites */
  75553. sprites: Sprite[];
  75554. /** Gets or sets the rendering group id (0 by default) */
  75555. renderingGroupId: number;
  75556. /** Gets or sets camera layer mask */
  75557. layerMask: number;
  75558. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75559. fogEnabled: boolean;
  75560. /** Gets or sets a boolean indicating if the sprites are pickable */
  75561. isPickable: boolean;
  75562. /** Defines the default width of a cell in the spritesheet */
  75563. cellWidth: number;
  75564. /** Defines the default height of a cell in the spritesheet */
  75565. cellHeight: number;
  75566. /**
  75567. * An event triggered when the manager is disposed.
  75568. */
  75569. onDisposeObservable: Observable<SpriteManager>;
  75570. private _onDisposeObserver;
  75571. /**
  75572. * Callback called when the manager is disposed
  75573. */
  75574. onDispose: () => void;
  75575. private _capacity;
  75576. private _spriteTexture;
  75577. private _epsilon;
  75578. private _scene;
  75579. private _vertexData;
  75580. private _buffer;
  75581. private _vertexBuffers;
  75582. private _indexBuffer;
  75583. private _effectBase;
  75584. private _effectFog;
  75585. /**
  75586. * Gets or sets the spritesheet texture
  75587. */
  75588. texture: Texture;
  75589. /**
  75590. * Creates a new sprite manager
  75591. * @param name defines the manager's name
  75592. * @param imgUrl defines the sprite sheet url
  75593. * @param capacity defines the maximum allowed number of sprites
  75594. * @param cellSize defines the size of a sprite cell
  75595. * @param scene defines the hosting scene
  75596. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75597. * @param samplingMode defines the smapling mode to use with spritesheet
  75598. */
  75599. constructor(
  75600. /** defines the manager's name */
  75601. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75602. private _appendSpriteVertex;
  75603. /**
  75604. * Intersects the sprites with a ray
  75605. * @param ray defines the ray to intersect with
  75606. * @param camera defines the current active camera
  75607. * @param predicate defines a predicate used to select candidate sprites
  75608. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75609. * @returns null if no hit or a PickingInfo
  75610. */
  75611. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75612. /**
  75613. * Render all child sprites
  75614. */
  75615. render(): void;
  75616. /**
  75617. * Release associated resources
  75618. */
  75619. dispose(): void;
  75620. }
  75621. }
  75622. declare module BABYLON {
  75623. /**
  75624. * Class used to represent a sprite
  75625. * @see http://doc.babylonjs.com/babylon101/sprites
  75626. */
  75627. export class Sprite {
  75628. /** defines the name */
  75629. name: string;
  75630. /** Gets or sets the current world position */
  75631. position: Vector3;
  75632. /** Gets or sets the main color */
  75633. color: Color4;
  75634. /** Gets or sets the width */
  75635. width: number;
  75636. /** Gets or sets the height */
  75637. height: number;
  75638. /** Gets or sets rotation angle */
  75639. angle: number;
  75640. /** Gets or sets the cell index in the sprite sheet */
  75641. cellIndex: number;
  75642. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75643. invertU: number;
  75644. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75645. invertV: number;
  75646. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75647. disposeWhenFinishedAnimating: boolean;
  75648. /** Gets the list of attached animations */
  75649. animations: Animation[];
  75650. /** Gets or sets a boolean indicating if the sprite can be picked */
  75651. isPickable: boolean;
  75652. /**
  75653. * Gets or sets the associated action manager
  75654. */
  75655. actionManager: Nullable<ActionManager>;
  75656. private _animationStarted;
  75657. private _loopAnimation;
  75658. private _fromIndex;
  75659. private _toIndex;
  75660. private _delay;
  75661. private _direction;
  75662. private _manager;
  75663. private _time;
  75664. private _onAnimationEnd;
  75665. /**
  75666. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75667. */
  75668. isVisible: boolean;
  75669. /**
  75670. * Gets or sets the sprite size
  75671. */
  75672. size: number;
  75673. /**
  75674. * Creates a new Sprite
  75675. * @param name defines the name
  75676. * @param manager defines the manager
  75677. */
  75678. constructor(
  75679. /** defines the name */
  75680. name: string, manager: ISpriteManager);
  75681. /**
  75682. * Starts an animation
  75683. * @param from defines the initial key
  75684. * @param to defines the end key
  75685. * @param loop defines if the animation must loop
  75686. * @param delay defines the start delay (in ms)
  75687. * @param onAnimationEnd defines a callback to call when animation ends
  75688. */
  75689. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75690. /** Stops current animation (if any) */
  75691. stopAnimation(): void;
  75692. /** @hidden */
  75693. _animate(deltaTime: number): void;
  75694. /** Release associated resources */
  75695. dispose(): void;
  75696. }
  75697. }
  75698. declare module BABYLON {
  75699. /**
  75700. * Information about the result of picking within a scene
  75701. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75702. */
  75703. export class PickingInfo {
  75704. /** @hidden */
  75705. _pickingUnavailable: boolean;
  75706. /**
  75707. * If the pick collided with an object
  75708. */
  75709. hit: boolean;
  75710. /**
  75711. * Distance away where the pick collided
  75712. */
  75713. distance: number;
  75714. /**
  75715. * The location of pick collision
  75716. */
  75717. pickedPoint: Nullable<Vector3>;
  75718. /**
  75719. * The mesh corresponding the the pick collision
  75720. */
  75721. pickedMesh: Nullable<AbstractMesh>;
  75722. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75723. bu: number;
  75724. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75725. bv: number;
  75726. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75727. faceId: number;
  75728. /** Id of the the submesh that was picked */
  75729. subMeshId: number;
  75730. /** If a sprite was picked, this will be the sprite the pick collided with */
  75731. pickedSprite: Nullable<Sprite>;
  75732. /**
  75733. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75734. */
  75735. originMesh: Nullable<AbstractMesh>;
  75736. /**
  75737. * The ray that was used to perform the picking.
  75738. */
  75739. ray: Nullable<Ray>;
  75740. /**
  75741. * Gets the normal correspodning to the face the pick collided with
  75742. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75743. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75744. * @returns The normal correspodning to the face the pick collided with
  75745. */
  75746. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75747. /**
  75748. * Gets the texture coordinates of where the pick occured
  75749. * @returns the vector containing the coordnates of the texture
  75750. */
  75751. getTextureCoordinates(): Nullable<Vector2>;
  75752. }
  75753. }
  75754. declare module BABYLON {
  75755. /**
  75756. * Gather the list of pointer event types as constants.
  75757. */
  75758. export class PointerEventTypes {
  75759. /**
  75760. * 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.
  75761. */
  75762. static readonly POINTERDOWN: number;
  75763. /**
  75764. * The pointerup event is fired when a pointer is no longer active.
  75765. */
  75766. static readonly POINTERUP: number;
  75767. /**
  75768. * The pointermove event is fired when a pointer changes coordinates.
  75769. */
  75770. static readonly POINTERMOVE: number;
  75771. /**
  75772. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75773. */
  75774. static readonly POINTERWHEEL: number;
  75775. /**
  75776. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75777. */
  75778. static readonly POINTERPICK: number;
  75779. /**
  75780. * The pointertap event is fired when a the object has been touched and released without drag.
  75781. */
  75782. static readonly POINTERTAP: number;
  75783. /**
  75784. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75785. */
  75786. static readonly POINTERDOUBLETAP: number;
  75787. }
  75788. /**
  75789. * Base class of pointer info types.
  75790. */
  75791. export class PointerInfoBase {
  75792. /**
  75793. * Defines the type of event (PointerEventTypes)
  75794. */
  75795. type: number;
  75796. /**
  75797. * Defines the related dom event
  75798. */
  75799. event: PointerEvent | MouseWheelEvent;
  75800. /**
  75801. * Instantiates the base class of pointers info.
  75802. * @param type Defines the type of event (PointerEventTypes)
  75803. * @param event Defines the related dom event
  75804. */
  75805. constructor(
  75806. /**
  75807. * Defines the type of event (PointerEventTypes)
  75808. */
  75809. type: number,
  75810. /**
  75811. * Defines the related dom event
  75812. */
  75813. event: PointerEvent | MouseWheelEvent);
  75814. }
  75815. /**
  75816. * This class is used to store pointer related info for the onPrePointerObservable event.
  75817. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75818. */
  75819. export class PointerInfoPre extends PointerInfoBase {
  75820. /**
  75821. * Ray from a pointer if availible (eg. 6dof controller)
  75822. */
  75823. ray: Nullable<Ray>;
  75824. /**
  75825. * Defines the local position of the pointer on the canvas.
  75826. */
  75827. localPosition: Vector2;
  75828. /**
  75829. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75830. */
  75831. skipOnPointerObservable: boolean;
  75832. /**
  75833. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75834. * @param type Defines the type of event (PointerEventTypes)
  75835. * @param event Defines the related dom event
  75836. * @param localX Defines the local x coordinates of the pointer when the event occured
  75837. * @param localY Defines the local y coordinates of the pointer when the event occured
  75838. */
  75839. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75840. }
  75841. /**
  75842. * This type contains all the data related to a pointer event in Babylon.js.
  75843. * 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.
  75844. */
  75845. export class PointerInfo extends PointerInfoBase {
  75846. /**
  75847. * Defines the picking info associated to the info (if any)\
  75848. */
  75849. pickInfo: Nullable<PickingInfo>;
  75850. /**
  75851. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75852. * @param type Defines the type of event (PointerEventTypes)
  75853. * @param event Defines the related dom event
  75854. * @param pickInfo Defines the picking info associated to the info (if any)\
  75855. */
  75856. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75857. /**
  75858. * Defines the picking info associated to the info (if any)\
  75859. */
  75860. pickInfo: Nullable<PickingInfo>);
  75861. }
  75862. /**
  75863. * Data relating to a touch event on the screen.
  75864. */
  75865. export interface PointerTouch {
  75866. /**
  75867. * X coordinate of touch.
  75868. */
  75869. x: number;
  75870. /**
  75871. * Y coordinate of touch.
  75872. */
  75873. y: number;
  75874. /**
  75875. * Id of touch. Unique for each finger.
  75876. */
  75877. pointerId: number;
  75878. /**
  75879. * Event type passed from DOM.
  75880. */
  75881. type: any;
  75882. }
  75883. }
  75884. declare module BABYLON {
  75885. /**
  75886. * Manage the mouse inputs to control the movement of a free camera.
  75887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75888. */
  75889. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75890. /**
  75891. * Define if touch is enabled in the mouse input
  75892. */
  75893. touchEnabled: boolean;
  75894. /**
  75895. * Defines the camera the input is attached to.
  75896. */
  75897. camera: FreeCamera;
  75898. /**
  75899. * Defines the buttons associated with the input to handle camera move.
  75900. */
  75901. buttons: number[];
  75902. /**
  75903. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75904. */
  75905. angularSensibility: number;
  75906. private _pointerInput;
  75907. private _onMouseMove;
  75908. private _observer;
  75909. private previousPosition;
  75910. /**
  75911. * Observable for when a pointer move event occurs containing the move offset
  75912. */
  75913. onPointerMovedObservable: Observable<{
  75914. offsetX: number;
  75915. offsetY: number;
  75916. }>;
  75917. /**
  75918. * @hidden
  75919. * If the camera should be rotated automatically based on pointer movement
  75920. */
  75921. _allowCameraRotation: boolean;
  75922. /**
  75923. * Manage the mouse inputs to control the movement of a free camera.
  75924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75925. * @param touchEnabled Defines if touch is enabled or not
  75926. */
  75927. constructor(
  75928. /**
  75929. * Define if touch is enabled in the mouse input
  75930. */
  75931. touchEnabled?: boolean);
  75932. /**
  75933. * Attach the input controls to a specific dom element to get the input from.
  75934. * @param element Defines the element the controls should be listened from
  75935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75936. */
  75937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75938. /**
  75939. * Called on JS contextmenu event.
  75940. * Override this method to provide functionality.
  75941. */
  75942. protected onContextMenu(evt: PointerEvent): void;
  75943. /**
  75944. * Detach the current controls from the specified dom element.
  75945. * @param element Defines the element to stop listening the inputs from
  75946. */
  75947. detachControl(element: Nullable<HTMLElement>): void;
  75948. /**
  75949. * Gets the class name of the current intput.
  75950. * @returns the class name
  75951. */
  75952. getClassName(): string;
  75953. /**
  75954. * Get the friendly name associated with the input class.
  75955. * @returns the input friendly name
  75956. */
  75957. getSimpleName(): string;
  75958. }
  75959. }
  75960. declare module BABYLON {
  75961. /**
  75962. * Manage the touch inputs to control the movement of a free camera.
  75963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75964. */
  75965. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75966. /**
  75967. * Defines the camera the input is attached to.
  75968. */
  75969. camera: FreeCamera;
  75970. /**
  75971. * Defines the touch sensibility for rotation.
  75972. * The higher the faster.
  75973. */
  75974. touchAngularSensibility: number;
  75975. /**
  75976. * Defines the touch sensibility for move.
  75977. * The higher the faster.
  75978. */
  75979. touchMoveSensibility: number;
  75980. private _offsetX;
  75981. private _offsetY;
  75982. private _pointerPressed;
  75983. private _pointerInput;
  75984. private _observer;
  75985. private _onLostFocus;
  75986. /**
  75987. * Attach the input controls to a specific dom element to get the input from.
  75988. * @param element Defines the element the controls should be listened from
  75989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75990. */
  75991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75992. /**
  75993. * Detach the current controls from the specified dom element.
  75994. * @param element Defines the element to stop listening the inputs from
  75995. */
  75996. detachControl(element: Nullable<HTMLElement>): void;
  75997. /**
  75998. * Update the current camera state depending on the inputs that have been used this frame.
  75999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76000. */
  76001. checkInputs(): void;
  76002. /**
  76003. * Gets the class name of the current intput.
  76004. * @returns the class name
  76005. */
  76006. getClassName(): string;
  76007. /**
  76008. * Get the friendly name associated with the input class.
  76009. * @returns the input friendly name
  76010. */
  76011. getSimpleName(): string;
  76012. }
  76013. }
  76014. declare module BABYLON {
  76015. /**
  76016. * Default Inputs manager for the FreeCamera.
  76017. * It groups all the default supported inputs for ease of use.
  76018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76019. */
  76020. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76021. /**
  76022. * @hidden
  76023. */
  76024. _mouseInput: Nullable<FreeCameraMouseInput>;
  76025. /**
  76026. * Instantiates a new FreeCameraInputsManager.
  76027. * @param camera Defines the camera the inputs belong to
  76028. */
  76029. constructor(camera: FreeCamera);
  76030. /**
  76031. * Add keyboard input support to the input manager.
  76032. * @returns the current input manager
  76033. */
  76034. addKeyboard(): FreeCameraInputsManager;
  76035. /**
  76036. * Add mouse input support to the input manager.
  76037. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76038. * @returns the current input manager
  76039. */
  76040. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76041. /**
  76042. * Removes the mouse input support from the manager
  76043. * @returns the current input manager
  76044. */
  76045. removeMouse(): FreeCameraInputsManager;
  76046. /**
  76047. * Add touch input support to the input manager.
  76048. * @returns the current input manager
  76049. */
  76050. addTouch(): FreeCameraInputsManager;
  76051. /**
  76052. * Remove all attached input methods from a camera
  76053. */
  76054. clear(): void;
  76055. }
  76056. }
  76057. declare module BABYLON {
  76058. /**
  76059. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76060. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76061. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76062. */
  76063. export class FreeCamera extends TargetCamera {
  76064. /**
  76065. * Define the collision ellipsoid of the camera.
  76066. * This is helpful to simulate a camera body like the player body around the camera
  76067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76068. */
  76069. ellipsoid: Vector3;
  76070. /**
  76071. * Define an offset for the position of the ellipsoid around the camera.
  76072. * This can be helpful to determine the center of the body near the gravity center of the body
  76073. * instead of its head.
  76074. */
  76075. ellipsoidOffset: Vector3;
  76076. /**
  76077. * Enable or disable collisions of the camera with the rest of the scene objects.
  76078. */
  76079. checkCollisions: boolean;
  76080. /**
  76081. * Enable or disable gravity on the camera.
  76082. */
  76083. applyGravity: boolean;
  76084. /**
  76085. * Define the input manager associated to the camera.
  76086. */
  76087. inputs: FreeCameraInputsManager;
  76088. /**
  76089. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76090. * Higher values reduce sensitivity.
  76091. */
  76092. /**
  76093. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76094. * Higher values reduce sensitivity.
  76095. */
  76096. angularSensibility: number;
  76097. /**
  76098. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76099. */
  76100. keysUp: number[];
  76101. /**
  76102. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76103. */
  76104. keysDown: number[];
  76105. /**
  76106. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76107. */
  76108. keysLeft: number[];
  76109. /**
  76110. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76111. */
  76112. keysRight: number[];
  76113. /**
  76114. * Event raised when the camera collide with a mesh in the scene.
  76115. */
  76116. onCollide: (collidedMesh: AbstractMesh) => void;
  76117. private _collider;
  76118. private _needMoveForGravity;
  76119. private _oldPosition;
  76120. private _diffPosition;
  76121. private _newPosition;
  76122. /** @hidden */
  76123. _localDirection: Vector3;
  76124. /** @hidden */
  76125. _transformedDirection: Vector3;
  76126. /**
  76127. * Instantiates a Free Camera.
  76128. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76129. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76130. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76131. * @param name Define the name of the camera in the scene
  76132. * @param position Define the start position of the camera in the scene
  76133. * @param scene Define the scene the camera belongs to
  76134. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76135. */
  76136. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76137. /**
  76138. * Attached controls to the current camera.
  76139. * @param element Defines the element the controls should be listened from
  76140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76141. */
  76142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76143. /**
  76144. * Detach the current controls from the camera.
  76145. * The camera will stop reacting to inputs.
  76146. * @param element Defines the element to stop listening the inputs from
  76147. */
  76148. detachControl(element: HTMLElement): void;
  76149. private _collisionMask;
  76150. /**
  76151. * Define a collision mask to limit the list of object the camera can collide with
  76152. */
  76153. collisionMask: number;
  76154. /** @hidden */
  76155. _collideWithWorld(displacement: Vector3): void;
  76156. private _onCollisionPositionChange;
  76157. /** @hidden */
  76158. _checkInputs(): void;
  76159. /** @hidden */
  76160. _decideIfNeedsToMove(): boolean;
  76161. /** @hidden */
  76162. _updatePosition(): void;
  76163. /**
  76164. * Destroy the camera and release the current resources hold by it.
  76165. */
  76166. dispose(): void;
  76167. /**
  76168. * Gets the current object class name.
  76169. * @return the class name
  76170. */
  76171. getClassName(): string;
  76172. }
  76173. }
  76174. declare module BABYLON {
  76175. /**
  76176. * Represents a gamepad control stick position
  76177. */
  76178. export class StickValues {
  76179. /**
  76180. * The x component of the control stick
  76181. */
  76182. x: number;
  76183. /**
  76184. * The y component of the control stick
  76185. */
  76186. y: number;
  76187. /**
  76188. * Initializes the gamepad x and y control stick values
  76189. * @param x The x component of the gamepad control stick value
  76190. * @param y The y component of the gamepad control stick value
  76191. */
  76192. constructor(
  76193. /**
  76194. * The x component of the control stick
  76195. */
  76196. x: number,
  76197. /**
  76198. * The y component of the control stick
  76199. */
  76200. y: number);
  76201. }
  76202. /**
  76203. * An interface which manages callbacks for gamepad button changes
  76204. */
  76205. export interface GamepadButtonChanges {
  76206. /**
  76207. * Called when a gamepad has been changed
  76208. */
  76209. changed: boolean;
  76210. /**
  76211. * Called when a gamepad press event has been triggered
  76212. */
  76213. pressChanged: boolean;
  76214. /**
  76215. * Called when a touch event has been triggered
  76216. */
  76217. touchChanged: boolean;
  76218. /**
  76219. * Called when a value has changed
  76220. */
  76221. valueChanged: boolean;
  76222. }
  76223. /**
  76224. * Represents a gamepad
  76225. */
  76226. export class Gamepad {
  76227. /**
  76228. * The id of the gamepad
  76229. */
  76230. id: string;
  76231. /**
  76232. * The index of the gamepad
  76233. */
  76234. index: number;
  76235. /**
  76236. * The browser gamepad
  76237. */
  76238. browserGamepad: any;
  76239. /**
  76240. * Specifies what type of gamepad this represents
  76241. */
  76242. type: number;
  76243. private _leftStick;
  76244. private _rightStick;
  76245. /** @hidden */
  76246. _isConnected: boolean;
  76247. private _leftStickAxisX;
  76248. private _leftStickAxisY;
  76249. private _rightStickAxisX;
  76250. private _rightStickAxisY;
  76251. /**
  76252. * Triggered when the left control stick has been changed
  76253. */
  76254. private _onleftstickchanged;
  76255. /**
  76256. * Triggered when the right control stick has been changed
  76257. */
  76258. private _onrightstickchanged;
  76259. /**
  76260. * Represents a gamepad controller
  76261. */
  76262. static GAMEPAD: number;
  76263. /**
  76264. * Represents a generic controller
  76265. */
  76266. static GENERIC: number;
  76267. /**
  76268. * Represents an XBox controller
  76269. */
  76270. static XBOX: number;
  76271. /**
  76272. * Represents a pose-enabled controller
  76273. */
  76274. static POSE_ENABLED: number;
  76275. /**
  76276. * Represents an Dual Shock controller
  76277. */
  76278. static DUALSHOCK: number;
  76279. /**
  76280. * Specifies whether the left control stick should be Y-inverted
  76281. */
  76282. protected _invertLeftStickY: boolean;
  76283. /**
  76284. * Specifies if the gamepad has been connected
  76285. */
  76286. readonly isConnected: boolean;
  76287. /**
  76288. * Initializes the gamepad
  76289. * @param id The id of the gamepad
  76290. * @param index The index of the gamepad
  76291. * @param browserGamepad The browser gamepad
  76292. * @param leftStickX The x component of the left joystick
  76293. * @param leftStickY The y component of the left joystick
  76294. * @param rightStickX The x component of the right joystick
  76295. * @param rightStickY The y component of the right joystick
  76296. */
  76297. constructor(
  76298. /**
  76299. * The id of the gamepad
  76300. */
  76301. id: string,
  76302. /**
  76303. * The index of the gamepad
  76304. */
  76305. index: number,
  76306. /**
  76307. * The browser gamepad
  76308. */
  76309. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76310. /**
  76311. * Callback triggered when the left joystick has changed
  76312. * @param callback
  76313. */
  76314. onleftstickchanged(callback: (values: StickValues) => void): void;
  76315. /**
  76316. * Callback triggered when the right joystick has changed
  76317. * @param callback
  76318. */
  76319. onrightstickchanged(callback: (values: StickValues) => void): void;
  76320. /**
  76321. * Gets the left joystick
  76322. */
  76323. /**
  76324. * Sets the left joystick values
  76325. */
  76326. leftStick: StickValues;
  76327. /**
  76328. * Gets the right joystick
  76329. */
  76330. /**
  76331. * Sets the right joystick value
  76332. */
  76333. rightStick: StickValues;
  76334. /**
  76335. * Updates the gamepad joystick positions
  76336. */
  76337. update(): void;
  76338. /**
  76339. * Disposes the gamepad
  76340. */
  76341. dispose(): void;
  76342. }
  76343. /**
  76344. * Represents a generic gamepad
  76345. */
  76346. export class GenericPad extends Gamepad {
  76347. private _buttons;
  76348. private _onbuttondown;
  76349. private _onbuttonup;
  76350. /**
  76351. * Observable triggered when a button has been pressed
  76352. */
  76353. onButtonDownObservable: Observable<number>;
  76354. /**
  76355. * Observable triggered when a button has been released
  76356. */
  76357. onButtonUpObservable: Observable<number>;
  76358. /**
  76359. * Callback triggered when a button has been pressed
  76360. * @param callback Called when a button has been pressed
  76361. */
  76362. onbuttondown(callback: (buttonPressed: number) => void): void;
  76363. /**
  76364. * Callback triggered when a button has been released
  76365. * @param callback Called when a button has been released
  76366. */
  76367. onbuttonup(callback: (buttonReleased: number) => void): void;
  76368. /**
  76369. * Initializes the generic gamepad
  76370. * @param id The id of the generic gamepad
  76371. * @param index The index of the generic gamepad
  76372. * @param browserGamepad The browser gamepad
  76373. */
  76374. constructor(id: string, index: number, browserGamepad: any);
  76375. private _setButtonValue;
  76376. /**
  76377. * Updates the generic gamepad
  76378. */
  76379. update(): void;
  76380. /**
  76381. * Disposes the generic gamepad
  76382. */
  76383. dispose(): void;
  76384. }
  76385. }
  76386. declare module BABYLON {
  76387. interface Engine {
  76388. /**
  76389. * Creates a raw texture
  76390. * @param data defines the data to store in the texture
  76391. * @param width defines the width of the texture
  76392. * @param height defines the height of the texture
  76393. * @param format defines the format of the data
  76394. * @param generateMipMaps defines if the engine should generate the mip levels
  76395. * @param invertY defines if data must be stored with Y axis inverted
  76396. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76397. * @param compression defines the compression used (null by default)
  76398. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76399. * @returns the raw texture inside an InternalTexture
  76400. */
  76401. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76402. /**
  76403. * Update a raw texture
  76404. * @param texture defines the texture to update
  76405. * @param data defines the data to store in the texture
  76406. * @param format defines the format of the data
  76407. * @param invertY defines if data must be stored with Y axis inverted
  76408. */
  76409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76410. /**
  76411. * Update a raw texture
  76412. * @param texture defines the texture to update
  76413. * @param data defines the data to store in the texture
  76414. * @param format defines the format of the data
  76415. * @param invertY defines if data must be stored with Y axis inverted
  76416. * @param compression defines the compression used (null by default)
  76417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76418. */
  76419. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76420. /**
  76421. * Creates a new raw cube texture
  76422. * @param data defines the array of data to use to create each face
  76423. * @param size defines the size of the textures
  76424. * @param format defines the format of the data
  76425. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76426. * @param generateMipMaps defines if the engine should generate the mip levels
  76427. * @param invertY defines if data must be stored with Y axis inverted
  76428. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76429. * @param compression defines the compression used (null by default)
  76430. * @returns the cube texture as an InternalTexture
  76431. */
  76432. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76433. /**
  76434. * Update a raw cube texture
  76435. * @param texture defines the texture to udpdate
  76436. * @param data defines the data to store
  76437. * @param format defines the data format
  76438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76439. * @param invertY defines if data must be stored with Y axis inverted
  76440. */
  76441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76442. /**
  76443. * Update a raw cube texture
  76444. * @param texture defines the texture to udpdate
  76445. * @param data defines the data to store
  76446. * @param format defines the data format
  76447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76448. * @param invertY defines if data must be stored with Y axis inverted
  76449. * @param compression defines the compression used (null by default)
  76450. */
  76451. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76452. /**
  76453. * Update a raw cube texture
  76454. * @param texture defines the texture to udpdate
  76455. * @param data defines the data to store
  76456. * @param format defines the data format
  76457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76458. * @param invertY defines if data must be stored with Y axis inverted
  76459. * @param compression defines the compression used (null by default)
  76460. * @param level defines which level of the texture to update
  76461. */
  76462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76463. /**
  76464. * Creates a new raw cube texture from a specified url
  76465. * @param url defines the url where the data is located
  76466. * @param scene defines the current scene
  76467. * @param size defines the size of the textures
  76468. * @param format defines the format of the data
  76469. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76470. * @param noMipmap defines if the engine should avoid generating the mip levels
  76471. * @param callback defines a callback used to extract texture data from loaded data
  76472. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76473. * @param onLoad defines a callback called when texture is loaded
  76474. * @param onError defines a callback called if there is an error
  76475. * @returns the cube texture as an InternalTexture
  76476. */
  76477. 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;
  76478. /**
  76479. * Creates a new raw cube texture from a specified url
  76480. * @param url defines the url where the data is located
  76481. * @param scene defines the current scene
  76482. * @param size defines the size of the textures
  76483. * @param format defines the format of the data
  76484. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76485. * @param noMipmap defines if the engine should avoid generating the mip levels
  76486. * @param callback defines a callback used to extract texture data from loaded data
  76487. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76488. * @param onLoad defines a callback called when texture is loaded
  76489. * @param onError defines a callback called if there is an error
  76490. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76491. * @param invertY defines if data must be stored with Y axis inverted
  76492. * @returns the cube texture as an InternalTexture
  76493. */
  76494. 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;
  76495. /**
  76496. * Creates a new raw 3D texture
  76497. * @param data defines the data used to create the texture
  76498. * @param width defines the width of the texture
  76499. * @param height defines the height of the texture
  76500. * @param depth defines the depth of the texture
  76501. * @param format defines the format of the texture
  76502. * @param generateMipMaps defines if the engine must generate mip levels
  76503. * @param invertY defines if data must be stored with Y axis inverted
  76504. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76505. * @param compression defines the compressed used (can be null)
  76506. * @param textureType defines the compressed used (can be null)
  76507. * @returns a new raw 3D texture (stored in an InternalTexture)
  76508. */
  76509. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76510. /**
  76511. * Update a raw 3D texture
  76512. * @param texture defines the texture to update
  76513. * @param data defines the data to store
  76514. * @param format defines the data format
  76515. * @param invertY defines if data must be stored with Y axis inverted
  76516. */
  76517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76518. /**
  76519. * Update a raw 3D texture
  76520. * @param texture defines the texture to update
  76521. * @param data defines the data to store
  76522. * @param format defines the data format
  76523. * @param invertY defines if data must be stored with Y axis inverted
  76524. * @param compression defines the used compression (can be null)
  76525. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76526. */
  76527. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76528. }
  76529. }
  76530. declare module BABYLON {
  76531. /**
  76532. * Raw texture can help creating a texture directly from an array of data.
  76533. * This can be super useful if you either get the data from an uncompressed source or
  76534. * if you wish to create your texture pixel by pixel.
  76535. */
  76536. export class RawTexture extends Texture {
  76537. /**
  76538. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76539. */
  76540. format: number;
  76541. private _engine;
  76542. /**
  76543. * Instantiates a new RawTexture.
  76544. * Raw texture can help creating a texture directly from an array of data.
  76545. * This can be super useful if you either get the data from an uncompressed source or
  76546. * if you wish to create your texture pixel by pixel.
  76547. * @param data define the array of data to use to create the texture
  76548. * @param width define the width of the texture
  76549. * @param height define the height of the texture
  76550. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76551. * @param scene define the scene the texture belongs to
  76552. * @param generateMipMaps define whether mip maps should be generated or not
  76553. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76554. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76555. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76556. */
  76557. constructor(data: ArrayBufferView, width: number, height: number,
  76558. /**
  76559. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76560. */
  76561. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76562. /**
  76563. * Updates the texture underlying data.
  76564. * @param data Define the new data of the texture
  76565. */
  76566. update(data: ArrayBufferView): void;
  76567. /**
  76568. * Creates a luminance texture from some data.
  76569. * @param data Define the texture data
  76570. * @param width Define the width of the texture
  76571. * @param height Define the height of the texture
  76572. * @param scene Define the scene the texture belongs to
  76573. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76576. * @returns the luminance texture
  76577. */
  76578. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76579. /**
  76580. * Creates a luminance alpha texture from some data.
  76581. * @param data Define the texture data
  76582. * @param width Define the width of the texture
  76583. * @param height Define the height of the texture
  76584. * @param scene Define the scene the texture belongs to
  76585. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76586. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76587. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76588. * @returns the luminance alpha texture
  76589. */
  76590. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76591. /**
  76592. * Creates an alpha texture from some data.
  76593. * @param data Define the texture data
  76594. * @param width Define the width of the texture
  76595. * @param height Define the height of the texture
  76596. * @param scene Define the scene the texture belongs to
  76597. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76598. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76599. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76600. * @returns the alpha texture
  76601. */
  76602. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76603. /**
  76604. * Creates a RGB texture from some data.
  76605. * @param data Define the texture data
  76606. * @param width Define the width of the texture
  76607. * @param height Define the height of the texture
  76608. * @param scene Define the scene the texture belongs to
  76609. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76610. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76611. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76612. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76613. * @returns the RGB alpha texture
  76614. */
  76615. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76616. /**
  76617. * Creates a RGBA texture from some data.
  76618. * @param data Define the texture data
  76619. * @param width Define the width of the texture
  76620. * @param height Define the height of the texture
  76621. * @param scene Define the scene the texture belongs to
  76622. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76623. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76624. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76625. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76626. * @returns the RGBA texture
  76627. */
  76628. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76629. /**
  76630. * Creates a R texture from some data.
  76631. * @param data Define the texture data
  76632. * @param width Define the width of the texture
  76633. * @param height Define the height of the texture
  76634. * @param scene Define the scene the texture belongs to
  76635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76638. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76639. * @returns the R texture
  76640. */
  76641. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76642. }
  76643. }
  76644. declare module BABYLON {
  76645. /**
  76646. * Interface for the size containing width and height
  76647. */
  76648. export interface ISize {
  76649. /**
  76650. * Width
  76651. */
  76652. width: number;
  76653. /**
  76654. * Heighht
  76655. */
  76656. height: number;
  76657. }
  76658. /**
  76659. * Size containing widht and height
  76660. */
  76661. export class Size implements ISize {
  76662. /**
  76663. * Width
  76664. */
  76665. width: number;
  76666. /**
  76667. * Height
  76668. */
  76669. height: number;
  76670. /**
  76671. * Creates a Size object from the given width and height (floats).
  76672. * @param width width of the new size
  76673. * @param height height of the new size
  76674. */
  76675. constructor(width: number, height: number);
  76676. /**
  76677. * Returns a string with the Size width and height
  76678. * @returns a string with the Size width and height
  76679. */
  76680. toString(): string;
  76681. /**
  76682. * "Size"
  76683. * @returns the string "Size"
  76684. */
  76685. getClassName(): string;
  76686. /**
  76687. * Returns the Size hash code.
  76688. * @returns a hash code for a unique width and height
  76689. */
  76690. getHashCode(): number;
  76691. /**
  76692. * Updates the current size from the given one.
  76693. * @param src the given size
  76694. */
  76695. copyFrom(src: Size): void;
  76696. /**
  76697. * Updates in place the current Size from the given floats.
  76698. * @param width width of the new size
  76699. * @param height height of the new size
  76700. * @returns the updated Size.
  76701. */
  76702. copyFromFloats(width: number, height: number): Size;
  76703. /**
  76704. * Updates in place the current Size from the given floats.
  76705. * @param width width to set
  76706. * @param height height to set
  76707. * @returns the updated Size.
  76708. */
  76709. set(width: number, height: number): Size;
  76710. /**
  76711. * Multiplies the width and height by numbers
  76712. * @param w factor to multiple the width by
  76713. * @param h factor to multiple the height by
  76714. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76715. */
  76716. multiplyByFloats(w: number, h: number): Size;
  76717. /**
  76718. * Clones the size
  76719. * @returns a new Size copied from the given one.
  76720. */
  76721. clone(): Size;
  76722. /**
  76723. * True if the current Size and the given one width and height are strictly equal.
  76724. * @param other the other size to compare against
  76725. * @returns True if the current Size and the given one width and height are strictly equal.
  76726. */
  76727. equals(other: Size): boolean;
  76728. /**
  76729. * The surface of the Size : width * height (float).
  76730. */
  76731. readonly surface: number;
  76732. /**
  76733. * Create a new size of zero
  76734. * @returns a new Size set to (0.0, 0.0)
  76735. */
  76736. static Zero(): Size;
  76737. /**
  76738. * Sums the width and height of two sizes
  76739. * @param otherSize size to add to this size
  76740. * @returns a new Size set as the addition result of the current Size and the given one.
  76741. */
  76742. add(otherSize: Size): Size;
  76743. /**
  76744. * Subtracts the width and height of two
  76745. * @param otherSize size to subtract to this size
  76746. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76747. */
  76748. subtract(otherSize: Size): Size;
  76749. /**
  76750. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76751. * @param start starting size to lerp between
  76752. * @param end end size to lerp between
  76753. * @param amount amount to lerp between the start and end values
  76754. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76755. */
  76756. static Lerp(start: Size, end: Size, amount: number): Size;
  76757. }
  76758. }
  76759. declare module BABYLON {
  76760. /**
  76761. * Defines a runtime animation
  76762. */
  76763. export class RuntimeAnimation {
  76764. private _events;
  76765. /**
  76766. * The current frame of the runtime animation
  76767. */
  76768. private _currentFrame;
  76769. /**
  76770. * The animation used by the runtime animation
  76771. */
  76772. private _animation;
  76773. /**
  76774. * The target of the runtime animation
  76775. */
  76776. private _target;
  76777. /**
  76778. * The initiating animatable
  76779. */
  76780. private _host;
  76781. /**
  76782. * The original value of the runtime animation
  76783. */
  76784. private _originalValue;
  76785. /**
  76786. * The original blend value of the runtime animation
  76787. */
  76788. private _originalBlendValue;
  76789. /**
  76790. * The offsets cache of the runtime animation
  76791. */
  76792. private _offsetsCache;
  76793. /**
  76794. * The high limits cache of the runtime animation
  76795. */
  76796. private _highLimitsCache;
  76797. /**
  76798. * Specifies if the runtime animation has been stopped
  76799. */
  76800. private _stopped;
  76801. /**
  76802. * The blending factor of the runtime animation
  76803. */
  76804. private _blendingFactor;
  76805. /**
  76806. * The BabylonJS scene
  76807. */
  76808. private _scene;
  76809. /**
  76810. * The current value of the runtime animation
  76811. */
  76812. private _currentValue;
  76813. /** @hidden */
  76814. _animationState: _IAnimationState;
  76815. /**
  76816. * The active target of the runtime animation
  76817. */
  76818. private _activeTargets;
  76819. private _currentActiveTarget;
  76820. private _directTarget;
  76821. /**
  76822. * The target path of the runtime animation
  76823. */
  76824. private _targetPath;
  76825. /**
  76826. * The weight of the runtime animation
  76827. */
  76828. private _weight;
  76829. /**
  76830. * The ratio offset of the runtime animation
  76831. */
  76832. private _ratioOffset;
  76833. /**
  76834. * The previous delay of the runtime animation
  76835. */
  76836. private _previousDelay;
  76837. /**
  76838. * The previous ratio of the runtime animation
  76839. */
  76840. private _previousRatio;
  76841. private _enableBlending;
  76842. private _keys;
  76843. private _minFrame;
  76844. private _maxFrame;
  76845. private _minValue;
  76846. private _maxValue;
  76847. private _targetIsArray;
  76848. /**
  76849. * Gets the current frame of the runtime animation
  76850. */
  76851. readonly currentFrame: number;
  76852. /**
  76853. * Gets the weight of the runtime animation
  76854. */
  76855. readonly weight: number;
  76856. /**
  76857. * Gets the current value of the runtime animation
  76858. */
  76859. readonly currentValue: any;
  76860. /**
  76861. * Gets the target path of the runtime animation
  76862. */
  76863. readonly targetPath: string;
  76864. /**
  76865. * Gets the actual target of the runtime animation
  76866. */
  76867. readonly target: any;
  76868. /** @hidden */
  76869. _onLoop: () => void;
  76870. /**
  76871. * Create a new RuntimeAnimation object
  76872. * @param target defines the target of the animation
  76873. * @param animation defines the source animation object
  76874. * @param scene defines the hosting scene
  76875. * @param host defines the initiating Animatable
  76876. */
  76877. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76878. private _preparePath;
  76879. /**
  76880. * Gets the animation from the runtime animation
  76881. */
  76882. readonly animation: Animation;
  76883. /**
  76884. * Resets the runtime animation to the beginning
  76885. * @param restoreOriginal defines whether to restore the target property to the original value
  76886. */
  76887. reset(restoreOriginal?: boolean): void;
  76888. /**
  76889. * Specifies if the runtime animation is stopped
  76890. * @returns Boolean specifying if the runtime animation is stopped
  76891. */
  76892. isStopped(): boolean;
  76893. /**
  76894. * Disposes of the runtime animation
  76895. */
  76896. dispose(): void;
  76897. /**
  76898. * Apply the interpolated value to the target
  76899. * @param currentValue defines the value computed by the animation
  76900. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76901. */
  76902. setValue(currentValue: any, weight: number): void;
  76903. private _getOriginalValues;
  76904. private _setValue;
  76905. /**
  76906. * Gets the loop pmode of the runtime animation
  76907. * @returns Loop Mode
  76908. */
  76909. private _getCorrectLoopMode;
  76910. /**
  76911. * Move the current animation to a given frame
  76912. * @param frame defines the frame to move to
  76913. */
  76914. goToFrame(frame: number): void;
  76915. /**
  76916. * @hidden Internal use only
  76917. */
  76918. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76919. /**
  76920. * Execute the current animation
  76921. * @param delay defines the delay to add to the current frame
  76922. * @param from defines the lower bound of the animation range
  76923. * @param to defines the upper bound of the animation range
  76924. * @param loop defines if the current animation must loop
  76925. * @param speedRatio defines the current speed ratio
  76926. * @param weight defines the weight of the animation (default is -1 so no weight)
  76927. * @param onLoop optional callback called when animation loops
  76928. * @returns a boolean indicating if the animation is running
  76929. */
  76930. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76931. }
  76932. }
  76933. declare module BABYLON {
  76934. /**
  76935. * Class used to store an actual running animation
  76936. */
  76937. export class Animatable {
  76938. /** defines the target object */
  76939. target: any;
  76940. /** defines the starting frame number (default is 0) */
  76941. fromFrame: number;
  76942. /** defines the ending frame number (default is 100) */
  76943. toFrame: number;
  76944. /** defines if the animation must loop (default is false) */
  76945. loopAnimation: boolean;
  76946. /** defines a callback to call when animation ends if it is not looping */
  76947. onAnimationEnd?: (() => void) | null | undefined;
  76948. /** defines a callback to call when animation loops */
  76949. onAnimationLoop?: (() => void) | null | undefined;
  76950. private _localDelayOffset;
  76951. private _pausedDelay;
  76952. private _runtimeAnimations;
  76953. private _paused;
  76954. private _scene;
  76955. private _speedRatio;
  76956. private _weight;
  76957. private _syncRoot;
  76958. /**
  76959. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76960. * This will only apply for non looping animation (default is true)
  76961. */
  76962. disposeOnEnd: boolean;
  76963. /**
  76964. * Gets a boolean indicating if the animation has started
  76965. */
  76966. animationStarted: boolean;
  76967. /**
  76968. * Observer raised when the animation ends
  76969. */
  76970. onAnimationEndObservable: Observable<Animatable>;
  76971. /**
  76972. * Observer raised when the animation loops
  76973. */
  76974. onAnimationLoopObservable: Observable<Animatable>;
  76975. /**
  76976. * Gets the root Animatable used to synchronize and normalize animations
  76977. */
  76978. readonly syncRoot: Nullable<Animatable>;
  76979. /**
  76980. * Gets the current frame of the first RuntimeAnimation
  76981. * Used to synchronize Animatables
  76982. */
  76983. readonly masterFrame: number;
  76984. /**
  76985. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76986. */
  76987. weight: number;
  76988. /**
  76989. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76990. */
  76991. speedRatio: number;
  76992. /**
  76993. * Creates a new Animatable
  76994. * @param scene defines the hosting scene
  76995. * @param target defines the target object
  76996. * @param fromFrame defines the starting frame number (default is 0)
  76997. * @param toFrame defines the ending frame number (default is 100)
  76998. * @param loopAnimation defines if the animation must loop (default is false)
  76999. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77000. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77001. * @param animations defines a group of animation to add to the new Animatable
  77002. * @param onAnimationLoop defines a callback to call when animation loops
  77003. */
  77004. constructor(scene: Scene,
  77005. /** defines the target object */
  77006. target: any,
  77007. /** defines the starting frame number (default is 0) */
  77008. fromFrame?: number,
  77009. /** defines the ending frame number (default is 100) */
  77010. toFrame?: number,
  77011. /** defines if the animation must loop (default is false) */
  77012. loopAnimation?: boolean, speedRatio?: number,
  77013. /** defines a callback to call when animation ends if it is not looping */
  77014. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77015. /** defines a callback to call when animation loops */
  77016. onAnimationLoop?: (() => void) | null | undefined);
  77017. /**
  77018. * Synchronize and normalize current Animatable with a source Animatable
  77019. * This is useful when using animation weights and when animations are not of the same length
  77020. * @param root defines the root Animatable to synchronize with
  77021. * @returns the current Animatable
  77022. */
  77023. syncWith(root: Animatable): Animatable;
  77024. /**
  77025. * Gets the list of runtime animations
  77026. * @returns an array of RuntimeAnimation
  77027. */
  77028. getAnimations(): RuntimeAnimation[];
  77029. /**
  77030. * Adds more animations to the current animatable
  77031. * @param target defines the target of the animations
  77032. * @param animations defines the new animations to add
  77033. */
  77034. appendAnimations(target: any, animations: Animation[]): void;
  77035. /**
  77036. * Gets the source animation for a specific property
  77037. * @param property defines the propertyu to look for
  77038. * @returns null or the source animation for the given property
  77039. */
  77040. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77041. /**
  77042. * Gets the runtime animation for a specific property
  77043. * @param property defines the propertyu to look for
  77044. * @returns null or the runtime animation for the given property
  77045. */
  77046. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77047. /**
  77048. * Resets the animatable to its original state
  77049. */
  77050. reset(): void;
  77051. /**
  77052. * Allows the animatable to blend with current running animations
  77053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77054. * @param blendingSpeed defines the blending speed to use
  77055. */
  77056. enableBlending(blendingSpeed: number): void;
  77057. /**
  77058. * Disable animation blending
  77059. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77060. */
  77061. disableBlending(): void;
  77062. /**
  77063. * Jump directly to a given frame
  77064. * @param frame defines the frame to jump to
  77065. */
  77066. goToFrame(frame: number): void;
  77067. /**
  77068. * Pause the animation
  77069. */
  77070. pause(): void;
  77071. /**
  77072. * Restart the animation
  77073. */
  77074. restart(): void;
  77075. private _raiseOnAnimationEnd;
  77076. /**
  77077. * Stop and delete the current animation
  77078. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77079. * @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)
  77080. */
  77081. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77082. /**
  77083. * Wait asynchronously for the animation to end
  77084. * @returns a promise which will be fullfilled when the animation ends
  77085. */
  77086. waitAsync(): Promise<Animatable>;
  77087. /** @hidden */
  77088. _animate(delay: number): boolean;
  77089. }
  77090. interface Scene {
  77091. /** @hidden */
  77092. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77093. /** @hidden */
  77094. _processLateAnimationBindingsForMatrices(holder: {
  77095. totalWeight: number;
  77096. animations: RuntimeAnimation[];
  77097. originalValue: Matrix;
  77098. }): any;
  77099. /** @hidden */
  77100. _processLateAnimationBindingsForQuaternions(holder: {
  77101. totalWeight: number;
  77102. animations: RuntimeAnimation[];
  77103. originalValue: Quaternion;
  77104. }, refQuaternion: Quaternion): Quaternion;
  77105. /** @hidden */
  77106. _processLateAnimationBindings(): void;
  77107. /**
  77108. * Will start the animation sequence of a given target
  77109. * @param target defines the target
  77110. * @param from defines from which frame should animation start
  77111. * @param to defines until which frame should animation run.
  77112. * @param weight defines the weight to apply to the animation (1.0 by default)
  77113. * @param loop defines if the animation loops
  77114. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77115. * @param onAnimationEnd defines the function to be executed when the animation ends
  77116. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77117. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77118. * @param onAnimationLoop defines the callback to call when an animation loops
  77119. * @returns the animatable object created for this animation
  77120. */
  77121. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77122. /**
  77123. * Will start the animation sequence of a given target
  77124. * @param target defines the target
  77125. * @param from defines from which frame should animation start
  77126. * @param to defines until which frame should animation run.
  77127. * @param loop defines if the animation loops
  77128. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77129. * @param onAnimationEnd defines the function to be executed when the animation ends
  77130. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77131. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77132. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77133. * @param onAnimationLoop defines the callback to call when an animation loops
  77134. * @returns the animatable object created for this animation
  77135. */
  77136. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77137. /**
  77138. * Will start the animation sequence of a given target and its hierarchy
  77139. * @param target defines the target
  77140. * @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.
  77141. * @param from defines from which frame should animation start
  77142. * @param to defines until which frame should animation run.
  77143. * @param loop defines if the animation loops
  77144. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77145. * @param onAnimationEnd defines the function to be executed when the animation ends
  77146. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77147. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77148. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77149. * @param onAnimationLoop defines the callback to call when an animation loops
  77150. * @returns the list of created animatables
  77151. */
  77152. 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[];
  77153. /**
  77154. * Begin a new animation on a given node
  77155. * @param target defines the target where the animation will take place
  77156. * @param animations defines the list of animations to start
  77157. * @param from defines the initial value
  77158. * @param to defines the final value
  77159. * @param loop defines if you want animation to loop (off by default)
  77160. * @param speedRatio defines the speed ratio to apply to all animations
  77161. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77162. * @param onAnimationLoop defines the callback to call when an animation loops
  77163. * @returns the list of created animatables
  77164. */
  77165. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77166. /**
  77167. * Begin a new animation on a given node and its hierarchy
  77168. * @param target defines the root node where the animation will take place
  77169. * @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.
  77170. * @param animations defines the list of animations to start
  77171. * @param from defines the initial value
  77172. * @param to defines the final value
  77173. * @param loop defines if you want animation to loop (off by default)
  77174. * @param speedRatio defines the speed ratio to apply to all animations
  77175. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77176. * @param onAnimationLoop defines the callback to call when an animation loops
  77177. * @returns the list of animatables created for all nodes
  77178. */
  77179. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77180. /**
  77181. * Gets the animatable associated with a specific target
  77182. * @param target defines the target of the animatable
  77183. * @returns the required animatable if found
  77184. */
  77185. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77186. /**
  77187. * Gets all animatables associated with a given target
  77188. * @param target defines the target to look animatables for
  77189. * @returns an array of Animatables
  77190. */
  77191. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77192. /**
  77193. * Stops and removes all animations that have been applied to the scene
  77194. */
  77195. stopAllAnimations(): void;
  77196. }
  77197. interface Bone {
  77198. /**
  77199. * Copy an animation range from another bone
  77200. * @param source defines the source bone
  77201. * @param rangeName defines the range name to copy
  77202. * @param frameOffset defines the frame offset
  77203. * @param rescaleAsRequired defines if rescaling must be applied if required
  77204. * @param skelDimensionsRatio defines the scaling ratio
  77205. * @returns true if operation was successful
  77206. */
  77207. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77208. }
  77209. }
  77210. declare module BABYLON {
  77211. /**
  77212. * Class used to override all child animations of a given target
  77213. */
  77214. export class AnimationPropertiesOverride {
  77215. /**
  77216. * Gets or sets a value indicating if animation blending must be used
  77217. */
  77218. enableBlending: boolean;
  77219. /**
  77220. * Gets or sets the blending speed to use when enableBlending is true
  77221. */
  77222. blendingSpeed: number;
  77223. /**
  77224. * Gets or sets the default loop mode to use
  77225. */
  77226. loopMode: number;
  77227. }
  77228. }
  77229. declare module BABYLON {
  77230. /**
  77231. * Class used to handle skinning animations
  77232. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77233. */
  77234. export class Skeleton implements IAnimatable {
  77235. /** defines the skeleton name */
  77236. name: string;
  77237. /** defines the skeleton Id */
  77238. id: string;
  77239. /**
  77240. * Defines the list of child bones
  77241. */
  77242. bones: Bone[];
  77243. /**
  77244. * Defines an estimate of the dimension of the skeleton at rest
  77245. */
  77246. dimensionsAtRest: Vector3;
  77247. /**
  77248. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77249. */
  77250. needInitialSkinMatrix: boolean;
  77251. /**
  77252. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77253. */
  77254. overrideMesh: Nullable<AbstractMesh>;
  77255. /**
  77256. * Gets the list of animations attached to this skeleton
  77257. */
  77258. animations: Array<Animation>;
  77259. private _scene;
  77260. private _isDirty;
  77261. private _transformMatrices;
  77262. private _transformMatrixTexture;
  77263. private _meshesWithPoseMatrix;
  77264. private _animatables;
  77265. private _identity;
  77266. private _synchronizedWithMesh;
  77267. private _ranges;
  77268. private _lastAbsoluteTransformsUpdateId;
  77269. private _canUseTextureForBones;
  77270. private _uniqueId;
  77271. /** @hidden */
  77272. _numBonesWithLinkedTransformNode: number;
  77273. /** @hidden */
  77274. _hasWaitingData: Nullable<boolean>;
  77275. /**
  77276. * Specifies if the skeleton should be serialized
  77277. */
  77278. doNotSerialize: boolean;
  77279. private _useTextureToStoreBoneMatrices;
  77280. /**
  77281. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77282. * Please note that this option is not available if the hardware does not support it
  77283. */
  77284. useTextureToStoreBoneMatrices: boolean;
  77285. private _animationPropertiesOverride;
  77286. /**
  77287. * Gets or sets the animation properties override
  77288. */
  77289. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77290. /**
  77291. * List of inspectable custom properties (used by the Inspector)
  77292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77293. */
  77294. inspectableCustomProperties: IInspectable[];
  77295. /**
  77296. * An observable triggered before computing the skeleton's matrices
  77297. */
  77298. onBeforeComputeObservable: Observable<Skeleton>;
  77299. /**
  77300. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77301. */
  77302. readonly isUsingTextureForMatrices: boolean;
  77303. /**
  77304. * Gets the unique ID of this skeleton
  77305. */
  77306. readonly uniqueId: number;
  77307. /**
  77308. * Creates a new skeleton
  77309. * @param name defines the skeleton name
  77310. * @param id defines the skeleton Id
  77311. * @param scene defines the hosting scene
  77312. */
  77313. constructor(
  77314. /** defines the skeleton name */
  77315. name: string,
  77316. /** defines the skeleton Id */
  77317. id: string, scene: Scene);
  77318. /**
  77319. * Gets the current object class name.
  77320. * @return the class name
  77321. */
  77322. getClassName(): string;
  77323. /**
  77324. * Returns an array containing the root bones
  77325. * @returns an array containing the root bones
  77326. */
  77327. getChildren(): Array<Bone>;
  77328. /**
  77329. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77330. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77331. * @returns a Float32Array containing matrices data
  77332. */
  77333. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77334. /**
  77335. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77336. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77337. * @returns a raw texture containing the data
  77338. */
  77339. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77340. /**
  77341. * Gets the current hosting scene
  77342. * @returns a scene object
  77343. */
  77344. getScene(): Scene;
  77345. /**
  77346. * Gets a string representing the current skeleton data
  77347. * @param fullDetails defines a boolean indicating if we want a verbose version
  77348. * @returns a string representing the current skeleton data
  77349. */
  77350. toString(fullDetails?: boolean): string;
  77351. /**
  77352. * Get bone's index searching by name
  77353. * @param name defines bone's name to search for
  77354. * @return the indice of the bone. Returns -1 if not found
  77355. */
  77356. getBoneIndexByName(name: string): number;
  77357. /**
  77358. * Creater a new animation range
  77359. * @param name defines the name of the range
  77360. * @param from defines the start key
  77361. * @param to defines the end key
  77362. */
  77363. createAnimationRange(name: string, from: number, to: number): void;
  77364. /**
  77365. * Delete a specific animation range
  77366. * @param name defines the name of the range
  77367. * @param deleteFrames defines if frames must be removed as well
  77368. */
  77369. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77370. /**
  77371. * Gets a specific animation range
  77372. * @param name defines the name of the range to look for
  77373. * @returns the requested animation range or null if not found
  77374. */
  77375. getAnimationRange(name: string): Nullable<AnimationRange>;
  77376. /**
  77377. * Gets the list of all animation ranges defined on this skeleton
  77378. * @returns an array
  77379. */
  77380. getAnimationRanges(): Nullable<AnimationRange>[];
  77381. /**
  77382. * Copy animation range from a source skeleton.
  77383. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77384. * @param source defines the source skeleton
  77385. * @param name defines the name of the range to copy
  77386. * @param rescaleAsRequired defines if rescaling must be applied if required
  77387. * @returns true if operation was successful
  77388. */
  77389. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77390. /**
  77391. * Forces the skeleton to go to rest pose
  77392. */
  77393. returnToRest(): void;
  77394. private _getHighestAnimationFrame;
  77395. /**
  77396. * Begin a specific animation range
  77397. * @param name defines the name of the range to start
  77398. * @param loop defines if looping must be turned on (false by default)
  77399. * @param speedRatio defines the speed ratio to apply (1 by default)
  77400. * @param onAnimationEnd defines a callback which will be called when animation will end
  77401. * @returns a new animatable
  77402. */
  77403. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77404. /** @hidden */
  77405. _markAsDirty(): void;
  77406. /** @hidden */
  77407. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77408. /** @hidden */
  77409. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77410. private _computeTransformMatrices;
  77411. /**
  77412. * Build all resources required to render a skeleton
  77413. */
  77414. prepare(): void;
  77415. /**
  77416. * Gets the list of animatables currently running for this skeleton
  77417. * @returns an array of animatables
  77418. */
  77419. getAnimatables(): IAnimatable[];
  77420. /**
  77421. * Clone the current skeleton
  77422. * @param name defines the name of the new skeleton
  77423. * @param id defines the id of the new skeleton
  77424. * @returns the new skeleton
  77425. */
  77426. clone(name: string, id: string): Skeleton;
  77427. /**
  77428. * Enable animation blending for this skeleton
  77429. * @param blendingSpeed defines the blending speed to apply
  77430. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77431. */
  77432. enableBlending(blendingSpeed?: number): void;
  77433. /**
  77434. * Releases all resources associated with the current skeleton
  77435. */
  77436. dispose(): void;
  77437. /**
  77438. * Serialize the skeleton in a JSON object
  77439. * @returns a JSON object
  77440. */
  77441. serialize(): any;
  77442. /**
  77443. * Creates a new skeleton from serialized data
  77444. * @param parsedSkeleton defines the serialized data
  77445. * @param scene defines the hosting scene
  77446. * @returns a new skeleton
  77447. */
  77448. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77449. /**
  77450. * Compute all node absolute transforms
  77451. * @param forceUpdate defines if computation must be done even if cache is up to date
  77452. */
  77453. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77454. /**
  77455. * Gets the root pose matrix
  77456. * @returns a matrix
  77457. */
  77458. getPoseMatrix(): Nullable<Matrix>;
  77459. /**
  77460. * Sorts bones per internal index
  77461. */
  77462. sortBones(): void;
  77463. private _sortBones;
  77464. }
  77465. }
  77466. declare module BABYLON {
  77467. /**
  77468. * Class used to store bone information
  77469. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77470. */
  77471. export class Bone extends Node {
  77472. /**
  77473. * defines the bone name
  77474. */
  77475. name: string;
  77476. private static _tmpVecs;
  77477. private static _tmpQuat;
  77478. private static _tmpMats;
  77479. /**
  77480. * Gets the list of child bones
  77481. */
  77482. children: Bone[];
  77483. /** Gets the animations associated with this bone */
  77484. animations: Animation[];
  77485. /**
  77486. * Gets or sets bone length
  77487. */
  77488. length: number;
  77489. /**
  77490. * @hidden Internal only
  77491. * Set this value to map this bone to a different index in the transform matrices
  77492. * Set this value to -1 to exclude the bone from the transform matrices
  77493. */
  77494. _index: Nullable<number>;
  77495. private _skeleton;
  77496. private _localMatrix;
  77497. private _restPose;
  77498. private _baseMatrix;
  77499. private _absoluteTransform;
  77500. private _invertedAbsoluteTransform;
  77501. private _parent;
  77502. private _scalingDeterminant;
  77503. private _worldTransform;
  77504. private _localScaling;
  77505. private _localRotation;
  77506. private _localPosition;
  77507. private _needToDecompose;
  77508. private _needToCompose;
  77509. /** @hidden */
  77510. _linkedTransformNode: Nullable<TransformNode>;
  77511. /** @hidden */
  77512. _waitingTransformNodeId: Nullable<string>;
  77513. /** @hidden */
  77514. /** @hidden */
  77515. _matrix: Matrix;
  77516. /**
  77517. * Create a new bone
  77518. * @param name defines the bone name
  77519. * @param skeleton defines the parent skeleton
  77520. * @param parentBone defines the parent (can be null if the bone is the root)
  77521. * @param localMatrix defines the local matrix
  77522. * @param restPose defines the rest pose matrix
  77523. * @param baseMatrix defines the base matrix
  77524. * @param index defines index of the bone in the hiearchy
  77525. */
  77526. constructor(
  77527. /**
  77528. * defines the bone name
  77529. */
  77530. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77531. /**
  77532. * Gets the current object class name.
  77533. * @return the class name
  77534. */
  77535. getClassName(): string;
  77536. /**
  77537. * Gets the parent skeleton
  77538. * @returns a skeleton
  77539. */
  77540. getSkeleton(): Skeleton;
  77541. /**
  77542. * Gets parent bone
  77543. * @returns a bone or null if the bone is the root of the bone hierarchy
  77544. */
  77545. getParent(): Nullable<Bone>;
  77546. /**
  77547. * Returns an array containing the root bones
  77548. * @returns an array containing the root bones
  77549. */
  77550. getChildren(): Array<Bone>;
  77551. /**
  77552. * Sets the parent bone
  77553. * @param parent defines the parent (can be null if the bone is the root)
  77554. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77555. */
  77556. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77557. /**
  77558. * Gets the local matrix
  77559. * @returns a matrix
  77560. */
  77561. getLocalMatrix(): Matrix;
  77562. /**
  77563. * Gets the base matrix (initial matrix which remains unchanged)
  77564. * @returns a matrix
  77565. */
  77566. getBaseMatrix(): Matrix;
  77567. /**
  77568. * Gets the rest pose matrix
  77569. * @returns a matrix
  77570. */
  77571. getRestPose(): Matrix;
  77572. /**
  77573. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77574. */
  77575. getWorldMatrix(): Matrix;
  77576. /**
  77577. * Sets the local matrix to rest pose matrix
  77578. */
  77579. returnToRest(): void;
  77580. /**
  77581. * Gets the inverse of the absolute transform matrix.
  77582. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77583. * @returns a matrix
  77584. */
  77585. getInvertedAbsoluteTransform(): Matrix;
  77586. /**
  77587. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77588. * @returns a matrix
  77589. */
  77590. getAbsoluteTransform(): Matrix;
  77591. /**
  77592. * Links with the given transform node.
  77593. * The local matrix of this bone is copied from the transform node every frame.
  77594. * @param transformNode defines the transform node to link to
  77595. */
  77596. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77597. /**
  77598. * Gets the node used to drive the bone's transformation
  77599. * @returns a transform node or null
  77600. */
  77601. getTransformNode(): Nullable<TransformNode>;
  77602. /** Gets or sets current position (in local space) */
  77603. position: Vector3;
  77604. /** Gets or sets current rotation (in local space) */
  77605. rotation: Vector3;
  77606. /** Gets or sets current rotation quaternion (in local space) */
  77607. rotationQuaternion: Quaternion;
  77608. /** Gets or sets current scaling (in local space) */
  77609. scaling: Vector3;
  77610. /**
  77611. * Gets the animation properties override
  77612. */
  77613. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77614. private _decompose;
  77615. private _compose;
  77616. /**
  77617. * Update the base and local matrices
  77618. * @param matrix defines the new base or local matrix
  77619. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77620. * @param updateLocalMatrix defines if the local matrix should be updated
  77621. */
  77622. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77623. /** @hidden */
  77624. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77625. /**
  77626. * Flag the bone as dirty (Forcing it to update everything)
  77627. */
  77628. markAsDirty(): void;
  77629. /** @hidden */
  77630. _markAsDirtyAndCompose(): void;
  77631. private _markAsDirtyAndDecompose;
  77632. /**
  77633. * Translate the bone in local or world space
  77634. * @param vec The amount to translate the bone
  77635. * @param space The space that the translation is in
  77636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77637. */
  77638. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77639. /**
  77640. * Set the postion of the bone in local or world space
  77641. * @param position The position to set the bone
  77642. * @param space The space that the position is in
  77643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77644. */
  77645. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77646. /**
  77647. * Set the absolute position of the bone (world space)
  77648. * @param position The position to set the bone
  77649. * @param mesh The mesh that this bone is attached to
  77650. */
  77651. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77652. /**
  77653. * Scale the bone on the x, y and z axes (in local space)
  77654. * @param x The amount to scale the bone on the x axis
  77655. * @param y The amount to scale the bone on the y axis
  77656. * @param z The amount to scale the bone on the z axis
  77657. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77658. */
  77659. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77660. /**
  77661. * Set the bone scaling in local space
  77662. * @param scale defines the scaling vector
  77663. */
  77664. setScale(scale: Vector3): void;
  77665. /**
  77666. * Gets the current scaling in local space
  77667. * @returns the current scaling vector
  77668. */
  77669. getScale(): Vector3;
  77670. /**
  77671. * Gets the current scaling in local space and stores it in a target vector
  77672. * @param result defines the target vector
  77673. */
  77674. getScaleToRef(result: Vector3): void;
  77675. /**
  77676. * Set the yaw, pitch, and roll of the bone in local or world space
  77677. * @param yaw The rotation of the bone on the y axis
  77678. * @param pitch The rotation of the bone on the x axis
  77679. * @param roll The rotation of the bone on the z axis
  77680. * @param space The space that the axes of rotation are in
  77681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77682. */
  77683. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77684. /**
  77685. * Add a rotation to the bone on an axis in local or world space
  77686. * @param axis The axis to rotate the bone on
  77687. * @param amount The amount to rotate the bone
  77688. * @param space The space that the axis is in
  77689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77690. */
  77691. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77692. /**
  77693. * Set the rotation of the bone to a particular axis angle in local or world space
  77694. * @param axis The axis to rotate the bone on
  77695. * @param angle The angle that the bone should be rotated to
  77696. * @param space The space that the axis is in
  77697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77698. */
  77699. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77700. /**
  77701. * Set the euler rotation of the bone in local of world space
  77702. * @param rotation The euler rotation that the bone should be set to
  77703. * @param space The space that the rotation is in
  77704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77705. */
  77706. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77707. /**
  77708. * Set the quaternion rotation of the bone in local of world space
  77709. * @param quat The quaternion rotation that the bone should be set to
  77710. * @param space The space that the rotation is in
  77711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77712. */
  77713. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77714. /**
  77715. * Set the rotation matrix of the bone in local of world space
  77716. * @param rotMat The rotation matrix that the bone should be set to
  77717. * @param space The space that the rotation is in
  77718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77719. */
  77720. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77721. private _rotateWithMatrix;
  77722. private _getNegativeRotationToRef;
  77723. /**
  77724. * Get the position of the bone in local or world space
  77725. * @param space The space that the returned position is in
  77726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77727. * @returns The position of the bone
  77728. */
  77729. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77730. /**
  77731. * Copy the position of the bone to a vector3 in local or world space
  77732. * @param space The space that the returned position is in
  77733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77734. * @param result The vector3 to copy the position to
  77735. */
  77736. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77737. /**
  77738. * Get the absolute position of the bone (world space)
  77739. * @param mesh The mesh that this bone is attached to
  77740. * @returns The absolute position of the bone
  77741. */
  77742. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77743. /**
  77744. * Copy the absolute position of the bone (world space) to the result param
  77745. * @param mesh The mesh that this bone is attached to
  77746. * @param result The vector3 to copy the absolute position to
  77747. */
  77748. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77749. /**
  77750. * Compute the absolute transforms of this bone and its children
  77751. */
  77752. computeAbsoluteTransforms(): void;
  77753. /**
  77754. * Get the world direction from an axis that is in the local space of the bone
  77755. * @param localAxis The local direction that is used to compute the world direction
  77756. * @param mesh The mesh that this bone is attached to
  77757. * @returns The world direction
  77758. */
  77759. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77760. /**
  77761. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77762. * @param localAxis The local direction that is used to compute the world direction
  77763. * @param mesh The mesh that this bone is attached to
  77764. * @param result The vector3 that the world direction will be copied to
  77765. */
  77766. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77767. /**
  77768. * Get the euler rotation of the bone in local or world space
  77769. * @param space The space that the rotation should be in
  77770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77771. * @returns The euler rotation
  77772. */
  77773. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77774. /**
  77775. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77776. * @param space The space that the rotation should be in
  77777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77778. * @param result The vector3 that the rotation should be copied to
  77779. */
  77780. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77781. /**
  77782. * Get the quaternion rotation of the bone in either local or world space
  77783. * @param space The space that the rotation should be in
  77784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77785. * @returns The quaternion rotation
  77786. */
  77787. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77788. /**
  77789. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77790. * @param space The space that the rotation should be in
  77791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77792. * @param result The quaternion that the rotation should be copied to
  77793. */
  77794. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77795. /**
  77796. * Get the rotation matrix of the bone in local or world space
  77797. * @param space The space that the rotation should be in
  77798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77799. * @returns The rotation matrix
  77800. */
  77801. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77802. /**
  77803. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77804. * @param space The space that the rotation should be in
  77805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77806. * @param result The quaternion that the rotation should be copied to
  77807. */
  77808. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77809. /**
  77810. * Get the world position of a point that is in the local space of the bone
  77811. * @param position The local position
  77812. * @param mesh The mesh that this bone is attached to
  77813. * @returns The world position
  77814. */
  77815. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77816. /**
  77817. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77818. * @param position The local position
  77819. * @param mesh The mesh that this bone is attached to
  77820. * @param result The vector3 that the world position should be copied to
  77821. */
  77822. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77823. /**
  77824. * Get the local position of a point that is in world space
  77825. * @param position The world position
  77826. * @param mesh The mesh that this bone is attached to
  77827. * @returns The local position
  77828. */
  77829. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77830. /**
  77831. * Get the local position of a point that is in world space and copy it to the result param
  77832. * @param position The world position
  77833. * @param mesh The mesh that this bone is attached to
  77834. * @param result The vector3 that the local position should be copied to
  77835. */
  77836. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77837. }
  77838. }
  77839. declare module BABYLON {
  77840. /**
  77841. * 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.
  77842. * @see https://doc.babylonjs.com/how_to/transformnode
  77843. */
  77844. export class TransformNode extends Node {
  77845. /**
  77846. * Object will not rotate to face the camera
  77847. */
  77848. static BILLBOARDMODE_NONE: number;
  77849. /**
  77850. * Object will rotate to face the camera but only on the x axis
  77851. */
  77852. static BILLBOARDMODE_X: number;
  77853. /**
  77854. * Object will rotate to face the camera but only on the y axis
  77855. */
  77856. static BILLBOARDMODE_Y: number;
  77857. /**
  77858. * Object will rotate to face the camera but only on the z axis
  77859. */
  77860. static BILLBOARDMODE_Z: number;
  77861. /**
  77862. * Object will rotate to face the camera
  77863. */
  77864. static BILLBOARDMODE_ALL: number;
  77865. private _forward;
  77866. private _forwardInverted;
  77867. private _up;
  77868. private _right;
  77869. private _rightInverted;
  77870. private _position;
  77871. private _rotation;
  77872. private _rotationQuaternion;
  77873. protected _scaling: Vector3;
  77874. protected _isDirty: boolean;
  77875. private _transformToBoneReferal;
  77876. private _isAbsoluteSynced;
  77877. private _billboardMode;
  77878. /**
  77879. * Gets or sets the billboard mode. Default is 0.
  77880. *
  77881. * | Value | Type | Description |
  77882. * | --- | --- | --- |
  77883. * | 0 | BILLBOARDMODE_NONE | |
  77884. * | 1 | BILLBOARDMODE_X | |
  77885. * | 2 | BILLBOARDMODE_Y | |
  77886. * | 4 | BILLBOARDMODE_Z | |
  77887. * | 7 | BILLBOARDMODE_ALL | |
  77888. *
  77889. */
  77890. billboardMode: number;
  77891. private _preserveParentRotationForBillboard;
  77892. /**
  77893. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77894. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77895. */
  77896. preserveParentRotationForBillboard: boolean;
  77897. /**
  77898. * 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
  77899. */
  77900. scalingDeterminant: number;
  77901. private _infiniteDistance;
  77902. /**
  77903. * Gets or sets the distance of the object to max, often used by skybox
  77904. */
  77905. infiniteDistance: boolean;
  77906. /**
  77907. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77908. * By default the system will update normals to compensate
  77909. */
  77910. ignoreNonUniformScaling: boolean;
  77911. /**
  77912. * 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
  77913. */
  77914. reIntegrateRotationIntoRotationQuaternion: boolean;
  77915. /** @hidden */
  77916. _poseMatrix: Nullable<Matrix>;
  77917. /** @hidden */
  77918. _localMatrix: Matrix;
  77919. private _usePivotMatrix;
  77920. private _absolutePosition;
  77921. private _absoluteScaling;
  77922. private _absoluteRotationQuaternion;
  77923. private _pivotMatrix;
  77924. private _pivotMatrixInverse;
  77925. protected _postMultiplyPivotMatrix: boolean;
  77926. protected _isWorldMatrixFrozen: boolean;
  77927. /** @hidden */
  77928. _indexInSceneTransformNodesArray: number;
  77929. /**
  77930. * An event triggered after the world matrix is updated
  77931. */
  77932. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77933. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77934. /**
  77935. * Gets a string identifying the name of the class
  77936. * @returns "TransformNode" string
  77937. */
  77938. getClassName(): string;
  77939. /**
  77940. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77941. */
  77942. position: Vector3;
  77943. /**
  77944. * 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)).
  77945. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77946. */
  77947. rotation: Vector3;
  77948. /**
  77949. * 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)).
  77950. */
  77951. scaling: Vector3;
  77952. /**
  77953. * 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).
  77954. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77955. */
  77956. rotationQuaternion: Nullable<Quaternion>;
  77957. /**
  77958. * The forward direction of that transform in world space.
  77959. */
  77960. readonly forward: Vector3;
  77961. /**
  77962. * The up direction of that transform in world space.
  77963. */
  77964. readonly up: Vector3;
  77965. /**
  77966. * The right direction of that transform in world space.
  77967. */
  77968. readonly right: Vector3;
  77969. /**
  77970. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77971. * @param matrix the matrix to copy the pose from
  77972. * @returns this TransformNode.
  77973. */
  77974. updatePoseMatrix(matrix: Matrix): TransformNode;
  77975. /**
  77976. * Returns the mesh Pose matrix.
  77977. * @returns the pose matrix
  77978. */
  77979. getPoseMatrix(): Matrix;
  77980. /** @hidden */
  77981. _isSynchronized(): boolean;
  77982. /** @hidden */
  77983. _initCache(): void;
  77984. /**
  77985. * Flag the transform node as dirty (Forcing it to update everything)
  77986. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77987. * @returns this transform node
  77988. */
  77989. markAsDirty(property: string): TransformNode;
  77990. /**
  77991. * Returns the current mesh absolute position.
  77992. * Returns a Vector3.
  77993. */
  77994. readonly absolutePosition: Vector3;
  77995. /**
  77996. * Returns the current mesh absolute scaling.
  77997. * Returns a Vector3.
  77998. */
  77999. readonly absoluteScaling: Vector3;
  78000. /**
  78001. * Returns the current mesh absolute rotation.
  78002. * Returns a Quaternion.
  78003. */
  78004. readonly absoluteRotationQuaternion: Quaternion;
  78005. /**
  78006. * Sets a new matrix to apply before all other transformation
  78007. * @param matrix defines the transform matrix
  78008. * @returns the current TransformNode
  78009. */
  78010. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78011. /**
  78012. * Sets a new pivot matrix to the current node
  78013. * @param matrix defines the new pivot matrix to use
  78014. * @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
  78015. * @returns the current TransformNode
  78016. */
  78017. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78018. /**
  78019. * Returns the mesh pivot matrix.
  78020. * Default : Identity.
  78021. * @returns the matrix
  78022. */
  78023. getPivotMatrix(): Matrix;
  78024. /**
  78025. * Prevents the World matrix to be computed any longer.
  78026. * @returns the TransformNode.
  78027. */
  78028. freezeWorldMatrix(): TransformNode;
  78029. /**
  78030. * Allows back the World matrix computation.
  78031. * @returns the TransformNode.
  78032. */
  78033. unfreezeWorldMatrix(): this;
  78034. /**
  78035. * True if the World matrix has been frozen.
  78036. */
  78037. readonly isWorldMatrixFrozen: boolean;
  78038. /**
  78039. * Retuns the mesh absolute position in the World.
  78040. * @returns a Vector3.
  78041. */
  78042. getAbsolutePosition(): Vector3;
  78043. /**
  78044. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78045. * @param absolutePosition the absolute position to set
  78046. * @returns the TransformNode.
  78047. */
  78048. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78049. /**
  78050. * Sets the mesh position in its local space.
  78051. * @param vector3 the position to set in localspace
  78052. * @returns the TransformNode.
  78053. */
  78054. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78055. /**
  78056. * Returns the mesh position in the local space from the current World matrix values.
  78057. * @returns a new Vector3.
  78058. */
  78059. getPositionExpressedInLocalSpace(): Vector3;
  78060. /**
  78061. * Translates the mesh along the passed Vector3 in its local space.
  78062. * @param vector3 the distance to translate in localspace
  78063. * @returns the TransformNode.
  78064. */
  78065. locallyTranslate(vector3: Vector3): TransformNode;
  78066. private static _lookAtVectorCache;
  78067. /**
  78068. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78069. * @param targetPoint the position (must be in same space as current mesh) to look at
  78070. * @param yawCor optional yaw (y-axis) correction in radians
  78071. * @param pitchCor optional pitch (x-axis) correction in radians
  78072. * @param rollCor optional roll (z-axis) correction in radians
  78073. * @param space the choosen space of the target
  78074. * @returns the TransformNode.
  78075. */
  78076. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78077. /**
  78078. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78079. * This Vector3 is expressed in the World space.
  78080. * @param localAxis axis to rotate
  78081. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78082. */
  78083. getDirection(localAxis: Vector3): Vector3;
  78084. /**
  78085. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78086. * localAxis is expressed in the mesh local space.
  78087. * result is computed in the Wordl space from the mesh World matrix.
  78088. * @param localAxis axis to rotate
  78089. * @param result the resulting transformnode
  78090. * @returns this TransformNode.
  78091. */
  78092. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78093. /**
  78094. * Sets this transform node rotation to the given local axis.
  78095. * @param localAxis the axis in local space
  78096. * @param yawCor optional yaw (y-axis) correction in radians
  78097. * @param pitchCor optional pitch (x-axis) correction in radians
  78098. * @param rollCor optional roll (z-axis) correction in radians
  78099. * @returns this TransformNode
  78100. */
  78101. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78102. /**
  78103. * Sets a new pivot point to the current node
  78104. * @param point defines the new pivot point to use
  78105. * @param space defines if the point is in world or local space (local by default)
  78106. * @returns the current TransformNode
  78107. */
  78108. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78109. /**
  78110. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78111. * @returns the pivot point
  78112. */
  78113. getPivotPoint(): Vector3;
  78114. /**
  78115. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78116. * @param result the vector3 to store the result
  78117. * @returns this TransformNode.
  78118. */
  78119. getPivotPointToRef(result: Vector3): TransformNode;
  78120. /**
  78121. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78122. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78123. */
  78124. getAbsolutePivotPoint(): Vector3;
  78125. /**
  78126. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78127. * @param result vector3 to store the result
  78128. * @returns this TransformNode.
  78129. */
  78130. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78131. /**
  78132. * Defines the passed node as the parent of the current node.
  78133. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78134. * @see https://doc.babylonjs.com/how_to/parenting
  78135. * @param node the node ot set as the parent
  78136. * @returns this TransformNode.
  78137. */
  78138. setParent(node: Nullable<Node>): TransformNode;
  78139. private _nonUniformScaling;
  78140. /**
  78141. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78142. */
  78143. readonly nonUniformScaling: boolean;
  78144. /** @hidden */
  78145. _updateNonUniformScalingState(value: boolean): boolean;
  78146. /**
  78147. * Attach the current TransformNode to another TransformNode associated with a bone
  78148. * @param bone Bone affecting the TransformNode
  78149. * @param affectedTransformNode TransformNode associated with the bone
  78150. * @returns this object
  78151. */
  78152. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78153. /**
  78154. * Detach the transform node if its associated with a bone
  78155. * @returns this object
  78156. */
  78157. detachFromBone(): TransformNode;
  78158. private static _rotationAxisCache;
  78159. /**
  78160. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78161. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78162. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78163. * The passed axis is also normalized.
  78164. * @param axis the axis to rotate around
  78165. * @param amount the amount to rotate in radians
  78166. * @param space Space to rotate in (Default: local)
  78167. * @returns the TransformNode.
  78168. */
  78169. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78170. /**
  78171. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78172. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78173. * The passed axis is also normalized. .
  78174. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78175. * @param point the point to rotate around
  78176. * @param axis the axis to rotate around
  78177. * @param amount the amount to rotate in radians
  78178. * @returns the TransformNode
  78179. */
  78180. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78181. /**
  78182. * Translates the mesh along the axis vector for the passed distance in the given space.
  78183. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78184. * @param axis the axis to translate in
  78185. * @param distance the distance to translate
  78186. * @param space Space to rotate in (Default: local)
  78187. * @returns the TransformNode.
  78188. */
  78189. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78190. /**
  78191. * Adds a rotation step to the mesh current rotation.
  78192. * x, y, z are Euler angles expressed in radians.
  78193. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78194. * This means this rotation is made in the mesh local space only.
  78195. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78196. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78197. * ```javascript
  78198. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78199. * ```
  78200. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78201. * 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.
  78202. * @param x Rotation to add
  78203. * @param y Rotation to add
  78204. * @param z Rotation to add
  78205. * @returns the TransformNode.
  78206. */
  78207. addRotation(x: number, y: number, z: number): TransformNode;
  78208. /**
  78209. * @hidden
  78210. */
  78211. protected _getEffectiveParent(): Nullable<Node>;
  78212. /**
  78213. * Computes the world matrix of the node
  78214. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78215. * @returns the world matrix
  78216. */
  78217. computeWorldMatrix(force?: boolean): Matrix;
  78218. protected _afterComputeWorldMatrix(): void;
  78219. /**
  78220. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78221. * @param func callback function to add
  78222. *
  78223. * @returns the TransformNode.
  78224. */
  78225. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78226. /**
  78227. * Removes a registered callback function.
  78228. * @param func callback function to remove
  78229. * @returns the TransformNode.
  78230. */
  78231. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78232. /**
  78233. * Gets the position of the current mesh in camera space
  78234. * @param camera defines the camera to use
  78235. * @returns a position
  78236. */
  78237. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78238. /**
  78239. * Returns the distance from the mesh to the active camera
  78240. * @param camera defines the camera to use
  78241. * @returns the distance
  78242. */
  78243. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78244. /**
  78245. * Clone the current transform node
  78246. * @param name Name of the new clone
  78247. * @param newParent New parent for the clone
  78248. * @param doNotCloneChildren Do not clone children hierarchy
  78249. * @returns the new transform node
  78250. */
  78251. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78252. /**
  78253. * Serializes the objects information.
  78254. * @param currentSerializationObject defines the object to serialize in
  78255. * @returns the serialized object
  78256. */
  78257. serialize(currentSerializationObject?: any): any;
  78258. /**
  78259. * Returns a new TransformNode object parsed from the source provided.
  78260. * @param parsedTransformNode is the source.
  78261. * @param scene the scne the object belongs to
  78262. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78263. * @returns a new TransformNode object parsed from the source provided.
  78264. */
  78265. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78266. /**
  78267. * Get all child-transformNodes of this node
  78268. * @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
  78269. * @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
  78270. * @returns an array of TransformNode
  78271. */
  78272. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78273. /**
  78274. * Releases resources associated with this transform node.
  78275. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78276. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78277. */
  78278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78279. /**
  78280. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78281. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78282. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78283. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78284. * @returns the current mesh
  78285. */
  78286. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78287. private _syncAbsoluteScalingAndRotation;
  78288. }
  78289. }
  78290. declare module BABYLON {
  78291. /**
  78292. * Defines the types of pose enabled controllers that are supported
  78293. */
  78294. export enum PoseEnabledControllerType {
  78295. /**
  78296. * HTC Vive
  78297. */
  78298. VIVE = 0,
  78299. /**
  78300. * Oculus Rift
  78301. */
  78302. OCULUS = 1,
  78303. /**
  78304. * Windows mixed reality
  78305. */
  78306. WINDOWS = 2,
  78307. /**
  78308. * Samsung gear VR
  78309. */
  78310. GEAR_VR = 3,
  78311. /**
  78312. * Google Daydream
  78313. */
  78314. DAYDREAM = 4,
  78315. /**
  78316. * Generic
  78317. */
  78318. GENERIC = 5
  78319. }
  78320. /**
  78321. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78322. */
  78323. export interface MutableGamepadButton {
  78324. /**
  78325. * Value of the button/trigger
  78326. */
  78327. value: number;
  78328. /**
  78329. * If the button/trigger is currently touched
  78330. */
  78331. touched: boolean;
  78332. /**
  78333. * If the button/trigger is currently pressed
  78334. */
  78335. pressed: boolean;
  78336. }
  78337. /**
  78338. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78339. * @hidden
  78340. */
  78341. export interface ExtendedGamepadButton extends GamepadButton {
  78342. /**
  78343. * If the button/trigger is currently pressed
  78344. */
  78345. readonly pressed: boolean;
  78346. /**
  78347. * If the button/trigger is currently touched
  78348. */
  78349. readonly touched: boolean;
  78350. /**
  78351. * Value of the button/trigger
  78352. */
  78353. readonly value: number;
  78354. }
  78355. /** @hidden */
  78356. export interface _GamePadFactory {
  78357. /**
  78358. * Returns wether or not the current gamepad can be created for this type of controller.
  78359. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78360. * @returns true if it can be created, otherwise false
  78361. */
  78362. canCreate(gamepadInfo: any): boolean;
  78363. /**
  78364. * Creates a new instance of the Gamepad.
  78365. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78366. * @returns the new gamepad instance
  78367. */
  78368. create(gamepadInfo: any): Gamepad;
  78369. }
  78370. /**
  78371. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78372. */
  78373. export class PoseEnabledControllerHelper {
  78374. /** @hidden */
  78375. static _ControllerFactories: _GamePadFactory[];
  78376. /** @hidden */
  78377. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78378. /**
  78379. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78380. * @param vrGamepad the gamepad to initialized
  78381. * @returns a vr controller of the type the gamepad identified as
  78382. */
  78383. static InitiateController(vrGamepad: any): Gamepad;
  78384. }
  78385. /**
  78386. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78387. */
  78388. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78389. /**
  78390. * If the controller is used in a webXR session
  78391. */
  78392. isXR: boolean;
  78393. private _deviceRoomPosition;
  78394. private _deviceRoomRotationQuaternion;
  78395. /**
  78396. * The device position in babylon space
  78397. */
  78398. devicePosition: Vector3;
  78399. /**
  78400. * The device rotation in babylon space
  78401. */
  78402. deviceRotationQuaternion: Quaternion;
  78403. /**
  78404. * The scale factor of the device in babylon space
  78405. */
  78406. deviceScaleFactor: number;
  78407. /**
  78408. * (Likely devicePosition should be used instead) The device position in its room space
  78409. */
  78410. position: Vector3;
  78411. /**
  78412. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78413. */
  78414. rotationQuaternion: Quaternion;
  78415. /**
  78416. * The type of controller (Eg. Windows mixed reality)
  78417. */
  78418. controllerType: PoseEnabledControllerType;
  78419. protected _calculatedPosition: Vector3;
  78420. private _calculatedRotation;
  78421. /**
  78422. * The raw pose from the device
  78423. */
  78424. rawPose: DevicePose;
  78425. private _trackPosition;
  78426. private _maxRotationDistFromHeadset;
  78427. private _draggedRoomRotation;
  78428. /**
  78429. * @hidden
  78430. */
  78431. _disableTrackPosition(fixedPosition: Vector3): void;
  78432. /**
  78433. * Internal, the mesh attached to the controller
  78434. * @hidden
  78435. */
  78436. _mesh: Nullable<AbstractMesh>;
  78437. private _poseControlledCamera;
  78438. private _leftHandSystemQuaternion;
  78439. /**
  78440. * Internal, matrix used to convert room space to babylon space
  78441. * @hidden
  78442. */
  78443. _deviceToWorld: Matrix;
  78444. /**
  78445. * Node to be used when casting a ray from the controller
  78446. * @hidden
  78447. */
  78448. _pointingPoseNode: Nullable<TransformNode>;
  78449. /**
  78450. * Name of the child mesh that can be used to cast a ray from the controller
  78451. */
  78452. static readonly POINTING_POSE: string;
  78453. /**
  78454. * Creates a new PoseEnabledController from a gamepad
  78455. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78456. */
  78457. constructor(browserGamepad: any);
  78458. private _workingMatrix;
  78459. /**
  78460. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78461. */
  78462. update(): void;
  78463. /**
  78464. * Updates only the pose device and mesh without doing any button event checking
  78465. */
  78466. protected _updatePoseAndMesh(): void;
  78467. /**
  78468. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78469. * @param poseData raw pose fromthe device
  78470. */
  78471. updateFromDevice(poseData: DevicePose): void;
  78472. /**
  78473. * @hidden
  78474. */
  78475. _meshAttachedObservable: Observable<AbstractMesh>;
  78476. /**
  78477. * Attaches a mesh to the controller
  78478. * @param mesh the mesh to be attached
  78479. */
  78480. attachToMesh(mesh: AbstractMesh): void;
  78481. /**
  78482. * Attaches the controllers mesh to a camera
  78483. * @param camera the camera the mesh should be attached to
  78484. */
  78485. attachToPoseControlledCamera(camera: TargetCamera): void;
  78486. /**
  78487. * Disposes of the controller
  78488. */
  78489. dispose(): void;
  78490. /**
  78491. * The mesh that is attached to the controller
  78492. */
  78493. readonly mesh: Nullable<AbstractMesh>;
  78494. /**
  78495. * Gets the ray of the controller in the direction the controller is pointing
  78496. * @param length the length the resulting ray should be
  78497. * @returns a ray in the direction the controller is pointing
  78498. */
  78499. getForwardRay(length?: number): Ray;
  78500. }
  78501. }
  78502. declare module BABYLON {
  78503. /**
  78504. * Defines the WebVRController object that represents controllers tracked in 3D space
  78505. */
  78506. export abstract class WebVRController extends PoseEnabledController {
  78507. /**
  78508. * Internal, the default controller model for the controller
  78509. */
  78510. protected _defaultModel: AbstractMesh;
  78511. /**
  78512. * Fired when the trigger state has changed
  78513. */
  78514. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78515. /**
  78516. * Fired when the main button state has changed
  78517. */
  78518. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78519. /**
  78520. * Fired when the secondary button state has changed
  78521. */
  78522. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78523. /**
  78524. * Fired when the pad state has changed
  78525. */
  78526. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78527. /**
  78528. * Fired when controllers stick values have changed
  78529. */
  78530. onPadValuesChangedObservable: Observable<StickValues>;
  78531. /**
  78532. * Array of button availible on the controller
  78533. */
  78534. protected _buttons: Array<MutableGamepadButton>;
  78535. private _onButtonStateChange;
  78536. /**
  78537. * Fired when a controller button's state has changed
  78538. * @param callback the callback containing the button that was modified
  78539. */
  78540. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78541. /**
  78542. * X and Y axis corresponding to the controllers joystick
  78543. */
  78544. pad: StickValues;
  78545. /**
  78546. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78547. */
  78548. hand: string;
  78549. /**
  78550. * The default controller model for the controller
  78551. */
  78552. readonly defaultModel: AbstractMesh;
  78553. /**
  78554. * Creates a new WebVRController from a gamepad
  78555. * @param vrGamepad the gamepad that the WebVRController should be created from
  78556. */
  78557. constructor(vrGamepad: any);
  78558. /**
  78559. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78560. */
  78561. update(): void;
  78562. /**
  78563. * Function to be called when a button is modified
  78564. */
  78565. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78566. /**
  78567. * Loads a mesh and attaches it to the controller
  78568. * @param scene the scene the mesh should be added to
  78569. * @param meshLoaded callback for when the mesh has been loaded
  78570. */
  78571. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78572. private _setButtonValue;
  78573. private _changes;
  78574. private _checkChanges;
  78575. /**
  78576. * Disposes of th webVRCOntroller
  78577. */
  78578. dispose(): void;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /**
  78583. * The HemisphericLight simulates the ambient environment light,
  78584. * so the passed direction is the light reflection direction, not the incoming direction.
  78585. */
  78586. export class HemisphericLight extends Light {
  78587. /**
  78588. * The groundColor is the light in the opposite direction to the one specified during creation.
  78589. * 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.
  78590. */
  78591. groundColor: Color3;
  78592. /**
  78593. * The light reflection direction, not the incoming direction.
  78594. */
  78595. direction: Vector3;
  78596. /**
  78597. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78598. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78599. * The HemisphericLight can't cast shadows.
  78600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78601. * @param name The friendly name of the light
  78602. * @param direction The direction of the light reflection
  78603. * @param scene The scene the light belongs to
  78604. */
  78605. constructor(name: string, direction: Vector3, scene: Scene);
  78606. protected _buildUniformLayout(): void;
  78607. /**
  78608. * Returns the string "HemisphericLight".
  78609. * @return The class name
  78610. */
  78611. getClassName(): string;
  78612. /**
  78613. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78614. * Returns the updated direction.
  78615. * @param target The target the direction should point to
  78616. * @return The computed direction
  78617. */
  78618. setDirectionToTarget(target: Vector3): Vector3;
  78619. /**
  78620. * Returns the shadow generator associated to the light.
  78621. * @returns Always null for hemispheric lights because it does not support shadows.
  78622. */
  78623. getShadowGenerator(): Nullable<IShadowGenerator>;
  78624. /**
  78625. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78626. * @param effect The effect to update
  78627. * @param lightIndex The index of the light in the effect to update
  78628. * @returns The hemispheric light
  78629. */
  78630. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78631. /**
  78632. * Computes the world matrix of the node
  78633. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78634. * @param useWasUpdatedFlag defines a reserved property
  78635. * @returns the world matrix
  78636. */
  78637. computeWorldMatrix(): Matrix;
  78638. /**
  78639. * Returns the integer 3.
  78640. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78641. */
  78642. getTypeID(): number;
  78643. /**
  78644. * Prepares the list of defines specific to the light type.
  78645. * @param defines the list of defines
  78646. * @param lightIndex defines the index of the light for the effect
  78647. */
  78648. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78649. }
  78650. }
  78651. declare module BABYLON {
  78652. /** @hidden */
  78653. export var vrMultiviewToSingleviewPixelShader: {
  78654. name: string;
  78655. shader: string;
  78656. };
  78657. }
  78658. declare module BABYLON {
  78659. /**
  78660. * Renders to multiple views with a single draw call
  78661. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78662. */
  78663. export class MultiviewRenderTarget extends RenderTargetTexture {
  78664. /**
  78665. * Creates a multiview render target
  78666. * @param scene scene used with the render target
  78667. * @param size the size of the render target (used for each view)
  78668. */
  78669. constructor(scene: Scene, size?: number | {
  78670. width: number;
  78671. height: number;
  78672. } | {
  78673. ratio: number;
  78674. });
  78675. /**
  78676. * @hidden
  78677. * @param faceIndex the face index, if its a cube texture
  78678. */
  78679. _bindFrameBuffer(faceIndex?: number): void;
  78680. /**
  78681. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78682. * @returns the view count
  78683. */
  78684. getViewCount(): number;
  78685. }
  78686. }
  78687. declare module BABYLON {
  78688. /**
  78689. * Reprasents a camera frustum
  78690. */
  78691. export class Frustum {
  78692. /**
  78693. * Gets the planes representing the frustum
  78694. * @param transform matrix to be applied to the returned planes
  78695. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78696. */
  78697. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78698. /**
  78699. * Gets the near frustum plane transformed by the transform matrix
  78700. * @param transform transformation matrix to be applied to the resulting frustum plane
  78701. * @param frustumPlane the resuling frustum plane
  78702. */
  78703. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78704. /**
  78705. * Gets the far frustum plane transformed by the transform matrix
  78706. * @param transform transformation matrix to be applied to the resulting frustum plane
  78707. * @param frustumPlane the resuling frustum plane
  78708. */
  78709. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78710. /**
  78711. * Gets the left frustum plane transformed by the transform matrix
  78712. * @param transform transformation matrix to be applied to the resulting frustum plane
  78713. * @param frustumPlane the resuling frustum plane
  78714. */
  78715. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78716. /**
  78717. * Gets the right frustum plane transformed by the transform matrix
  78718. * @param transform transformation matrix to be applied to the resulting frustum plane
  78719. * @param frustumPlane the resuling frustum plane
  78720. */
  78721. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78722. /**
  78723. * Gets the top frustum plane transformed by the transform matrix
  78724. * @param transform transformation matrix to be applied to the resulting frustum plane
  78725. * @param frustumPlane the resuling frustum plane
  78726. */
  78727. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78728. /**
  78729. * Gets the bottom frustum plane transformed by the transform matrix
  78730. * @param transform transformation matrix to be applied to the resulting frustum plane
  78731. * @param frustumPlane the resuling frustum plane
  78732. */
  78733. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78734. /**
  78735. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78736. * @param transform transformation matrix to be applied to the resulting frustum planes
  78737. * @param frustumPlanes the resuling frustum planes
  78738. */
  78739. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78740. }
  78741. }
  78742. declare module BABYLON {
  78743. interface Engine {
  78744. /**
  78745. * Creates a new multiview render target
  78746. * @param width defines the width of the texture
  78747. * @param height defines the height of the texture
  78748. * @returns the created multiview texture
  78749. */
  78750. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78751. /**
  78752. * Binds a multiview framebuffer to be drawn to
  78753. * @param multiviewTexture texture to bind
  78754. */
  78755. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78756. }
  78757. interface Camera {
  78758. /**
  78759. * @hidden
  78760. * 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)
  78761. */
  78762. _useMultiviewToSingleView: boolean;
  78763. /**
  78764. * @hidden
  78765. * 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)
  78766. */
  78767. _multiviewTexture: Nullable<RenderTargetTexture>;
  78768. /**
  78769. * @hidden
  78770. * ensures the multiview texture of the camera exists and has the specified width/height
  78771. * @param width height to set on the multiview texture
  78772. * @param height width to set on the multiview texture
  78773. */
  78774. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78775. }
  78776. interface Scene {
  78777. /** @hidden */
  78778. _transformMatrixR: Matrix;
  78779. /** @hidden */
  78780. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78781. /** @hidden */
  78782. _createMultiviewUbo(): void;
  78783. /** @hidden */
  78784. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78785. /** @hidden */
  78786. _renderMultiviewToSingleView(camera: Camera): void;
  78787. }
  78788. }
  78789. declare module BABYLON {
  78790. /**
  78791. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78792. * This will not be used for webXR as it supports displaying texture arrays directly
  78793. */
  78794. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78795. /**
  78796. * Initializes a VRMultiviewToSingleview
  78797. * @param name name of the post process
  78798. * @param camera camera to be applied to
  78799. * @param scaleFactor scaling factor to the size of the output texture
  78800. */
  78801. constructor(name: string, camera: Camera, scaleFactor: number);
  78802. }
  78803. }
  78804. declare module BABYLON {
  78805. interface Engine {
  78806. /** @hidden */
  78807. _vrDisplay: any;
  78808. /** @hidden */
  78809. _vrSupported: boolean;
  78810. /** @hidden */
  78811. _oldSize: Size;
  78812. /** @hidden */
  78813. _oldHardwareScaleFactor: number;
  78814. /** @hidden */
  78815. _vrExclusivePointerMode: boolean;
  78816. /** @hidden */
  78817. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78818. /** @hidden */
  78819. _onVRDisplayPointerRestricted: () => void;
  78820. /** @hidden */
  78821. _onVRDisplayPointerUnrestricted: () => void;
  78822. /** @hidden */
  78823. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78824. /** @hidden */
  78825. _onVrDisplayDisconnect: Nullable<() => void>;
  78826. /** @hidden */
  78827. _onVrDisplayPresentChange: Nullable<() => void>;
  78828. /**
  78829. * Observable signaled when VR display mode changes
  78830. */
  78831. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78832. /**
  78833. * Observable signaled when VR request present is complete
  78834. */
  78835. onVRRequestPresentComplete: Observable<boolean>;
  78836. /**
  78837. * Observable signaled when VR request present starts
  78838. */
  78839. onVRRequestPresentStart: Observable<Engine>;
  78840. /**
  78841. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78842. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78843. */
  78844. isInVRExclusivePointerMode: boolean;
  78845. /**
  78846. * Gets a boolean indicating if a webVR device was detected
  78847. * @returns true if a webVR device was detected
  78848. */
  78849. isVRDevicePresent(): boolean;
  78850. /**
  78851. * Gets the current webVR device
  78852. * @returns the current webVR device (or null)
  78853. */
  78854. getVRDevice(): any;
  78855. /**
  78856. * Initializes a webVR display and starts listening to display change events
  78857. * The onVRDisplayChangedObservable will be notified upon these changes
  78858. * @returns A promise containing a VRDisplay and if vr is supported
  78859. */
  78860. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78861. /** @hidden */
  78862. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78863. /**
  78864. * Call this function to switch to webVR mode
  78865. * Will do nothing if webVR is not supported or if there is no webVR device
  78866. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78867. */
  78868. enableVR(): void;
  78869. /** @hidden */
  78870. _onVRFullScreenTriggered(): void;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78876. * IMPORTANT!! The data is right-hand data.
  78877. * @export
  78878. * @interface DevicePose
  78879. */
  78880. export interface DevicePose {
  78881. /**
  78882. * The position of the device, values in array are [x,y,z].
  78883. */
  78884. readonly position: Nullable<Float32Array>;
  78885. /**
  78886. * The linearVelocity of the device, values in array are [x,y,z].
  78887. */
  78888. readonly linearVelocity: Nullable<Float32Array>;
  78889. /**
  78890. * The linearAcceleration of the device, values in array are [x,y,z].
  78891. */
  78892. readonly linearAcceleration: Nullable<Float32Array>;
  78893. /**
  78894. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78895. */
  78896. readonly orientation: Nullable<Float32Array>;
  78897. /**
  78898. * The angularVelocity of the device, values in array are [x,y,z].
  78899. */
  78900. readonly angularVelocity: Nullable<Float32Array>;
  78901. /**
  78902. * The angularAcceleration of the device, values in array are [x,y,z].
  78903. */
  78904. readonly angularAcceleration: Nullable<Float32Array>;
  78905. }
  78906. /**
  78907. * Interface representing a pose controlled object in Babylon.
  78908. * A pose controlled object has both regular pose values as well as pose values
  78909. * from an external device such as a VR head mounted display
  78910. */
  78911. export interface PoseControlled {
  78912. /**
  78913. * The position of the object in babylon space.
  78914. */
  78915. position: Vector3;
  78916. /**
  78917. * The rotation quaternion of the object in babylon space.
  78918. */
  78919. rotationQuaternion: Quaternion;
  78920. /**
  78921. * The position of the device in babylon space.
  78922. */
  78923. devicePosition?: Vector3;
  78924. /**
  78925. * The rotation quaternion of the device in babylon space.
  78926. */
  78927. deviceRotationQuaternion: Quaternion;
  78928. /**
  78929. * The raw pose coming from the device.
  78930. */
  78931. rawPose: Nullable<DevicePose>;
  78932. /**
  78933. * The scale of the device to be used when translating from device space to babylon space.
  78934. */
  78935. deviceScaleFactor: number;
  78936. /**
  78937. * Updates the poseControlled values based on the input device pose.
  78938. * @param poseData the pose data to update the object with
  78939. */
  78940. updateFromDevice(poseData: DevicePose): void;
  78941. }
  78942. /**
  78943. * Set of options to customize the webVRCamera
  78944. */
  78945. export interface WebVROptions {
  78946. /**
  78947. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78948. */
  78949. trackPosition?: boolean;
  78950. /**
  78951. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78952. */
  78953. positionScale?: number;
  78954. /**
  78955. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78956. */
  78957. displayName?: string;
  78958. /**
  78959. * Should the native controller meshes be initialized. (default: true)
  78960. */
  78961. controllerMeshes?: boolean;
  78962. /**
  78963. * Creating a default HemiLight only on controllers. (default: true)
  78964. */
  78965. defaultLightingOnControllers?: boolean;
  78966. /**
  78967. * If you don't want to use the default VR button of the helper. (default: false)
  78968. */
  78969. useCustomVRButton?: boolean;
  78970. /**
  78971. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78972. */
  78973. customVRButton?: HTMLButtonElement;
  78974. /**
  78975. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78976. */
  78977. rayLength?: number;
  78978. /**
  78979. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78980. */
  78981. defaultHeight?: number;
  78982. /**
  78983. * If multiview should be used if availible (default: false)
  78984. */
  78985. useMultiview?: boolean;
  78986. }
  78987. /**
  78988. * This represents a WebVR camera.
  78989. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78990. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78991. */
  78992. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78993. private webVROptions;
  78994. /**
  78995. * @hidden
  78996. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78997. */
  78998. _vrDevice: any;
  78999. /**
  79000. * The rawPose of the vrDevice.
  79001. */
  79002. rawPose: Nullable<DevicePose>;
  79003. private _onVREnabled;
  79004. private _specsVersion;
  79005. private _attached;
  79006. private _frameData;
  79007. protected _descendants: Array<Node>;
  79008. private _deviceRoomPosition;
  79009. /** @hidden */
  79010. _deviceRoomRotationQuaternion: Quaternion;
  79011. private _standingMatrix;
  79012. /**
  79013. * Represents device position in babylon space.
  79014. */
  79015. devicePosition: Vector3;
  79016. /**
  79017. * Represents device rotation in babylon space.
  79018. */
  79019. deviceRotationQuaternion: Quaternion;
  79020. /**
  79021. * The scale of the device to be used when translating from device space to babylon space.
  79022. */
  79023. deviceScaleFactor: number;
  79024. private _deviceToWorld;
  79025. private _worldToDevice;
  79026. /**
  79027. * References to the webVR controllers for the vrDevice.
  79028. */
  79029. controllers: Array<WebVRController>;
  79030. /**
  79031. * Emits an event when a controller is attached.
  79032. */
  79033. onControllersAttachedObservable: Observable<WebVRController[]>;
  79034. /**
  79035. * Emits an event when a controller's mesh has been loaded;
  79036. */
  79037. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79038. /**
  79039. * Emits an event when the HMD's pose has been updated.
  79040. */
  79041. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79042. private _poseSet;
  79043. /**
  79044. * If the rig cameras be used as parent instead of this camera.
  79045. */
  79046. rigParenting: boolean;
  79047. private _lightOnControllers;
  79048. private _defaultHeight?;
  79049. /**
  79050. * Instantiates a WebVRFreeCamera.
  79051. * @param name The name of the WebVRFreeCamera
  79052. * @param position The starting anchor position for the camera
  79053. * @param scene The scene the camera belongs to
  79054. * @param webVROptions a set of customizable options for the webVRCamera
  79055. */
  79056. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79057. /**
  79058. * Gets the device distance from the ground in meters.
  79059. * @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.
  79060. */
  79061. deviceDistanceToRoomGround(): number;
  79062. /**
  79063. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79064. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79065. */
  79066. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79067. /**
  79068. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79069. * @returns A promise with a boolean set to if the standing matrix is supported.
  79070. */
  79071. useStandingMatrixAsync(): Promise<boolean>;
  79072. /**
  79073. * Disposes the camera
  79074. */
  79075. dispose(): void;
  79076. /**
  79077. * Gets a vrController by name.
  79078. * @param name The name of the controller to retreive
  79079. * @returns the controller matching the name specified or null if not found
  79080. */
  79081. getControllerByName(name: string): Nullable<WebVRController>;
  79082. private _leftController;
  79083. /**
  79084. * The controller corresponding to the users left hand.
  79085. */
  79086. readonly leftController: Nullable<WebVRController>;
  79087. private _rightController;
  79088. /**
  79089. * The controller corresponding to the users right hand.
  79090. */
  79091. readonly rightController: Nullable<WebVRController>;
  79092. /**
  79093. * Casts a ray forward from the vrCamera's gaze.
  79094. * @param length Length of the ray (default: 100)
  79095. * @returns the ray corresponding to the gaze
  79096. */
  79097. getForwardRay(length?: number): Ray;
  79098. /**
  79099. * @hidden
  79100. * Updates the camera based on device's frame data
  79101. */
  79102. _checkInputs(): void;
  79103. /**
  79104. * Updates the poseControlled values based on the input device pose.
  79105. * @param poseData Pose coming from the device
  79106. */
  79107. updateFromDevice(poseData: DevicePose): void;
  79108. private _htmlElementAttached;
  79109. private _detachIfAttached;
  79110. /**
  79111. * WebVR's attach control will start broadcasting frames to the device.
  79112. * Note that in certain browsers (chrome for example) this function must be called
  79113. * within a user-interaction callback. Example:
  79114. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79115. *
  79116. * @param element html element to attach the vrDevice to
  79117. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79118. */
  79119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79120. /**
  79121. * Detaches the camera from the html element and disables VR
  79122. *
  79123. * @param element html element to detach from
  79124. */
  79125. detachControl(element: HTMLElement): void;
  79126. /**
  79127. * @returns the name of this class
  79128. */
  79129. getClassName(): string;
  79130. /**
  79131. * Calls resetPose on the vrDisplay
  79132. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79133. */
  79134. resetToCurrentRotation(): void;
  79135. /**
  79136. * @hidden
  79137. * Updates the rig cameras (left and right eye)
  79138. */
  79139. _updateRigCameras(): void;
  79140. private _workingVector;
  79141. private _oneVector;
  79142. private _workingMatrix;
  79143. private updateCacheCalled;
  79144. private _correctPositionIfNotTrackPosition;
  79145. /**
  79146. * @hidden
  79147. * Updates the cached values of the camera
  79148. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79149. */
  79150. _updateCache(ignoreParentClass?: boolean): void;
  79151. /**
  79152. * @hidden
  79153. * Get current device position in babylon world
  79154. */
  79155. _computeDevicePosition(): void;
  79156. /**
  79157. * Updates the current device position and rotation in the babylon world
  79158. */
  79159. update(): void;
  79160. /**
  79161. * @hidden
  79162. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79163. * @returns an identity matrix
  79164. */
  79165. _getViewMatrix(): Matrix;
  79166. private _tmpMatrix;
  79167. /**
  79168. * This function is called by the two RIG cameras.
  79169. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79170. * @hidden
  79171. */
  79172. _getWebVRViewMatrix(): Matrix;
  79173. /** @hidden */
  79174. _getWebVRProjectionMatrix(): Matrix;
  79175. private _onGamepadConnectedObserver;
  79176. private _onGamepadDisconnectedObserver;
  79177. private _updateCacheWhenTrackingDisabledObserver;
  79178. /**
  79179. * Initializes the controllers and their meshes
  79180. */
  79181. initControllers(): void;
  79182. }
  79183. }
  79184. declare module BABYLON {
  79185. /**
  79186. * Size options for a post process
  79187. */
  79188. export type PostProcessOptions = {
  79189. width: number;
  79190. height: number;
  79191. };
  79192. /**
  79193. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79194. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79195. */
  79196. export class PostProcess {
  79197. /** Name of the PostProcess. */
  79198. name: string;
  79199. /**
  79200. * Gets or sets the unique id of the post process
  79201. */
  79202. uniqueId: number;
  79203. /**
  79204. * Width of the texture to apply the post process on
  79205. */
  79206. width: number;
  79207. /**
  79208. * Height of the texture to apply the post process on
  79209. */
  79210. height: number;
  79211. /**
  79212. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79213. * @hidden
  79214. */
  79215. _outputTexture: Nullable<InternalTexture>;
  79216. /**
  79217. * Sampling mode used by the shader
  79218. * See https://doc.babylonjs.com/classes/3.1/texture
  79219. */
  79220. renderTargetSamplingMode: number;
  79221. /**
  79222. * Clear color to use when screen clearing
  79223. */
  79224. clearColor: Color4;
  79225. /**
  79226. * If the buffer needs to be cleared before applying the post process. (default: true)
  79227. * Should be set to false if shader will overwrite all previous pixels.
  79228. */
  79229. autoClear: boolean;
  79230. /**
  79231. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79232. */
  79233. alphaMode: number;
  79234. /**
  79235. * Sets the setAlphaBlendConstants of the babylon engine
  79236. */
  79237. alphaConstants: Color4;
  79238. /**
  79239. * Animations to be used for the post processing
  79240. */
  79241. animations: Animation[];
  79242. /**
  79243. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79244. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79245. */
  79246. enablePixelPerfectMode: boolean;
  79247. /**
  79248. * Force the postprocess to be applied without taking in account viewport
  79249. */
  79250. forceFullscreenViewport: boolean;
  79251. /**
  79252. * List of inspectable custom properties (used by the Inspector)
  79253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79254. */
  79255. inspectableCustomProperties: IInspectable[];
  79256. /**
  79257. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79258. *
  79259. * | Value | Type | Description |
  79260. * | ----- | ----------------------------------- | ----------- |
  79261. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79262. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79263. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79264. *
  79265. */
  79266. scaleMode: number;
  79267. /**
  79268. * Force textures to be a power of two (default: false)
  79269. */
  79270. alwaysForcePOT: boolean;
  79271. private _samples;
  79272. /**
  79273. * Number of sample textures (default: 1)
  79274. */
  79275. samples: number;
  79276. /**
  79277. * Modify the scale of the post process to be the same as the viewport (default: false)
  79278. */
  79279. adaptScaleToCurrentViewport: boolean;
  79280. private _camera;
  79281. private _scene;
  79282. private _engine;
  79283. private _options;
  79284. private _reusable;
  79285. private _textureType;
  79286. /**
  79287. * Smart array of input and output textures for the post process.
  79288. * @hidden
  79289. */
  79290. _textures: SmartArray<InternalTexture>;
  79291. /**
  79292. * The index in _textures that corresponds to the output texture.
  79293. * @hidden
  79294. */
  79295. _currentRenderTextureInd: number;
  79296. private _effect;
  79297. private _samplers;
  79298. private _fragmentUrl;
  79299. private _vertexUrl;
  79300. private _parameters;
  79301. private _scaleRatio;
  79302. protected _indexParameters: any;
  79303. private _shareOutputWithPostProcess;
  79304. private _texelSize;
  79305. private _forcedOutputTexture;
  79306. /**
  79307. * Returns the fragment url or shader name used in the post process.
  79308. * @returns the fragment url or name in the shader store.
  79309. */
  79310. getEffectName(): string;
  79311. /**
  79312. * An event triggered when the postprocess is activated.
  79313. */
  79314. onActivateObservable: Observable<Camera>;
  79315. private _onActivateObserver;
  79316. /**
  79317. * A function that is added to the onActivateObservable
  79318. */
  79319. onActivate: Nullable<(camera: Camera) => void>;
  79320. /**
  79321. * An event triggered when the postprocess changes its size.
  79322. */
  79323. onSizeChangedObservable: Observable<PostProcess>;
  79324. private _onSizeChangedObserver;
  79325. /**
  79326. * A function that is added to the onSizeChangedObservable
  79327. */
  79328. onSizeChanged: (postProcess: PostProcess) => void;
  79329. /**
  79330. * An event triggered when the postprocess applies its effect.
  79331. */
  79332. onApplyObservable: Observable<Effect>;
  79333. private _onApplyObserver;
  79334. /**
  79335. * A function that is added to the onApplyObservable
  79336. */
  79337. onApply: (effect: Effect) => void;
  79338. /**
  79339. * An event triggered before rendering the postprocess
  79340. */
  79341. onBeforeRenderObservable: Observable<Effect>;
  79342. private _onBeforeRenderObserver;
  79343. /**
  79344. * A function that is added to the onBeforeRenderObservable
  79345. */
  79346. onBeforeRender: (effect: Effect) => void;
  79347. /**
  79348. * An event triggered after rendering the postprocess
  79349. */
  79350. onAfterRenderObservable: Observable<Effect>;
  79351. private _onAfterRenderObserver;
  79352. /**
  79353. * A function that is added to the onAfterRenderObservable
  79354. */
  79355. onAfterRender: (efect: Effect) => void;
  79356. /**
  79357. * 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
  79358. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79359. */
  79360. inputTexture: InternalTexture;
  79361. /**
  79362. * Gets the camera which post process is applied to.
  79363. * @returns The camera the post process is applied to.
  79364. */
  79365. getCamera(): Camera;
  79366. /**
  79367. * Gets the texel size of the postprocess.
  79368. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79369. */
  79370. readonly texelSize: Vector2;
  79371. /**
  79372. * Creates a new instance PostProcess
  79373. * @param name The name of the PostProcess.
  79374. * @param fragmentUrl The url of the fragment shader to be used.
  79375. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79376. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79377. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79378. * @param camera The camera to apply the render pass to.
  79379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79380. * @param engine The engine which the post process will be applied. (default: current engine)
  79381. * @param reusable If the post process can be reused on the same frame. (default: false)
  79382. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79383. * @param textureType Type of textures used when performing the post process. (default: 0)
  79384. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79385. * @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
  79386. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79387. */
  79388. constructor(
  79389. /** Name of the PostProcess. */
  79390. 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);
  79391. /**
  79392. * Gets a string idenfifying the name of the class
  79393. * @returns "PostProcess" string
  79394. */
  79395. getClassName(): string;
  79396. /**
  79397. * Gets the engine which this post process belongs to.
  79398. * @returns The engine the post process was enabled with.
  79399. */
  79400. getEngine(): Engine;
  79401. /**
  79402. * The effect that is created when initializing the post process.
  79403. * @returns The created effect corresponding the the postprocess.
  79404. */
  79405. getEffect(): Effect;
  79406. /**
  79407. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79408. * @param postProcess The post process to share the output with.
  79409. * @returns This post process.
  79410. */
  79411. shareOutputWith(postProcess: PostProcess): PostProcess;
  79412. /**
  79413. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79414. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79415. */
  79416. useOwnOutput(): void;
  79417. /**
  79418. * Updates the effect with the current post process compile time values and recompiles the shader.
  79419. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79420. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79421. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79422. * @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
  79423. * @param onCompiled Called when the shader has been compiled.
  79424. * @param onError Called if there is an error when compiling a shader.
  79425. */
  79426. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79427. /**
  79428. * The post process is reusable if it can be used multiple times within one frame.
  79429. * @returns If the post process is reusable
  79430. */
  79431. isReusable(): boolean;
  79432. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79433. markTextureDirty(): void;
  79434. /**
  79435. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79436. * 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.
  79437. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79438. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79439. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79440. * @returns The target texture that was bound to be written to.
  79441. */
  79442. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79443. /**
  79444. * If the post process is supported.
  79445. */
  79446. readonly isSupported: boolean;
  79447. /**
  79448. * The aspect ratio of the output texture.
  79449. */
  79450. readonly aspectRatio: number;
  79451. /**
  79452. * Get a value indicating if the post-process is ready to be used
  79453. * @returns true if the post-process is ready (shader is compiled)
  79454. */
  79455. isReady(): boolean;
  79456. /**
  79457. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79458. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79459. */
  79460. apply(): Nullable<Effect>;
  79461. private _disposeTextures;
  79462. /**
  79463. * Disposes the post process.
  79464. * @param camera The camera to dispose the post process on.
  79465. */
  79466. dispose(camera?: Camera): void;
  79467. }
  79468. }
  79469. declare module BABYLON {
  79470. /** @hidden */
  79471. export var kernelBlurVaryingDeclaration: {
  79472. name: string;
  79473. shader: string;
  79474. };
  79475. }
  79476. declare module BABYLON {
  79477. /** @hidden */
  79478. export var kernelBlurFragment: {
  79479. name: string;
  79480. shader: string;
  79481. };
  79482. }
  79483. declare module BABYLON {
  79484. /** @hidden */
  79485. export var kernelBlurFragment2: {
  79486. name: string;
  79487. shader: string;
  79488. };
  79489. }
  79490. declare module BABYLON {
  79491. /** @hidden */
  79492. export var kernelBlurPixelShader: {
  79493. name: string;
  79494. shader: string;
  79495. };
  79496. }
  79497. declare module BABYLON {
  79498. /** @hidden */
  79499. export var kernelBlurVertex: {
  79500. name: string;
  79501. shader: string;
  79502. };
  79503. }
  79504. declare module BABYLON {
  79505. /** @hidden */
  79506. export var kernelBlurVertexShader: {
  79507. name: string;
  79508. shader: string;
  79509. };
  79510. }
  79511. declare module BABYLON {
  79512. /**
  79513. * The Blur Post Process which blurs an image based on a kernel and direction.
  79514. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79515. */
  79516. export class BlurPostProcess extends PostProcess {
  79517. /** The direction in which to blur the image. */
  79518. direction: Vector2;
  79519. private blockCompilation;
  79520. protected _kernel: number;
  79521. protected _idealKernel: number;
  79522. protected _packedFloat: boolean;
  79523. private _staticDefines;
  79524. /**
  79525. * Sets the length in pixels of the blur sample region
  79526. */
  79527. /**
  79528. * Gets the length in pixels of the blur sample region
  79529. */
  79530. kernel: number;
  79531. /**
  79532. * Sets wether or not the blur needs to unpack/repack floats
  79533. */
  79534. /**
  79535. * Gets wether or not the blur is unpacking/repacking floats
  79536. */
  79537. packedFloat: boolean;
  79538. /**
  79539. * Creates a new instance BlurPostProcess
  79540. * @param name The name of the effect.
  79541. * @param direction The direction in which to blur the image.
  79542. * @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.
  79543. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79544. * @param camera The camera to apply the render pass to.
  79545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79546. * @param engine The engine which the post process will be applied. (default: current engine)
  79547. * @param reusable If the post process can be reused on the same frame. (default: false)
  79548. * @param textureType Type of textures used when performing the post process. (default: 0)
  79549. * @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)
  79550. */
  79551. constructor(name: string,
  79552. /** The direction in which to blur the image. */
  79553. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79554. /**
  79555. * Updates the effect with the current post process compile time values and recompiles the shader.
  79556. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79557. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79558. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79559. * @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
  79560. * @param onCompiled Called when the shader has been compiled.
  79561. * @param onError Called if there is an error when compiling a shader.
  79562. */
  79563. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79564. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79565. /**
  79566. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79567. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79568. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79569. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79570. * The gaps between physical kernels are compensated for in the weighting of the samples
  79571. * @param idealKernel Ideal blur kernel.
  79572. * @return Nearest best kernel.
  79573. */
  79574. protected _nearestBestKernel(idealKernel: number): number;
  79575. /**
  79576. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79577. * @param x The point on the Gaussian distribution to sample.
  79578. * @return the value of the Gaussian function at x.
  79579. */
  79580. protected _gaussianWeight(x: number): number;
  79581. /**
  79582. * Generates a string that can be used as a floating point number in GLSL.
  79583. * @param x Value to print.
  79584. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79585. * @return GLSL float string.
  79586. */
  79587. protected _glslFloat(x: number, decimalFigures?: number): string;
  79588. }
  79589. }
  79590. declare module BABYLON {
  79591. /**
  79592. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79593. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79594. * You can then easily use it as a reflectionTexture on a flat surface.
  79595. * In case the surface is not a plane, please consider relying on reflection probes.
  79596. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79597. */
  79598. export class MirrorTexture extends RenderTargetTexture {
  79599. private scene;
  79600. /**
  79601. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79602. * 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.
  79603. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79604. */
  79605. mirrorPlane: Plane;
  79606. /**
  79607. * Define the blur ratio used to blur the reflection if needed.
  79608. */
  79609. blurRatio: number;
  79610. /**
  79611. * Define the adaptive blur kernel used to blur the reflection if needed.
  79612. * This will autocompute the closest best match for the `blurKernel`
  79613. */
  79614. adaptiveBlurKernel: number;
  79615. /**
  79616. * Define the blur kernel used to blur the reflection if needed.
  79617. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79618. */
  79619. blurKernel: number;
  79620. /**
  79621. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79622. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79623. */
  79624. blurKernelX: number;
  79625. /**
  79626. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79627. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79628. */
  79629. blurKernelY: number;
  79630. private _autoComputeBlurKernel;
  79631. protected _onRatioRescale(): void;
  79632. private _updateGammaSpace;
  79633. private _imageProcessingConfigChangeObserver;
  79634. private _transformMatrix;
  79635. private _mirrorMatrix;
  79636. private _savedViewMatrix;
  79637. private _blurX;
  79638. private _blurY;
  79639. private _adaptiveBlurKernel;
  79640. private _blurKernelX;
  79641. private _blurKernelY;
  79642. private _blurRatio;
  79643. /**
  79644. * Instantiates a Mirror Texture.
  79645. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79646. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79647. * You can then easily use it as a reflectionTexture on a flat surface.
  79648. * In case the surface is not a plane, please consider relying on reflection probes.
  79649. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79650. * @param name
  79651. * @param size
  79652. * @param scene
  79653. * @param generateMipMaps
  79654. * @param type
  79655. * @param samplingMode
  79656. * @param generateDepthBuffer
  79657. */
  79658. constructor(name: string, size: number | {
  79659. width: number;
  79660. height: number;
  79661. } | {
  79662. ratio: number;
  79663. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79664. private _preparePostProcesses;
  79665. /**
  79666. * Clone the mirror texture.
  79667. * @returns the cloned texture
  79668. */
  79669. clone(): MirrorTexture;
  79670. /**
  79671. * Serialize the texture to a JSON representation you could use in Parse later on
  79672. * @returns the serialized JSON representation
  79673. */
  79674. serialize(): any;
  79675. /**
  79676. * Dispose the texture and release its associated resources.
  79677. */
  79678. dispose(): void;
  79679. }
  79680. }
  79681. declare module BABYLON {
  79682. /**
  79683. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79684. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79685. */
  79686. export class Texture extends BaseTexture {
  79687. /** @hidden */
  79688. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79689. /** @hidden */
  79690. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79691. /** @hidden */
  79692. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79693. /** nearest is mag = nearest and min = nearest and mip = linear */
  79694. static readonly NEAREST_SAMPLINGMODE: number;
  79695. /** nearest is mag = nearest and min = nearest and mip = linear */
  79696. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79697. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79698. static readonly BILINEAR_SAMPLINGMODE: number;
  79699. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79700. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79701. /** Trilinear is mag = linear and min = linear and mip = linear */
  79702. static readonly TRILINEAR_SAMPLINGMODE: number;
  79703. /** Trilinear is mag = linear and min = linear and mip = linear */
  79704. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79705. /** mag = nearest and min = nearest and mip = nearest */
  79706. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79707. /** mag = nearest and min = linear and mip = nearest */
  79708. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79709. /** mag = nearest and min = linear and mip = linear */
  79710. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79711. /** mag = nearest and min = linear and mip = none */
  79712. static readonly NEAREST_LINEAR: number;
  79713. /** mag = nearest and min = nearest and mip = none */
  79714. static readonly NEAREST_NEAREST: number;
  79715. /** mag = linear and min = nearest and mip = nearest */
  79716. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79717. /** mag = linear and min = nearest and mip = linear */
  79718. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79719. /** mag = linear and min = linear and mip = none */
  79720. static readonly LINEAR_LINEAR: number;
  79721. /** mag = linear and min = nearest and mip = none */
  79722. static readonly LINEAR_NEAREST: number;
  79723. /** Explicit coordinates mode */
  79724. static readonly EXPLICIT_MODE: number;
  79725. /** Spherical coordinates mode */
  79726. static readonly SPHERICAL_MODE: number;
  79727. /** Planar coordinates mode */
  79728. static readonly PLANAR_MODE: number;
  79729. /** Cubic coordinates mode */
  79730. static readonly CUBIC_MODE: number;
  79731. /** Projection coordinates mode */
  79732. static readonly PROJECTION_MODE: number;
  79733. /** Inverse Cubic coordinates mode */
  79734. static readonly SKYBOX_MODE: number;
  79735. /** Inverse Cubic coordinates mode */
  79736. static readonly INVCUBIC_MODE: number;
  79737. /** Equirectangular coordinates mode */
  79738. static readonly EQUIRECTANGULAR_MODE: number;
  79739. /** Equirectangular Fixed coordinates mode */
  79740. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79741. /** Equirectangular Fixed Mirrored coordinates mode */
  79742. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79743. /** Texture is not repeating outside of 0..1 UVs */
  79744. static readonly CLAMP_ADDRESSMODE: number;
  79745. /** Texture is repeating outside of 0..1 UVs */
  79746. static readonly WRAP_ADDRESSMODE: number;
  79747. /** Texture is repeating and mirrored */
  79748. static readonly MIRROR_ADDRESSMODE: number;
  79749. /**
  79750. * 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
  79751. */
  79752. static UseSerializedUrlIfAny: boolean;
  79753. /**
  79754. * Define the url of the texture.
  79755. */
  79756. url: Nullable<string>;
  79757. /**
  79758. * Define an offset on the texture to offset the u coordinates of the UVs
  79759. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79760. */
  79761. uOffset: number;
  79762. /**
  79763. * Define an offset on the texture to offset the v coordinates of the UVs
  79764. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79765. */
  79766. vOffset: number;
  79767. /**
  79768. * Define an offset on the texture to scale the u coordinates of the UVs
  79769. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79770. */
  79771. uScale: number;
  79772. /**
  79773. * Define an offset on the texture to scale the v coordinates of the UVs
  79774. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79775. */
  79776. vScale: number;
  79777. /**
  79778. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79779. * @see http://doc.babylonjs.com/how_to/more_materials
  79780. */
  79781. uAng: number;
  79782. /**
  79783. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79784. * @see http://doc.babylonjs.com/how_to/more_materials
  79785. */
  79786. vAng: number;
  79787. /**
  79788. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79789. * @see http://doc.babylonjs.com/how_to/more_materials
  79790. */
  79791. wAng: number;
  79792. /**
  79793. * Defines the center of rotation (U)
  79794. */
  79795. uRotationCenter: number;
  79796. /**
  79797. * Defines the center of rotation (V)
  79798. */
  79799. vRotationCenter: number;
  79800. /**
  79801. * Defines the center of rotation (W)
  79802. */
  79803. wRotationCenter: number;
  79804. /**
  79805. * Are mip maps generated for this texture or not.
  79806. */
  79807. readonly noMipmap: boolean;
  79808. /**
  79809. * List of inspectable custom properties (used by the Inspector)
  79810. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79811. */
  79812. inspectableCustomProperties: Nullable<IInspectable[]>;
  79813. private _noMipmap;
  79814. /** @hidden */
  79815. _invertY: boolean;
  79816. private _rowGenerationMatrix;
  79817. private _cachedTextureMatrix;
  79818. private _projectionModeMatrix;
  79819. private _t0;
  79820. private _t1;
  79821. private _t2;
  79822. private _cachedUOffset;
  79823. private _cachedVOffset;
  79824. private _cachedUScale;
  79825. private _cachedVScale;
  79826. private _cachedUAng;
  79827. private _cachedVAng;
  79828. private _cachedWAng;
  79829. private _cachedProjectionMatrixId;
  79830. private _cachedCoordinatesMode;
  79831. /** @hidden */
  79832. protected _initialSamplingMode: number;
  79833. /** @hidden */
  79834. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79835. private _deleteBuffer;
  79836. protected _format: Nullable<number>;
  79837. private _delayedOnLoad;
  79838. private _delayedOnError;
  79839. /**
  79840. * Observable triggered once the texture has been loaded.
  79841. */
  79842. onLoadObservable: Observable<Texture>;
  79843. protected _isBlocking: boolean;
  79844. /**
  79845. * Is the texture preventing material to render while loading.
  79846. * If false, a default texture will be used instead of the loading one during the preparation step.
  79847. */
  79848. isBlocking: boolean;
  79849. /**
  79850. * Get the current sampling mode associated with the texture.
  79851. */
  79852. readonly samplingMode: number;
  79853. /**
  79854. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79855. */
  79856. readonly invertY: boolean;
  79857. /**
  79858. * Instantiates a new texture.
  79859. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79860. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79861. * @param url define the url of the picture to load as a texture
  79862. * @param scene define the scene or engine the texture will belong to
  79863. * @param noMipmap define if the texture will require mip maps or not
  79864. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79865. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79866. * @param onLoad define a callback triggered when the texture has been loaded
  79867. * @param onError define a callback triggered when an error occurred during the loading session
  79868. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79869. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79870. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79871. */
  79872. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  79873. /**
  79874. * Update the url (and optional buffer) of this texture if url was null during construction.
  79875. * @param url the url of the texture
  79876. * @param buffer the buffer of the texture (defaults to null)
  79877. * @param onLoad callback called when the texture is loaded (defaults to null)
  79878. */
  79879. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79880. /**
  79881. * Finish the loading sequence of a texture flagged as delayed load.
  79882. * @hidden
  79883. */
  79884. delayLoad(): void;
  79885. private _prepareRowForTextureGeneration;
  79886. /**
  79887. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79888. * @returns the transform matrix of the texture.
  79889. */
  79890. getTextureMatrix(): Matrix;
  79891. /**
  79892. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79893. * @returns The reflection texture transform
  79894. */
  79895. getReflectionTextureMatrix(): Matrix;
  79896. /**
  79897. * Clones the texture.
  79898. * @returns the cloned texture
  79899. */
  79900. clone(): Texture;
  79901. /**
  79902. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79903. * @returns The JSON representation of the texture
  79904. */
  79905. serialize(): any;
  79906. /**
  79907. * Get the current class name of the texture useful for serialization or dynamic coding.
  79908. * @returns "Texture"
  79909. */
  79910. getClassName(): string;
  79911. /**
  79912. * Dispose the texture and release its associated resources.
  79913. */
  79914. dispose(): void;
  79915. /**
  79916. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79917. * @param parsedTexture Define the JSON representation of the texture
  79918. * @param scene Define the scene the parsed texture should be instantiated in
  79919. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79920. * @returns The parsed texture if successful
  79921. */
  79922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79923. /**
  79924. * Creates a texture from its base 64 representation.
  79925. * @param data Define the base64 payload without the data: prefix
  79926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79927. * @param scene Define the scene the texture should belong to
  79928. * @param noMipmap Forces the texture to not create mip map information if true
  79929. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79930. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79931. * @param onLoad define a callback triggered when the texture has been loaded
  79932. * @param onError define a callback triggered when an error occurred during the loading session
  79933. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79934. * @returns the created texture
  79935. */
  79936. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79937. /**
  79938. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79939. * @param data Define the base64 payload without the data: prefix
  79940. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79941. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79942. * @param scene Define the scene the texture should belong to
  79943. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79944. * @param noMipmap Forces the texture to not create mip map information if true
  79945. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79946. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79947. * @param onLoad define a callback triggered when the texture has been loaded
  79948. * @param onError define a callback triggered when an error occurred during the loading session
  79949. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79950. * @returns the created texture
  79951. */
  79952. 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;
  79953. }
  79954. }
  79955. declare module BABYLON {
  79956. /**
  79957. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79958. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79959. */
  79960. export class PostProcessManager {
  79961. private _scene;
  79962. private _indexBuffer;
  79963. private _vertexBuffers;
  79964. /**
  79965. * Creates a new instance PostProcess
  79966. * @param scene The scene that the post process is associated with.
  79967. */
  79968. constructor(scene: Scene);
  79969. private _prepareBuffers;
  79970. private _buildIndexBuffer;
  79971. /**
  79972. * Rebuilds the vertex buffers of the manager.
  79973. * @hidden
  79974. */
  79975. _rebuild(): void;
  79976. /**
  79977. * Prepares a frame to be run through a post process.
  79978. * @param sourceTexture The input texture to the post procesess. (default: null)
  79979. * @param postProcesses An array of post processes to be run. (default: null)
  79980. * @returns True if the post processes were able to be run.
  79981. * @hidden
  79982. */
  79983. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79984. /**
  79985. * Manually render a set of post processes to a texture.
  79986. * @param postProcesses An array of post processes to be run.
  79987. * @param targetTexture The target texture to render to.
  79988. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79989. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79990. * @param lodLevel defines which lod of the texture to render to
  79991. */
  79992. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79993. /**
  79994. * Finalize the result of the output of the postprocesses.
  79995. * @param doNotPresent If true the result will not be displayed to the screen.
  79996. * @param targetTexture The target texture to render to.
  79997. * @param faceIndex The index of the face to bind the target texture to.
  79998. * @param postProcesses The array of post processes to render.
  79999. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80000. * @hidden
  80001. */
  80002. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80003. /**
  80004. * Disposes of the post process manager.
  80005. */
  80006. dispose(): void;
  80007. }
  80008. }
  80009. declare module BABYLON {
  80010. /** Interface used by value gradients (color, factor, ...) */
  80011. export interface IValueGradient {
  80012. /**
  80013. * Gets or sets the gradient value (between 0 and 1)
  80014. */
  80015. gradient: number;
  80016. }
  80017. /** Class used to store color4 gradient */
  80018. export class ColorGradient implements IValueGradient {
  80019. /**
  80020. * Gets or sets the gradient value (between 0 and 1)
  80021. */
  80022. gradient: number;
  80023. /**
  80024. * Gets or sets first associated color
  80025. */
  80026. color1: Color4;
  80027. /**
  80028. * Gets or sets second associated color
  80029. */
  80030. color2?: Color4;
  80031. /**
  80032. * Will get a color picked randomly between color1 and color2.
  80033. * If color2 is undefined then color1 will be used
  80034. * @param result defines the target Color4 to store the result in
  80035. */
  80036. getColorToRef(result: Color4): void;
  80037. }
  80038. /** Class used to store color 3 gradient */
  80039. export class Color3Gradient implements IValueGradient {
  80040. /**
  80041. * Gets or sets the gradient value (between 0 and 1)
  80042. */
  80043. gradient: number;
  80044. /**
  80045. * Gets or sets the associated color
  80046. */
  80047. color: Color3;
  80048. }
  80049. /** Class used to store factor gradient */
  80050. export class FactorGradient implements IValueGradient {
  80051. /**
  80052. * Gets or sets the gradient value (between 0 and 1)
  80053. */
  80054. gradient: number;
  80055. /**
  80056. * Gets or sets first associated factor
  80057. */
  80058. factor1: number;
  80059. /**
  80060. * Gets or sets second associated factor
  80061. */
  80062. factor2?: number;
  80063. /**
  80064. * Will get a number picked randomly between factor1 and factor2.
  80065. * If factor2 is undefined then factor1 will be used
  80066. * @returns the picked number
  80067. */
  80068. getFactor(): number;
  80069. }
  80070. /**
  80071. * Helper used to simplify some generic gradient tasks
  80072. */
  80073. export class GradientHelper {
  80074. /**
  80075. * Gets the current gradient from an array of IValueGradient
  80076. * @param ratio defines the current ratio to get
  80077. * @param gradients defines the array of IValueGradient
  80078. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80079. */
  80080. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80081. }
  80082. }
  80083. declare module BABYLON {
  80084. interface AbstractScene {
  80085. /**
  80086. * The list of procedural textures added to the scene
  80087. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80088. */
  80089. proceduralTextures: Array<ProceduralTexture>;
  80090. }
  80091. /**
  80092. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80093. * in a given scene.
  80094. */
  80095. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80096. /**
  80097. * The component name helpfull to identify the component in the list of scene components.
  80098. */
  80099. readonly name: string;
  80100. /**
  80101. * The scene the component belongs to.
  80102. */
  80103. scene: Scene;
  80104. /**
  80105. * Creates a new instance of the component for the given scene
  80106. * @param scene Defines the scene to register the component in
  80107. */
  80108. constructor(scene: Scene);
  80109. /**
  80110. * Registers the component in a given scene
  80111. */
  80112. register(): void;
  80113. /**
  80114. * Rebuilds the elements related to this component in case of
  80115. * context lost for instance.
  80116. */
  80117. rebuild(): void;
  80118. /**
  80119. * Disposes the component and the associated ressources.
  80120. */
  80121. dispose(): void;
  80122. private _beforeClear;
  80123. }
  80124. }
  80125. declare module BABYLON {
  80126. interface Engine {
  80127. /**
  80128. * Creates a new render target cube texture
  80129. * @param size defines the size of the texture
  80130. * @param options defines the options used to create the texture
  80131. * @returns a new render target cube texture stored in an InternalTexture
  80132. */
  80133. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80134. }
  80135. }
  80136. declare module BABYLON {
  80137. /** @hidden */
  80138. export var proceduralVertexShader: {
  80139. name: string;
  80140. shader: string;
  80141. };
  80142. }
  80143. declare module BABYLON {
  80144. /**
  80145. * 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.
  80146. * This is the base class of any Procedural texture and contains most of the shareable code.
  80147. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80148. */
  80149. export class ProceduralTexture extends Texture {
  80150. isCube: boolean;
  80151. /**
  80152. * Define if the texture is enabled or not (disabled texture will not render)
  80153. */
  80154. isEnabled: boolean;
  80155. /**
  80156. * Define if the texture must be cleared before rendering (default is true)
  80157. */
  80158. autoClear: boolean;
  80159. /**
  80160. * Callback called when the texture is generated
  80161. */
  80162. onGenerated: () => void;
  80163. /**
  80164. * Event raised when the texture is generated
  80165. */
  80166. onGeneratedObservable: Observable<ProceduralTexture>;
  80167. /** @hidden */
  80168. _generateMipMaps: boolean;
  80169. /** @hidden **/
  80170. _effect: Effect;
  80171. /** @hidden */
  80172. _textures: {
  80173. [key: string]: Texture;
  80174. };
  80175. private _size;
  80176. private _currentRefreshId;
  80177. private _refreshRate;
  80178. private _vertexBuffers;
  80179. private _indexBuffer;
  80180. private _uniforms;
  80181. private _samplers;
  80182. private _fragment;
  80183. private _floats;
  80184. private _ints;
  80185. private _floatsArrays;
  80186. private _colors3;
  80187. private _colors4;
  80188. private _vectors2;
  80189. private _vectors3;
  80190. private _matrices;
  80191. private _fallbackTexture;
  80192. private _fallbackTextureUsed;
  80193. private _engine;
  80194. private _cachedDefines;
  80195. private _contentUpdateId;
  80196. private _contentData;
  80197. /**
  80198. * Instantiates a new procedural texture.
  80199. * 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.
  80200. * This is the base class of any Procedural texture and contains most of the shareable code.
  80201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80202. * @param name Define the name of the texture
  80203. * @param size Define the size of the texture to create
  80204. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80205. * @param scene Define the scene the texture belongs to
  80206. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80207. * @param generateMipMaps Define if the texture should creates mip maps or not
  80208. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80209. */
  80210. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80211. /**
  80212. * The effect that is created when initializing the post process.
  80213. * @returns The created effect corresponding the the postprocess.
  80214. */
  80215. getEffect(): Effect;
  80216. /**
  80217. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80218. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80219. */
  80220. getContent(): Nullable<ArrayBufferView>;
  80221. private _createIndexBuffer;
  80222. /** @hidden */
  80223. _rebuild(): void;
  80224. /**
  80225. * Resets the texture in order to recreate its associated resources.
  80226. * This can be called in case of context loss
  80227. */
  80228. reset(): void;
  80229. protected _getDefines(): string;
  80230. /**
  80231. * Is the texture ready to be used ? (rendered at least once)
  80232. * @returns true if ready, otherwise, false.
  80233. */
  80234. isReady(): boolean;
  80235. /**
  80236. * Resets the refresh counter of the texture and start bak from scratch.
  80237. * Could be useful to regenerate the texture if it is setup to render only once.
  80238. */
  80239. resetRefreshCounter(): void;
  80240. /**
  80241. * Set the fragment shader to use in order to render the texture.
  80242. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80243. */
  80244. setFragment(fragment: any): void;
  80245. /**
  80246. * Define the refresh rate of the texture or the rendering frequency.
  80247. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80248. */
  80249. refreshRate: number;
  80250. /** @hidden */
  80251. _shouldRender(): boolean;
  80252. /**
  80253. * Get the size the texture is rendering at.
  80254. * @returns the size (texture is always squared)
  80255. */
  80256. getRenderSize(): number;
  80257. /**
  80258. * Resize the texture to new value.
  80259. * @param size Define the new size the texture should have
  80260. * @param generateMipMaps Define whether the new texture should create mip maps
  80261. */
  80262. resize(size: number, generateMipMaps: boolean): void;
  80263. private _checkUniform;
  80264. /**
  80265. * Set a texture in the shader program used to render.
  80266. * @param name Define the name of the uniform samplers as defined in the shader
  80267. * @param texture Define the texture to bind to this sampler
  80268. * @return the texture itself allowing "fluent" like uniform updates
  80269. */
  80270. setTexture(name: string, texture: Texture): ProceduralTexture;
  80271. /**
  80272. * Set a float in the shader.
  80273. * @param name Define the name of the uniform as defined in the shader
  80274. * @param value Define the value to give to the uniform
  80275. * @return the texture itself allowing "fluent" like uniform updates
  80276. */
  80277. setFloat(name: string, value: number): ProceduralTexture;
  80278. /**
  80279. * Set a int in the shader.
  80280. * @param name Define the name of the uniform as defined in the shader
  80281. * @param value Define the value to give to the uniform
  80282. * @return the texture itself allowing "fluent" like uniform updates
  80283. */
  80284. setInt(name: string, value: number): ProceduralTexture;
  80285. /**
  80286. * Set an array of floats in the shader.
  80287. * @param name Define the name of the uniform as defined in the shader
  80288. * @param value Define the value to give to the uniform
  80289. * @return the texture itself allowing "fluent" like uniform updates
  80290. */
  80291. setFloats(name: string, value: number[]): ProceduralTexture;
  80292. /**
  80293. * Set a vec3 in the shader from a Color3.
  80294. * @param name Define the name of the uniform as defined in the shader
  80295. * @param value Define the value to give to the uniform
  80296. * @return the texture itself allowing "fluent" like uniform updates
  80297. */
  80298. setColor3(name: string, value: Color3): ProceduralTexture;
  80299. /**
  80300. * Set a vec4 in the shader from a Color4.
  80301. * @param name Define the name of the uniform as defined in the shader
  80302. * @param value Define the value to give to the uniform
  80303. * @return the texture itself allowing "fluent" like uniform updates
  80304. */
  80305. setColor4(name: string, value: Color4): ProceduralTexture;
  80306. /**
  80307. * Set a vec2 in the shader from a Vector2.
  80308. * @param name Define the name of the uniform as defined in the shader
  80309. * @param value Define the value to give to the uniform
  80310. * @return the texture itself allowing "fluent" like uniform updates
  80311. */
  80312. setVector2(name: string, value: Vector2): ProceduralTexture;
  80313. /**
  80314. * Set a vec3 in the shader from a Vector3.
  80315. * @param name Define the name of the uniform as defined in the shader
  80316. * @param value Define the value to give to the uniform
  80317. * @return the texture itself allowing "fluent" like uniform updates
  80318. */
  80319. setVector3(name: string, value: Vector3): ProceduralTexture;
  80320. /**
  80321. * Set a mat4 in the shader from a MAtrix.
  80322. * @param name Define the name of the uniform as defined in the shader
  80323. * @param value Define the value to give to the uniform
  80324. * @return the texture itself allowing "fluent" like uniform updates
  80325. */
  80326. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80327. /**
  80328. * Render the texture to its associated render target.
  80329. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80330. */
  80331. render(useCameraPostProcess?: boolean): void;
  80332. /**
  80333. * Clone the texture.
  80334. * @returns the cloned texture
  80335. */
  80336. clone(): ProceduralTexture;
  80337. /**
  80338. * Dispose the texture and release its asoociated resources.
  80339. */
  80340. dispose(): void;
  80341. }
  80342. }
  80343. declare module BABYLON {
  80344. /**
  80345. * This represents the base class for particle system in Babylon.
  80346. * 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.
  80347. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80348. * @example https://doc.babylonjs.com/babylon101/particles
  80349. */
  80350. export class BaseParticleSystem {
  80351. /**
  80352. * Source color is added to the destination color without alpha affecting the result
  80353. */
  80354. static BLENDMODE_ONEONE: number;
  80355. /**
  80356. * Blend current color and particle color using particle’s alpha
  80357. */
  80358. static BLENDMODE_STANDARD: number;
  80359. /**
  80360. * Add current color and particle color multiplied by particle’s alpha
  80361. */
  80362. static BLENDMODE_ADD: number;
  80363. /**
  80364. * Multiply current color with particle color
  80365. */
  80366. static BLENDMODE_MULTIPLY: number;
  80367. /**
  80368. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80369. */
  80370. static BLENDMODE_MULTIPLYADD: number;
  80371. /**
  80372. * List of animations used by the particle system.
  80373. */
  80374. animations: Animation[];
  80375. /**
  80376. * The id of the Particle system.
  80377. */
  80378. id: string;
  80379. /**
  80380. * The friendly name of the Particle system.
  80381. */
  80382. name: string;
  80383. /**
  80384. * The rendering group used by the Particle system to chose when to render.
  80385. */
  80386. renderingGroupId: number;
  80387. /**
  80388. * The emitter represents the Mesh or position we are attaching the particle system to.
  80389. */
  80390. emitter: Nullable<AbstractMesh | Vector3>;
  80391. /**
  80392. * The maximum number of particles to emit per frame
  80393. */
  80394. emitRate: number;
  80395. /**
  80396. * If you want to launch only a few particles at once, that can be done, as well.
  80397. */
  80398. manualEmitCount: number;
  80399. /**
  80400. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80401. */
  80402. updateSpeed: number;
  80403. /**
  80404. * The amount of time the particle system is running (depends of the overall update speed).
  80405. */
  80406. targetStopDuration: number;
  80407. /**
  80408. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80409. */
  80410. disposeOnStop: boolean;
  80411. /**
  80412. * Minimum power of emitting particles.
  80413. */
  80414. minEmitPower: number;
  80415. /**
  80416. * Maximum power of emitting particles.
  80417. */
  80418. maxEmitPower: number;
  80419. /**
  80420. * Minimum life time of emitting particles.
  80421. */
  80422. minLifeTime: number;
  80423. /**
  80424. * Maximum life time of emitting particles.
  80425. */
  80426. maxLifeTime: number;
  80427. /**
  80428. * Minimum Size of emitting particles.
  80429. */
  80430. minSize: number;
  80431. /**
  80432. * Maximum Size of emitting particles.
  80433. */
  80434. maxSize: number;
  80435. /**
  80436. * Minimum scale of emitting particles on X axis.
  80437. */
  80438. minScaleX: number;
  80439. /**
  80440. * Maximum scale of emitting particles on X axis.
  80441. */
  80442. maxScaleX: number;
  80443. /**
  80444. * Minimum scale of emitting particles on Y axis.
  80445. */
  80446. minScaleY: number;
  80447. /**
  80448. * Maximum scale of emitting particles on Y axis.
  80449. */
  80450. maxScaleY: number;
  80451. /**
  80452. * Gets or sets the minimal initial rotation in radians.
  80453. */
  80454. minInitialRotation: number;
  80455. /**
  80456. * Gets or sets the maximal initial rotation in radians.
  80457. */
  80458. maxInitialRotation: number;
  80459. /**
  80460. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80461. */
  80462. minAngularSpeed: number;
  80463. /**
  80464. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80465. */
  80466. maxAngularSpeed: number;
  80467. /**
  80468. * The texture used to render each particle. (this can be a spritesheet)
  80469. */
  80470. particleTexture: Nullable<Texture>;
  80471. /**
  80472. * The layer mask we are rendering the particles through.
  80473. */
  80474. layerMask: number;
  80475. /**
  80476. * This can help using your own shader to render the particle system.
  80477. * The according effect will be created
  80478. */
  80479. customShader: any;
  80480. /**
  80481. * By default particle system starts as soon as they are created. This prevents the
  80482. * automatic start to happen and let you decide when to start emitting particles.
  80483. */
  80484. preventAutoStart: boolean;
  80485. private _noiseTexture;
  80486. /**
  80487. * Gets or sets a texture used to add random noise to particle positions
  80488. */
  80489. noiseTexture: Nullable<ProceduralTexture>;
  80490. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80491. noiseStrength: Vector3;
  80492. /**
  80493. * Callback triggered when the particle animation is ending.
  80494. */
  80495. onAnimationEnd: Nullable<() => void>;
  80496. /**
  80497. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80498. */
  80499. blendMode: number;
  80500. /**
  80501. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80502. * to override the particles.
  80503. */
  80504. forceDepthWrite: boolean;
  80505. /** 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 */
  80506. preWarmCycles: number;
  80507. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80508. preWarmStepOffset: number;
  80509. /**
  80510. * 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)
  80511. */
  80512. spriteCellChangeSpeed: number;
  80513. /**
  80514. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80515. */
  80516. startSpriteCellID: number;
  80517. /**
  80518. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80519. */
  80520. endSpriteCellID: number;
  80521. /**
  80522. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80523. */
  80524. spriteCellWidth: number;
  80525. /**
  80526. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80527. */
  80528. spriteCellHeight: number;
  80529. /**
  80530. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80531. */
  80532. spriteRandomStartCell: boolean;
  80533. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80534. translationPivot: Vector2;
  80535. /** @hidden */
  80536. protected _isAnimationSheetEnabled: boolean;
  80537. /**
  80538. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80539. */
  80540. beginAnimationOnStart: boolean;
  80541. /**
  80542. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80543. */
  80544. beginAnimationFrom: number;
  80545. /**
  80546. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80547. */
  80548. beginAnimationTo: number;
  80549. /**
  80550. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80551. */
  80552. beginAnimationLoop: boolean;
  80553. /**
  80554. * Gets or sets a world offset applied to all particles
  80555. */
  80556. worldOffset: Vector3;
  80557. /**
  80558. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80559. */
  80560. isAnimationSheetEnabled: boolean;
  80561. /**
  80562. * Get hosting scene
  80563. * @returns the scene
  80564. */
  80565. getScene(): Scene;
  80566. /**
  80567. * You can use gravity if you want to give an orientation to your particles.
  80568. */
  80569. gravity: Vector3;
  80570. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80571. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80572. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80573. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80574. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80575. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80576. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80577. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80578. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80579. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80580. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80581. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80582. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80583. /**
  80584. * Defines the delay in milliseconds before starting the system (0 by default)
  80585. */
  80586. startDelay: number;
  80587. /**
  80588. * Gets the current list of drag gradients.
  80589. * You must use addDragGradient and removeDragGradient to udpate this list
  80590. * @returns the list of drag gradients
  80591. */
  80592. getDragGradients(): Nullable<Array<FactorGradient>>;
  80593. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80594. limitVelocityDamping: number;
  80595. /**
  80596. * Gets the current list of limit velocity gradients.
  80597. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80598. * @returns the list of limit velocity gradients
  80599. */
  80600. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80601. /**
  80602. * Gets the current list of color gradients.
  80603. * You must use addColorGradient and removeColorGradient to udpate this list
  80604. * @returns the list of color gradients
  80605. */
  80606. getColorGradients(): Nullable<Array<ColorGradient>>;
  80607. /**
  80608. * Gets the current list of size gradients.
  80609. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80610. * @returns the list of size gradients
  80611. */
  80612. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80613. /**
  80614. * Gets the current list of color remap gradients.
  80615. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80616. * @returns the list of color remap gradients
  80617. */
  80618. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80619. /**
  80620. * Gets the current list of alpha remap gradients.
  80621. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80622. * @returns the list of alpha remap gradients
  80623. */
  80624. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80625. /**
  80626. * Gets the current list of life time gradients.
  80627. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80628. * @returns the list of life time gradients
  80629. */
  80630. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80631. /**
  80632. * Gets the current list of angular speed gradients.
  80633. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80634. * @returns the list of angular speed gradients
  80635. */
  80636. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80637. /**
  80638. * Gets the current list of velocity gradients.
  80639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80640. * @returns the list of velocity gradients
  80641. */
  80642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80643. /**
  80644. * Gets the current list of start size gradients.
  80645. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80646. * @returns the list of start size gradients
  80647. */
  80648. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80649. /**
  80650. * Gets the current list of emit rate gradients.
  80651. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80652. * @returns the list of emit rate gradients
  80653. */
  80654. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80655. /**
  80656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80657. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80658. */
  80659. direction1: Vector3;
  80660. /**
  80661. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80662. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80663. */
  80664. direction2: Vector3;
  80665. /**
  80666. * 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.
  80667. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80668. */
  80669. minEmitBox: Vector3;
  80670. /**
  80671. * 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.
  80672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80673. */
  80674. maxEmitBox: Vector3;
  80675. /**
  80676. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80677. */
  80678. color1: Color4;
  80679. /**
  80680. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80681. */
  80682. color2: Color4;
  80683. /**
  80684. * Color the particle will have at the end of its lifetime
  80685. */
  80686. colorDead: Color4;
  80687. /**
  80688. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80689. */
  80690. textureMask: Color4;
  80691. /**
  80692. * The particle emitter type defines the emitter used by the particle system.
  80693. * It can be for example box, sphere, or cone...
  80694. */
  80695. particleEmitterType: IParticleEmitterType;
  80696. /** @hidden */
  80697. _isSubEmitter: boolean;
  80698. /**
  80699. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80700. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80701. */
  80702. billboardMode: number;
  80703. protected _isBillboardBased: boolean;
  80704. /**
  80705. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80706. */
  80707. isBillboardBased: boolean;
  80708. /**
  80709. * The scene the particle system belongs to.
  80710. */
  80711. protected _scene: Scene;
  80712. /**
  80713. * Local cache of defines for image processing.
  80714. */
  80715. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80716. /**
  80717. * Default configuration related to image processing available in the standard Material.
  80718. */
  80719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80720. /**
  80721. * Gets the image processing configuration used either in this material.
  80722. */
  80723. /**
  80724. * Sets the Default image processing configuration used either in the this material.
  80725. *
  80726. * If sets to null, the scene one is in use.
  80727. */
  80728. imageProcessingConfiguration: ImageProcessingConfiguration;
  80729. /**
  80730. * Attaches a new image processing configuration to the Standard Material.
  80731. * @param configuration
  80732. */
  80733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80734. /** @hidden */
  80735. protected _reset(): void;
  80736. /** @hidden */
  80737. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80738. /**
  80739. * Instantiates a particle system.
  80740. * 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.
  80741. * @param name The name of the particle system
  80742. */
  80743. constructor(name: string);
  80744. /**
  80745. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80748. * @returns the emitter
  80749. */
  80750. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80751. /**
  80752. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80753. * @param radius The radius of the hemisphere to emit from
  80754. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80755. * @returns the emitter
  80756. */
  80757. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80758. /**
  80759. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80760. * @param radius The radius of the sphere to emit from
  80761. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80762. * @returns the emitter
  80763. */
  80764. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80765. /**
  80766. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80767. * @param radius The radius of the sphere to emit from
  80768. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80769. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80770. * @returns the emitter
  80771. */
  80772. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80773. /**
  80774. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80775. * @param radius The radius of the emission cylinder
  80776. * @param height The height of the emission cylinder
  80777. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80778. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80779. * @returns the emitter
  80780. */
  80781. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80782. /**
  80783. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80784. * @param radius The radius of the cylinder to emit from
  80785. * @param height The height of the emission cylinder
  80786. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80789. * @returns the emitter
  80790. */
  80791. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80792. /**
  80793. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80794. * @param radius The radius of the cone to emit from
  80795. * @param angle The base angle of the cone
  80796. * @returns the emitter
  80797. */
  80798. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80799. /**
  80800. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80803. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80804. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80805. * @returns the emitter
  80806. */
  80807. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80808. }
  80809. }
  80810. declare module BABYLON {
  80811. /**
  80812. * Type of sub emitter
  80813. */
  80814. export enum SubEmitterType {
  80815. /**
  80816. * Attached to the particle over it's lifetime
  80817. */
  80818. ATTACHED = 0,
  80819. /**
  80820. * Created when the particle dies
  80821. */
  80822. END = 1
  80823. }
  80824. /**
  80825. * Sub emitter class used to emit particles from an existing particle
  80826. */
  80827. export class SubEmitter {
  80828. /**
  80829. * the particle system to be used by the sub emitter
  80830. */
  80831. particleSystem: ParticleSystem;
  80832. /**
  80833. * Type of the submitter (Default: END)
  80834. */
  80835. type: SubEmitterType;
  80836. /**
  80837. * 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)
  80838. * Note: This only is supported when using an emitter of type Mesh
  80839. */
  80840. inheritDirection: boolean;
  80841. /**
  80842. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80843. */
  80844. inheritedVelocityAmount: number;
  80845. /**
  80846. * Creates a sub emitter
  80847. * @param particleSystem the particle system to be used by the sub emitter
  80848. */
  80849. constructor(
  80850. /**
  80851. * the particle system to be used by the sub emitter
  80852. */
  80853. particleSystem: ParticleSystem);
  80854. /**
  80855. * Clones the sub emitter
  80856. * @returns the cloned sub emitter
  80857. */
  80858. clone(): SubEmitter;
  80859. /**
  80860. * Serialize current object to a JSON object
  80861. * @returns the serialized object
  80862. */
  80863. serialize(): any;
  80864. /** @hidden */
  80865. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80866. /**
  80867. * Creates a new SubEmitter from a serialized JSON version
  80868. * @param serializationObject defines the JSON object to read from
  80869. * @param scene defines the hosting scene
  80870. * @param rootUrl defines the rootUrl for data loading
  80871. * @returns a new SubEmitter
  80872. */
  80873. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80874. /** Release associated resources */
  80875. dispose(): void;
  80876. }
  80877. }
  80878. declare module BABYLON {
  80879. /** @hidden */
  80880. export var clipPlaneFragmentDeclaration: {
  80881. name: string;
  80882. shader: string;
  80883. };
  80884. }
  80885. declare module BABYLON {
  80886. /** @hidden */
  80887. export var imageProcessingDeclaration: {
  80888. name: string;
  80889. shader: string;
  80890. };
  80891. }
  80892. declare module BABYLON {
  80893. /** @hidden */
  80894. export var imageProcessingFunctions: {
  80895. name: string;
  80896. shader: string;
  80897. };
  80898. }
  80899. declare module BABYLON {
  80900. /** @hidden */
  80901. export var clipPlaneFragment: {
  80902. name: string;
  80903. shader: string;
  80904. };
  80905. }
  80906. declare module BABYLON {
  80907. /** @hidden */
  80908. export var particlesPixelShader: {
  80909. name: string;
  80910. shader: string;
  80911. };
  80912. }
  80913. declare module BABYLON {
  80914. /** @hidden */
  80915. export var clipPlaneVertexDeclaration: {
  80916. name: string;
  80917. shader: string;
  80918. };
  80919. }
  80920. declare module BABYLON {
  80921. /** @hidden */
  80922. export var clipPlaneVertex: {
  80923. name: string;
  80924. shader: string;
  80925. };
  80926. }
  80927. declare module BABYLON {
  80928. /** @hidden */
  80929. export var particlesVertexShader: {
  80930. name: string;
  80931. shader: string;
  80932. };
  80933. }
  80934. declare module BABYLON {
  80935. /**
  80936. * This represents a particle system in Babylon.
  80937. * 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.
  80938. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80939. * @example https://doc.babylonjs.com/babylon101/particles
  80940. */
  80941. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80942. /**
  80943. * Billboard mode will only apply to Y axis
  80944. */
  80945. static readonly BILLBOARDMODE_Y: number;
  80946. /**
  80947. * Billboard mode will apply to all axes
  80948. */
  80949. static readonly BILLBOARDMODE_ALL: number;
  80950. /**
  80951. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80952. */
  80953. static readonly BILLBOARDMODE_STRETCHED: number;
  80954. /**
  80955. * This function can be defined to provide custom update for active particles.
  80956. * This function will be called instead of regular update (age, position, color, etc.).
  80957. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80958. */
  80959. updateFunction: (particles: Particle[]) => void;
  80960. private _emitterWorldMatrix;
  80961. /**
  80962. * This function can be defined to specify initial direction for every new particle.
  80963. * It by default use the emitterType defined function
  80964. */
  80965. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80966. /**
  80967. * This function can be defined to specify initial position for every new particle.
  80968. * It by default use the emitterType defined function
  80969. */
  80970. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80971. /**
  80972. * @hidden
  80973. */
  80974. _inheritedVelocityOffset: Vector3;
  80975. /**
  80976. * An event triggered when the system is disposed
  80977. */
  80978. onDisposeObservable: Observable<ParticleSystem>;
  80979. private _onDisposeObserver;
  80980. /**
  80981. * Sets a callback that will be triggered when the system is disposed
  80982. */
  80983. onDispose: () => void;
  80984. private _particles;
  80985. private _epsilon;
  80986. private _capacity;
  80987. private _stockParticles;
  80988. private _newPartsExcess;
  80989. private _vertexData;
  80990. private _vertexBuffer;
  80991. private _vertexBuffers;
  80992. private _spriteBuffer;
  80993. private _indexBuffer;
  80994. private _effect;
  80995. private _customEffect;
  80996. private _cachedDefines;
  80997. private _scaledColorStep;
  80998. private _colorDiff;
  80999. private _scaledDirection;
  81000. private _scaledGravity;
  81001. private _currentRenderId;
  81002. private _alive;
  81003. private _useInstancing;
  81004. private _started;
  81005. private _stopped;
  81006. private _actualFrame;
  81007. private _scaledUpdateSpeed;
  81008. private _vertexBufferSize;
  81009. /** @hidden */
  81010. _currentEmitRateGradient: Nullable<FactorGradient>;
  81011. /** @hidden */
  81012. _currentEmitRate1: number;
  81013. /** @hidden */
  81014. _currentEmitRate2: number;
  81015. /** @hidden */
  81016. _currentStartSizeGradient: Nullable<FactorGradient>;
  81017. /** @hidden */
  81018. _currentStartSize1: number;
  81019. /** @hidden */
  81020. _currentStartSize2: number;
  81021. private readonly _rawTextureWidth;
  81022. private _rampGradientsTexture;
  81023. private _useRampGradients;
  81024. /** Gets or sets a boolean indicating that ramp gradients must be used
  81025. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81026. */
  81027. useRampGradients: boolean;
  81028. /**
  81029. * 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.
  81030. * 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: [])
  81031. */
  81032. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81033. private _subEmitters;
  81034. /**
  81035. * @hidden
  81036. * If the particle systems emitter should be disposed when the particle system is disposed
  81037. */
  81038. _disposeEmitterOnDispose: boolean;
  81039. /**
  81040. * The current active Sub-systems, this property is used by the root particle system only.
  81041. */
  81042. activeSubSystems: Array<ParticleSystem>;
  81043. private _rootParticleSystem;
  81044. /**
  81045. * Gets the current list of active particles
  81046. */
  81047. readonly particles: Particle[];
  81048. /**
  81049. * Returns the string "ParticleSystem"
  81050. * @returns a string containing the class name
  81051. */
  81052. getClassName(): string;
  81053. /**
  81054. * Instantiates a particle system.
  81055. * 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.
  81056. * @param name The name of the particle system
  81057. * @param capacity The max number of particles alive at the same time
  81058. * @param scene The scene the particle system belongs to
  81059. * @param customEffect a custom effect used to change the way particles are rendered by default
  81060. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81061. * @param epsilon Offset used to render the particles
  81062. */
  81063. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81064. private _addFactorGradient;
  81065. private _removeFactorGradient;
  81066. /**
  81067. * Adds a new life time gradient
  81068. * @param gradient defines the gradient to use (between 0 and 1)
  81069. * @param factor defines the life time factor to affect to the specified gradient
  81070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81071. * @returns the current particle system
  81072. */
  81073. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81074. /**
  81075. * Remove a specific life time gradient
  81076. * @param gradient defines the gradient to remove
  81077. * @returns the current particle system
  81078. */
  81079. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81080. /**
  81081. * Adds a new size gradient
  81082. * @param gradient defines the gradient to use (between 0 and 1)
  81083. * @param factor defines the size factor to affect to the specified gradient
  81084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81085. * @returns the current particle system
  81086. */
  81087. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81088. /**
  81089. * Remove a specific size gradient
  81090. * @param gradient defines the gradient to remove
  81091. * @returns the current particle system
  81092. */
  81093. removeSizeGradient(gradient: number): IParticleSystem;
  81094. /**
  81095. * Adds a new color remap gradient
  81096. * @param gradient defines the gradient to use (between 0 and 1)
  81097. * @param min defines the color remap minimal range
  81098. * @param max defines the color remap maximal range
  81099. * @returns the current particle system
  81100. */
  81101. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81102. /**
  81103. * Remove a specific color remap gradient
  81104. * @param gradient defines the gradient to remove
  81105. * @returns the current particle system
  81106. */
  81107. removeColorRemapGradient(gradient: number): IParticleSystem;
  81108. /**
  81109. * Adds a new alpha remap gradient
  81110. * @param gradient defines the gradient to use (between 0 and 1)
  81111. * @param min defines the alpha remap minimal range
  81112. * @param max defines the alpha remap maximal range
  81113. * @returns the current particle system
  81114. */
  81115. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81116. /**
  81117. * Remove a specific alpha remap gradient
  81118. * @param gradient defines the gradient to remove
  81119. * @returns the current particle system
  81120. */
  81121. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81122. /**
  81123. * Adds a new angular speed gradient
  81124. * @param gradient defines the gradient to use (between 0 and 1)
  81125. * @param factor defines the angular speed to affect to the specified gradient
  81126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81127. * @returns the current particle system
  81128. */
  81129. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81130. /**
  81131. * Remove a specific angular speed gradient
  81132. * @param gradient defines the gradient to remove
  81133. * @returns the current particle system
  81134. */
  81135. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81136. /**
  81137. * Adds a new velocity gradient
  81138. * @param gradient defines the gradient to use (between 0 and 1)
  81139. * @param factor defines the velocity to affect to the specified gradient
  81140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81141. * @returns the current particle system
  81142. */
  81143. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81144. /**
  81145. * Remove a specific velocity gradient
  81146. * @param gradient defines the gradient to remove
  81147. * @returns the current particle system
  81148. */
  81149. removeVelocityGradient(gradient: number): IParticleSystem;
  81150. /**
  81151. * Adds a new limit velocity gradient
  81152. * @param gradient defines the gradient to use (between 0 and 1)
  81153. * @param factor defines the limit velocity value to affect to the specified gradient
  81154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81155. * @returns the current particle system
  81156. */
  81157. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81158. /**
  81159. * Remove a specific limit velocity gradient
  81160. * @param gradient defines the gradient to remove
  81161. * @returns the current particle system
  81162. */
  81163. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81164. /**
  81165. * Adds a new drag gradient
  81166. * @param gradient defines the gradient to use (between 0 and 1)
  81167. * @param factor defines the drag value to affect to the specified gradient
  81168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81169. * @returns the current particle system
  81170. */
  81171. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81172. /**
  81173. * Remove a specific drag gradient
  81174. * @param gradient defines the gradient to remove
  81175. * @returns the current particle system
  81176. */
  81177. removeDragGradient(gradient: number): IParticleSystem;
  81178. /**
  81179. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81180. * @param gradient defines the gradient to use (between 0 and 1)
  81181. * @param factor defines the emit rate value to affect to the specified gradient
  81182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81183. * @returns the current particle system
  81184. */
  81185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81186. /**
  81187. * Remove a specific emit rate gradient
  81188. * @param gradient defines the gradient to remove
  81189. * @returns the current particle system
  81190. */
  81191. removeEmitRateGradient(gradient: number): IParticleSystem;
  81192. /**
  81193. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81194. * @param gradient defines the gradient to use (between 0 and 1)
  81195. * @param factor defines the start size value to affect to the specified gradient
  81196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81197. * @returns the current particle system
  81198. */
  81199. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81200. /**
  81201. * Remove a specific start size gradient
  81202. * @param gradient defines the gradient to remove
  81203. * @returns the current particle system
  81204. */
  81205. removeStartSizeGradient(gradient: number): IParticleSystem;
  81206. private _createRampGradientTexture;
  81207. /**
  81208. * Gets the current list of ramp gradients.
  81209. * You must use addRampGradient and removeRampGradient to udpate this list
  81210. * @returns the list of ramp gradients
  81211. */
  81212. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81213. /**
  81214. * Adds a new ramp gradient used to remap particle colors
  81215. * @param gradient defines the gradient to use (between 0 and 1)
  81216. * @param color defines the color to affect to the specified gradient
  81217. * @returns the current particle system
  81218. */
  81219. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81220. /**
  81221. * Remove a specific ramp gradient
  81222. * @param gradient defines the gradient to remove
  81223. * @returns the current particle system
  81224. */
  81225. removeRampGradient(gradient: number): ParticleSystem;
  81226. /**
  81227. * Adds a new color gradient
  81228. * @param gradient defines the gradient to use (between 0 and 1)
  81229. * @param color1 defines the color to affect to the specified gradient
  81230. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81231. * @returns this particle system
  81232. */
  81233. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81234. /**
  81235. * Remove a specific color gradient
  81236. * @param gradient defines the gradient to remove
  81237. * @returns this particle system
  81238. */
  81239. removeColorGradient(gradient: number): IParticleSystem;
  81240. private _fetchR;
  81241. protected _reset(): void;
  81242. private _resetEffect;
  81243. private _createVertexBuffers;
  81244. private _createIndexBuffer;
  81245. /**
  81246. * Gets the maximum number of particles active at the same time.
  81247. * @returns The max number of active particles.
  81248. */
  81249. getCapacity(): number;
  81250. /**
  81251. * Gets whether there are still active particles in the system.
  81252. * @returns True if it is alive, otherwise false.
  81253. */
  81254. isAlive(): boolean;
  81255. /**
  81256. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81257. * @returns True if it has been started, otherwise false.
  81258. */
  81259. isStarted(): boolean;
  81260. private _prepareSubEmitterInternalArray;
  81261. /**
  81262. * Starts the particle system and begins to emit
  81263. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81264. */
  81265. start(delay?: number): void;
  81266. /**
  81267. * Stops the particle system.
  81268. * @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.
  81269. */
  81270. stop(stopSubEmitters?: boolean): void;
  81271. /**
  81272. * Remove all active particles
  81273. */
  81274. reset(): void;
  81275. /**
  81276. * @hidden (for internal use only)
  81277. */
  81278. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81279. /**
  81280. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81281. * Its lifetime will start back at 0.
  81282. */
  81283. recycleParticle: (particle: Particle) => void;
  81284. private _stopSubEmitters;
  81285. private _createParticle;
  81286. private _removeFromRoot;
  81287. private _emitFromParticle;
  81288. private _update;
  81289. /** @hidden */
  81290. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81291. /** @hidden */
  81292. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81293. /** @hidden */
  81294. private _getEffect;
  81295. /**
  81296. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81297. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81298. */
  81299. animate(preWarmOnly?: boolean): void;
  81300. private _appendParticleVertices;
  81301. /**
  81302. * Rebuilds the particle system.
  81303. */
  81304. rebuild(): void;
  81305. /**
  81306. * Is this system ready to be used/rendered
  81307. * @return true if the system is ready
  81308. */
  81309. isReady(): boolean;
  81310. private _render;
  81311. /**
  81312. * Renders the particle system in its current state.
  81313. * @returns the current number of particles
  81314. */
  81315. render(): number;
  81316. /**
  81317. * Disposes the particle system and free the associated resources
  81318. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81319. */
  81320. dispose(disposeTexture?: boolean): void;
  81321. /**
  81322. * Clones the particle system.
  81323. * @param name The name of the cloned object
  81324. * @param newEmitter The new emitter to use
  81325. * @returns the cloned particle system
  81326. */
  81327. clone(name: string, newEmitter: any): ParticleSystem;
  81328. /**
  81329. * Serializes the particle system to a JSON object.
  81330. * @returns the JSON object
  81331. */
  81332. serialize(): any;
  81333. /** @hidden */
  81334. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81335. /** @hidden */
  81336. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81337. /**
  81338. * Parses a JSON object to create a particle system.
  81339. * @param parsedParticleSystem The JSON object to parse
  81340. * @param scene The scene to create the particle system in
  81341. * @param rootUrl The root url to use to load external dependencies like texture
  81342. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81343. * @returns the Parsed particle system
  81344. */
  81345. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81346. }
  81347. }
  81348. declare module BABYLON {
  81349. /**
  81350. * A particle represents one of the element emitted by a particle system.
  81351. * This is mainly define by its coordinates, direction, velocity and age.
  81352. */
  81353. export class Particle {
  81354. /**
  81355. * The particle system the particle belongs to.
  81356. */
  81357. particleSystem: ParticleSystem;
  81358. private static _Count;
  81359. /**
  81360. * Unique ID of the particle
  81361. */
  81362. id: number;
  81363. /**
  81364. * The world position of the particle in the scene.
  81365. */
  81366. position: Vector3;
  81367. /**
  81368. * The world direction of the particle in the scene.
  81369. */
  81370. direction: Vector3;
  81371. /**
  81372. * The color of the particle.
  81373. */
  81374. color: Color4;
  81375. /**
  81376. * The color change of the particle per step.
  81377. */
  81378. colorStep: Color4;
  81379. /**
  81380. * Defines how long will the life of the particle be.
  81381. */
  81382. lifeTime: number;
  81383. /**
  81384. * The current age of the particle.
  81385. */
  81386. age: number;
  81387. /**
  81388. * The current size of the particle.
  81389. */
  81390. size: number;
  81391. /**
  81392. * The current scale of the particle.
  81393. */
  81394. scale: Vector2;
  81395. /**
  81396. * The current angle of the particle.
  81397. */
  81398. angle: number;
  81399. /**
  81400. * Defines how fast is the angle changing.
  81401. */
  81402. angularSpeed: number;
  81403. /**
  81404. * Defines the cell index used by the particle to be rendered from a sprite.
  81405. */
  81406. cellIndex: number;
  81407. /**
  81408. * The information required to support color remapping
  81409. */
  81410. remapData: Vector4;
  81411. /** @hidden */
  81412. _randomCellOffset?: number;
  81413. /** @hidden */
  81414. _initialDirection: Nullable<Vector3>;
  81415. /** @hidden */
  81416. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81417. /** @hidden */
  81418. _initialStartSpriteCellID: number;
  81419. /** @hidden */
  81420. _initialEndSpriteCellID: number;
  81421. /** @hidden */
  81422. _currentColorGradient: Nullable<ColorGradient>;
  81423. /** @hidden */
  81424. _currentColor1: Color4;
  81425. /** @hidden */
  81426. _currentColor2: Color4;
  81427. /** @hidden */
  81428. _currentSizeGradient: Nullable<FactorGradient>;
  81429. /** @hidden */
  81430. _currentSize1: number;
  81431. /** @hidden */
  81432. _currentSize2: number;
  81433. /** @hidden */
  81434. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81435. /** @hidden */
  81436. _currentAngularSpeed1: number;
  81437. /** @hidden */
  81438. _currentAngularSpeed2: number;
  81439. /** @hidden */
  81440. _currentVelocityGradient: Nullable<FactorGradient>;
  81441. /** @hidden */
  81442. _currentVelocity1: number;
  81443. /** @hidden */
  81444. _currentVelocity2: number;
  81445. /** @hidden */
  81446. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81447. /** @hidden */
  81448. _currentLimitVelocity1: number;
  81449. /** @hidden */
  81450. _currentLimitVelocity2: number;
  81451. /** @hidden */
  81452. _currentDragGradient: Nullable<FactorGradient>;
  81453. /** @hidden */
  81454. _currentDrag1: number;
  81455. /** @hidden */
  81456. _currentDrag2: number;
  81457. /** @hidden */
  81458. _randomNoiseCoordinates1: Vector3;
  81459. /** @hidden */
  81460. _randomNoiseCoordinates2: Vector3;
  81461. /**
  81462. * Creates a new instance Particle
  81463. * @param particleSystem the particle system the particle belongs to
  81464. */
  81465. constructor(
  81466. /**
  81467. * The particle system the particle belongs to.
  81468. */
  81469. particleSystem: ParticleSystem);
  81470. private updateCellInfoFromSystem;
  81471. /**
  81472. * Defines how the sprite cell index is updated for the particle
  81473. */
  81474. updateCellIndex(): void;
  81475. /** @hidden */
  81476. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81477. /** @hidden */
  81478. _inheritParticleInfoToSubEmitters(): void;
  81479. /** @hidden */
  81480. _reset(): void;
  81481. /**
  81482. * Copy the properties of particle to another one.
  81483. * @param other the particle to copy the information to.
  81484. */
  81485. copyTo(other: Particle): void;
  81486. }
  81487. }
  81488. declare module BABYLON {
  81489. /**
  81490. * Particle emitter represents a volume emitting particles.
  81491. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81492. */
  81493. export interface IParticleEmitterType {
  81494. /**
  81495. * Called by the particle System when the direction is computed for the created particle.
  81496. * @param worldMatrix is the world matrix of the particle system
  81497. * @param directionToUpdate is the direction vector to update with the result
  81498. * @param particle is the particle we are computed the direction for
  81499. */
  81500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81501. /**
  81502. * Called by the particle System when the position is computed for the created particle.
  81503. * @param worldMatrix is the world matrix of the particle system
  81504. * @param positionToUpdate is the position vector to update with the result
  81505. * @param particle is the particle we are computed the position for
  81506. */
  81507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81508. /**
  81509. * Clones the current emitter and returns a copy of it
  81510. * @returns the new emitter
  81511. */
  81512. clone(): IParticleEmitterType;
  81513. /**
  81514. * Called by the GPUParticleSystem to setup the update shader
  81515. * @param effect defines the update shader
  81516. */
  81517. applyToShader(effect: Effect): void;
  81518. /**
  81519. * Returns a string to use to update the GPU particles update shader
  81520. * @returns the effect defines string
  81521. */
  81522. getEffectDefines(): string;
  81523. /**
  81524. * Returns a string representing the class name
  81525. * @returns a string containing the class name
  81526. */
  81527. getClassName(): string;
  81528. /**
  81529. * Serializes the particle system to a JSON object.
  81530. * @returns the JSON object
  81531. */
  81532. serialize(): any;
  81533. /**
  81534. * Parse properties from a JSON object
  81535. * @param serializationObject defines the JSON object
  81536. */
  81537. parse(serializationObject: any): void;
  81538. }
  81539. }
  81540. declare module BABYLON {
  81541. /**
  81542. * Particle emitter emitting particles from the inside of a box.
  81543. * It emits the particles randomly between 2 given directions.
  81544. */
  81545. export class BoxParticleEmitter implements IParticleEmitterType {
  81546. /**
  81547. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81548. */
  81549. direction1: Vector3;
  81550. /**
  81551. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81552. */
  81553. direction2: Vector3;
  81554. /**
  81555. * 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.
  81556. */
  81557. minEmitBox: Vector3;
  81558. /**
  81559. * 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.
  81560. */
  81561. maxEmitBox: Vector3;
  81562. /**
  81563. * Creates a new instance BoxParticleEmitter
  81564. */
  81565. constructor();
  81566. /**
  81567. * Called by the particle System when the direction is computed for the created particle.
  81568. * @param worldMatrix is the world matrix of the particle system
  81569. * @param directionToUpdate is the direction vector to update with the result
  81570. * @param particle is the particle we are computed the direction for
  81571. */
  81572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81573. /**
  81574. * Called by the particle System when the position is computed for the created particle.
  81575. * @param worldMatrix is the world matrix of the particle system
  81576. * @param positionToUpdate is the position vector to update with the result
  81577. * @param particle is the particle we are computed the position for
  81578. */
  81579. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81580. /**
  81581. * Clones the current emitter and returns a copy of it
  81582. * @returns the new emitter
  81583. */
  81584. clone(): BoxParticleEmitter;
  81585. /**
  81586. * Called by the GPUParticleSystem to setup the update shader
  81587. * @param effect defines the update shader
  81588. */
  81589. applyToShader(effect: Effect): void;
  81590. /**
  81591. * Returns a string to use to update the GPU particles update shader
  81592. * @returns a string containng the defines string
  81593. */
  81594. getEffectDefines(): string;
  81595. /**
  81596. * Returns the string "BoxParticleEmitter"
  81597. * @returns a string containing the class name
  81598. */
  81599. getClassName(): string;
  81600. /**
  81601. * Serializes the particle system to a JSON object.
  81602. * @returns the JSON object
  81603. */
  81604. serialize(): any;
  81605. /**
  81606. * Parse properties from a JSON object
  81607. * @param serializationObject defines the JSON object
  81608. */
  81609. parse(serializationObject: any): void;
  81610. }
  81611. }
  81612. declare module BABYLON {
  81613. /**
  81614. * Particle emitter emitting particles from the inside of a cone.
  81615. * It emits the particles alongside the cone volume from the base to the particle.
  81616. * The emission direction might be randomized.
  81617. */
  81618. export class ConeParticleEmitter implements IParticleEmitterType {
  81619. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81620. directionRandomizer: number;
  81621. private _radius;
  81622. private _angle;
  81623. private _height;
  81624. /**
  81625. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81626. */
  81627. radiusRange: number;
  81628. /**
  81629. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81630. */
  81631. heightRange: number;
  81632. /**
  81633. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81634. */
  81635. emitFromSpawnPointOnly: boolean;
  81636. /**
  81637. * Gets or sets the radius of the emission cone
  81638. */
  81639. radius: number;
  81640. /**
  81641. * Gets or sets the angle of the emission cone
  81642. */
  81643. angle: number;
  81644. private _buildHeight;
  81645. /**
  81646. * Creates a new instance ConeParticleEmitter
  81647. * @param radius the radius of the emission cone (1 by default)
  81648. * @param angle the cone base angle (PI by default)
  81649. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81650. */
  81651. constructor(radius?: number, angle?: number,
  81652. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81653. directionRandomizer?: number);
  81654. /**
  81655. * Called by the particle System when the direction is computed for the created particle.
  81656. * @param worldMatrix is the world matrix of the particle system
  81657. * @param directionToUpdate is the direction vector to update with the result
  81658. * @param particle is the particle we are computed the direction for
  81659. */
  81660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81661. /**
  81662. * Called by the particle System when the position is computed for the created particle.
  81663. * @param worldMatrix is the world matrix of the particle system
  81664. * @param positionToUpdate is the position vector to update with the result
  81665. * @param particle is the particle we are computed the position for
  81666. */
  81667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81668. /**
  81669. * Clones the current emitter and returns a copy of it
  81670. * @returns the new emitter
  81671. */
  81672. clone(): ConeParticleEmitter;
  81673. /**
  81674. * Called by the GPUParticleSystem to setup the update shader
  81675. * @param effect defines the update shader
  81676. */
  81677. applyToShader(effect: Effect): void;
  81678. /**
  81679. * Returns a string to use to update the GPU particles update shader
  81680. * @returns a string containng the defines string
  81681. */
  81682. getEffectDefines(): string;
  81683. /**
  81684. * Returns the string "ConeParticleEmitter"
  81685. * @returns a string containing the class name
  81686. */
  81687. getClassName(): string;
  81688. /**
  81689. * Serializes the particle system to a JSON object.
  81690. * @returns the JSON object
  81691. */
  81692. serialize(): any;
  81693. /**
  81694. * Parse properties from a JSON object
  81695. * @param serializationObject defines the JSON object
  81696. */
  81697. parse(serializationObject: any): void;
  81698. }
  81699. }
  81700. declare module BABYLON {
  81701. /**
  81702. * Particle emitter emitting particles from the inside of a cylinder.
  81703. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81704. */
  81705. export class CylinderParticleEmitter implements IParticleEmitterType {
  81706. /**
  81707. * The radius of the emission cylinder.
  81708. */
  81709. radius: number;
  81710. /**
  81711. * The height of the emission cylinder.
  81712. */
  81713. height: number;
  81714. /**
  81715. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81716. */
  81717. radiusRange: number;
  81718. /**
  81719. * How much to randomize the particle direction [0-1].
  81720. */
  81721. directionRandomizer: number;
  81722. /**
  81723. * Creates a new instance CylinderParticleEmitter
  81724. * @param radius the radius of the emission cylinder (1 by default)
  81725. * @param height the height of the emission cylinder (1 by default)
  81726. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81727. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81728. */
  81729. constructor(
  81730. /**
  81731. * The radius of the emission cylinder.
  81732. */
  81733. radius?: number,
  81734. /**
  81735. * The height of the emission cylinder.
  81736. */
  81737. height?: number,
  81738. /**
  81739. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81740. */
  81741. radiusRange?: number,
  81742. /**
  81743. * How much to randomize the particle direction [0-1].
  81744. */
  81745. directionRandomizer?: number);
  81746. /**
  81747. * Called by the particle System when the direction is computed for the created particle.
  81748. * @param worldMatrix is the world matrix of the particle system
  81749. * @param directionToUpdate is the direction vector to update with the result
  81750. * @param particle is the particle we are computed the direction for
  81751. */
  81752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81753. /**
  81754. * Called by the particle System when the position is computed for the created particle.
  81755. * @param worldMatrix is the world matrix of the particle system
  81756. * @param positionToUpdate is the position vector to update with the result
  81757. * @param particle is the particle we are computed the position for
  81758. */
  81759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81760. /**
  81761. * Clones the current emitter and returns a copy of it
  81762. * @returns the new emitter
  81763. */
  81764. clone(): CylinderParticleEmitter;
  81765. /**
  81766. * Called by the GPUParticleSystem to setup the update shader
  81767. * @param effect defines the update shader
  81768. */
  81769. applyToShader(effect: Effect): void;
  81770. /**
  81771. * Returns a string to use to update the GPU particles update shader
  81772. * @returns a string containng the defines string
  81773. */
  81774. getEffectDefines(): string;
  81775. /**
  81776. * Returns the string "CylinderParticleEmitter"
  81777. * @returns a string containing the class name
  81778. */
  81779. getClassName(): string;
  81780. /**
  81781. * Serializes the particle system to a JSON object.
  81782. * @returns the JSON object
  81783. */
  81784. serialize(): any;
  81785. /**
  81786. * Parse properties from a JSON object
  81787. * @param serializationObject defines the JSON object
  81788. */
  81789. parse(serializationObject: any): void;
  81790. }
  81791. /**
  81792. * Particle emitter emitting particles from the inside of a cylinder.
  81793. * It emits the particles randomly between two vectors.
  81794. */
  81795. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81796. /**
  81797. * The min limit of the emission direction.
  81798. */
  81799. direction1: Vector3;
  81800. /**
  81801. * The max limit of the emission direction.
  81802. */
  81803. direction2: Vector3;
  81804. /**
  81805. * Creates a new instance CylinderDirectedParticleEmitter
  81806. * @param radius the radius of the emission cylinder (1 by default)
  81807. * @param height the height of the emission cylinder (1 by default)
  81808. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81809. * @param direction1 the min limit of the emission direction (up vector by default)
  81810. * @param direction2 the max limit of the emission direction (up vector by default)
  81811. */
  81812. constructor(radius?: number, height?: number, radiusRange?: number,
  81813. /**
  81814. * The min limit of the emission direction.
  81815. */
  81816. direction1?: Vector3,
  81817. /**
  81818. * The max limit of the emission direction.
  81819. */
  81820. direction2?: Vector3);
  81821. /**
  81822. * Called by the particle System when the direction is computed for the created particle.
  81823. * @param worldMatrix is the world matrix of the particle system
  81824. * @param directionToUpdate is the direction vector to update with the result
  81825. * @param particle is the particle we are computed the direction for
  81826. */
  81827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81828. /**
  81829. * Clones the current emitter and returns a copy of it
  81830. * @returns the new emitter
  81831. */
  81832. clone(): CylinderDirectedParticleEmitter;
  81833. /**
  81834. * Called by the GPUParticleSystem to setup the update shader
  81835. * @param effect defines the update shader
  81836. */
  81837. applyToShader(effect: Effect): void;
  81838. /**
  81839. * Returns a string to use to update the GPU particles update shader
  81840. * @returns a string containng the defines string
  81841. */
  81842. getEffectDefines(): string;
  81843. /**
  81844. * Returns the string "CylinderDirectedParticleEmitter"
  81845. * @returns a string containing the class name
  81846. */
  81847. getClassName(): string;
  81848. /**
  81849. * Serializes the particle system to a JSON object.
  81850. * @returns the JSON object
  81851. */
  81852. serialize(): any;
  81853. /**
  81854. * Parse properties from a JSON object
  81855. * @param serializationObject defines the JSON object
  81856. */
  81857. parse(serializationObject: any): void;
  81858. }
  81859. }
  81860. declare module BABYLON {
  81861. /**
  81862. * Particle emitter emitting particles from the inside of a hemisphere.
  81863. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81864. */
  81865. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81866. /**
  81867. * The radius of the emission hemisphere.
  81868. */
  81869. radius: number;
  81870. /**
  81871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81872. */
  81873. radiusRange: number;
  81874. /**
  81875. * How much to randomize the particle direction [0-1].
  81876. */
  81877. directionRandomizer: number;
  81878. /**
  81879. * Creates a new instance HemisphericParticleEmitter
  81880. * @param radius the radius of the emission hemisphere (1 by default)
  81881. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81883. */
  81884. constructor(
  81885. /**
  81886. * The radius of the emission hemisphere.
  81887. */
  81888. radius?: number,
  81889. /**
  81890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81891. */
  81892. radiusRange?: number,
  81893. /**
  81894. * How much to randomize the particle direction [0-1].
  81895. */
  81896. directionRandomizer?: number);
  81897. /**
  81898. * Called by the particle System when the direction is computed for the created particle.
  81899. * @param worldMatrix is the world matrix of the particle system
  81900. * @param directionToUpdate is the direction vector to update with the result
  81901. * @param particle is the particle we are computed the direction for
  81902. */
  81903. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81904. /**
  81905. * Called by the particle System when the position is computed for the created particle.
  81906. * @param worldMatrix is the world matrix of the particle system
  81907. * @param positionToUpdate is the position vector to update with the result
  81908. * @param particle is the particle we are computed the position for
  81909. */
  81910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81911. /**
  81912. * Clones the current emitter and returns a copy of it
  81913. * @returns the new emitter
  81914. */
  81915. clone(): HemisphericParticleEmitter;
  81916. /**
  81917. * Called by the GPUParticleSystem to setup the update shader
  81918. * @param effect defines the update shader
  81919. */
  81920. applyToShader(effect: Effect): void;
  81921. /**
  81922. * Returns a string to use to update the GPU particles update shader
  81923. * @returns a string containng the defines string
  81924. */
  81925. getEffectDefines(): string;
  81926. /**
  81927. * Returns the string "HemisphericParticleEmitter"
  81928. * @returns a string containing the class name
  81929. */
  81930. getClassName(): string;
  81931. /**
  81932. * Serializes the particle system to a JSON object.
  81933. * @returns the JSON object
  81934. */
  81935. serialize(): any;
  81936. /**
  81937. * Parse properties from a JSON object
  81938. * @param serializationObject defines the JSON object
  81939. */
  81940. parse(serializationObject: any): void;
  81941. }
  81942. }
  81943. declare module BABYLON {
  81944. /**
  81945. * Particle emitter emitting particles from a point.
  81946. * It emits the particles randomly between 2 given directions.
  81947. */
  81948. export class PointParticleEmitter implements IParticleEmitterType {
  81949. /**
  81950. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81951. */
  81952. direction1: Vector3;
  81953. /**
  81954. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81955. */
  81956. direction2: Vector3;
  81957. /**
  81958. * Creates a new instance PointParticleEmitter
  81959. */
  81960. constructor();
  81961. /**
  81962. * Called by the particle System when the direction is computed for the created particle.
  81963. * @param worldMatrix is the world matrix of the particle system
  81964. * @param directionToUpdate is the direction vector to update with the result
  81965. * @param particle is the particle we are computed the direction for
  81966. */
  81967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81968. /**
  81969. * Called by the particle System when the position is computed for the created particle.
  81970. * @param worldMatrix is the world matrix of the particle system
  81971. * @param positionToUpdate is the position vector to update with the result
  81972. * @param particle is the particle we are computed the position for
  81973. */
  81974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81975. /**
  81976. * Clones the current emitter and returns a copy of it
  81977. * @returns the new emitter
  81978. */
  81979. clone(): PointParticleEmitter;
  81980. /**
  81981. * Called by the GPUParticleSystem to setup the update shader
  81982. * @param effect defines the update shader
  81983. */
  81984. applyToShader(effect: Effect): void;
  81985. /**
  81986. * Returns a string to use to update the GPU particles update shader
  81987. * @returns a string containng the defines string
  81988. */
  81989. getEffectDefines(): string;
  81990. /**
  81991. * Returns the string "PointParticleEmitter"
  81992. * @returns a string containing the class name
  81993. */
  81994. getClassName(): string;
  81995. /**
  81996. * Serializes the particle system to a JSON object.
  81997. * @returns the JSON object
  81998. */
  81999. serialize(): any;
  82000. /**
  82001. * Parse properties from a JSON object
  82002. * @param serializationObject defines the JSON object
  82003. */
  82004. parse(serializationObject: any): void;
  82005. }
  82006. }
  82007. declare module BABYLON {
  82008. /**
  82009. * Particle emitter emitting particles from the inside of a sphere.
  82010. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82011. */
  82012. export class SphereParticleEmitter implements IParticleEmitterType {
  82013. /**
  82014. * The radius of the emission sphere.
  82015. */
  82016. radius: number;
  82017. /**
  82018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82019. */
  82020. radiusRange: number;
  82021. /**
  82022. * How much to randomize the particle direction [0-1].
  82023. */
  82024. directionRandomizer: number;
  82025. /**
  82026. * Creates a new instance SphereParticleEmitter
  82027. * @param radius the radius of the emission sphere (1 by default)
  82028. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82029. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82030. */
  82031. constructor(
  82032. /**
  82033. * The radius of the emission sphere.
  82034. */
  82035. radius?: number,
  82036. /**
  82037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82038. */
  82039. radiusRange?: number,
  82040. /**
  82041. * How much to randomize the particle direction [0-1].
  82042. */
  82043. directionRandomizer?: number);
  82044. /**
  82045. * Called by the particle System when the direction is computed for the created particle.
  82046. * @param worldMatrix is the world matrix of the particle system
  82047. * @param directionToUpdate is the direction vector to update with the result
  82048. * @param particle is the particle we are computed the direction for
  82049. */
  82050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82051. /**
  82052. * Called by the particle System when the position is computed for the created particle.
  82053. * @param worldMatrix is the world matrix of the particle system
  82054. * @param positionToUpdate is the position vector to update with the result
  82055. * @param particle is the particle we are computed the position for
  82056. */
  82057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82058. /**
  82059. * Clones the current emitter and returns a copy of it
  82060. * @returns the new emitter
  82061. */
  82062. clone(): SphereParticleEmitter;
  82063. /**
  82064. * Called by the GPUParticleSystem to setup the update shader
  82065. * @param effect defines the update shader
  82066. */
  82067. applyToShader(effect: Effect): void;
  82068. /**
  82069. * Returns a string to use to update the GPU particles update shader
  82070. * @returns a string containng the defines string
  82071. */
  82072. getEffectDefines(): string;
  82073. /**
  82074. * Returns the string "SphereParticleEmitter"
  82075. * @returns a string containing the class name
  82076. */
  82077. getClassName(): string;
  82078. /**
  82079. * Serializes the particle system to a JSON object.
  82080. * @returns the JSON object
  82081. */
  82082. serialize(): any;
  82083. /**
  82084. * Parse properties from a JSON object
  82085. * @param serializationObject defines the JSON object
  82086. */
  82087. parse(serializationObject: any): void;
  82088. }
  82089. /**
  82090. * Particle emitter emitting particles from the inside of a sphere.
  82091. * It emits the particles randomly between two vectors.
  82092. */
  82093. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82094. /**
  82095. * The min limit of the emission direction.
  82096. */
  82097. direction1: Vector3;
  82098. /**
  82099. * The max limit of the emission direction.
  82100. */
  82101. direction2: Vector3;
  82102. /**
  82103. * Creates a new instance SphereDirectedParticleEmitter
  82104. * @param radius the radius of the emission sphere (1 by default)
  82105. * @param direction1 the min limit of the emission direction (up vector by default)
  82106. * @param direction2 the max limit of the emission direction (up vector by default)
  82107. */
  82108. constructor(radius?: number,
  82109. /**
  82110. * The min limit of the emission direction.
  82111. */
  82112. direction1?: Vector3,
  82113. /**
  82114. * The max limit of the emission direction.
  82115. */
  82116. direction2?: Vector3);
  82117. /**
  82118. * Called by the particle System when the direction is computed for the created particle.
  82119. * @param worldMatrix is the world matrix of the particle system
  82120. * @param directionToUpdate is the direction vector to update with the result
  82121. * @param particle is the particle we are computed the direction for
  82122. */
  82123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82124. /**
  82125. * Clones the current emitter and returns a copy of it
  82126. * @returns the new emitter
  82127. */
  82128. clone(): SphereDirectedParticleEmitter;
  82129. /**
  82130. * Called by the GPUParticleSystem to setup the update shader
  82131. * @param effect defines the update shader
  82132. */
  82133. applyToShader(effect: Effect): void;
  82134. /**
  82135. * Returns a string to use to update the GPU particles update shader
  82136. * @returns a string containng the defines string
  82137. */
  82138. getEffectDefines(): string;
  82139. /**
  82140. * Returns the string "SphereDirectedParticleEmitter"
  82141. * @returns a string containing the class name
  82142. */
  82143. getClassName(): string;
  82144. /**
  82145. * Serializes the particle system to a JSON object.
  82146. * @returns the JSON object
  82147. */
  82148. serialize(): any;
  82149. /**
  82150. * Parse properties from a JSON object
  82151. * @param serializationObject defines the JSON object
  82152. */
  82153. parse(serializationObject: any): void;
  82154. }
  82155. }
  82156. declare module BABYLON {
  82157. /**
  82158. * Interface representing a particle system in Babylon.js.
  82159. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82160. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82161. */
  82162. export interface IParticleSystem {
  82163. /**
  82164. * List of animations used by the particle system.
  82165. */
  82166. animations: Animation[];
  82167. /**
  82168. * The id of the Particle system.
  82169. */
  82170. id: string;
  82171. /**
  82172. * The name of the Particle system.
  82173. */
  82174. name: string;
  82175. /**
  82176. * The emitter represents the Mesh or position we are attaching the particle system to.
  82177. */
  82178. emitter: Nullable<AbstractMesh | Vector3>;
  82179. /**
  82180. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82181. */
  82182. isBillboardBased: boolean;
  82183. /**
  82184. * The rendering group used by the Particle system to chose when to render.
  82185. */
  82186. renderingGroupId: number;
  82187. /**
  82188. * The layer mask we are rendering the particles through.
  82189. */
  82190. layerMask: number;
  82191. /**
  82192. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82193. */
  82194. updateSpeed: number;
  82195. /**
  82196. * The amount of time the particle system is running (depends of the overall update speed).
  82197. */
  82198. targetStopDuration: number;
  82199. /**
  82200. * The texture used to render each particle. (this can be a spritesheet)
  82201. */
  82202. particleTexture: Nullable<Texture>;
  82203. /**
  82204. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82205. */
  82206. blendMode: number;
  82207. /**
  82208. * Minimum life time of emitting particles.
  82209. */
  82210. minLifeTime: number;
  82211. /**
  82212. * Maximum life time of emitting particles.
  82213. */
  82214. maxLifeTime: number;
  82215. /**
  82216. * Minimum Size of emitting particles.
  82217. */
  82218. minSize: number;
  82219. /**
  82220. * Maximum Size of emitting particles.
  82221. */
  82222. maxSize: number;
  82223. /**
  82224. * Minimum scale of emitting particles on X axis.
  82225. */
  82226. minScaleX: number;
  82227. /**
  82228. * Maximum scale of emitting particles on X axis.
  82229. */
  82230. maxScaleX: number;
  82231. /**
  82232. * Minimum scale of emitting particles on Y axis.
  82233. */
  82234. minScaleY: number;
  82235. /**
  82236. * Maximum scale of emitting particles on Y axis.
  82237. */
  82238. maxScaleY: number;
  82239. /**
  82240. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82241. */
  82242. color1: Color4;
  82243. /**
  82244. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82245. */
  82246. color2: Color4;
  82247. /**
  82248. * Color the particle will have at the end of its lifetime.
  82249. */
  82250. colorDead: Color4;
  82251. /**
  82252. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82253. */
  82254. emitRate: number;
  82255. /**
  82256. * You can use gravity if you want to give an orientation to your particles.
  82257. */
  82258. gravity: Vector3;
  82259. /**
  82260. * Minimum power of emitting particles.
  82261. */
  82262. minEmitPower: number;
  82263. /**
  82264. * Maximum power of emitting particles.
  82265. */
  82266. maxEmitPower: number;
  82267. /**
  82268. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82269. */
  82270. minAngularSpeed: number;
  82271. /**
  82272. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82273. */
  82274. maxAngularSpeed: number;
  82275. /**
  82276. * Gets or sets the minimal initial rotation in radians.
  82277. */
  82278. minInitialRotation: number;
  82279. /**
  82280. * Gets or sets the maximal initial rotation in radians.
  82281. */
  82282. maxInitialRotation: number;
  82283. /**
  82284. * The particle emitter type defines the emitter used by the particle system.
  82285. * It can be for example box, sphere, or cone...
  82286. */
  82287. particleEmitterType: Nullable<IParticleEmitterType>;
  82288. /**
  82289. * Defines the delay in milliseconds before starting the system (0 by default)
  82290. */
  82291. startDelay: number;
  82292. /**
  82293. * 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
  82294. */
  82295. preWarmCycles: number;
  82296. /**
  82297. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82298. */
  82299. preWarmStepOffset: number;
  82300. /**
  82301. * 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)
  82302. */
  82303. spriteCellChangeSpeed: number;
  82304. /**
  82305. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82306. */
  82307. startSpriteCellID: number;
  82308. /**
  82309. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82310. */
  82311. endSpriteCellID: number;
  82312. /**
  82313. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82314. */
  82315. spriteCellWidth: number;
  82316. /**
  82317. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82318. */
  82319. spriteCellHeight: number;
  82320. /**
  82321. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82322. */
  82323. spriteRandomStartCell: boolean;
  82324. /**
  82325. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82326. */
  82327. isAnimationSheetEnabled: boolean;
  82328. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82329. translationPivot: Vector2;
  82330. /**
  82331. * Gets or sets a texture used to add random noise to particle positions
  82332. */
  82333. noiseTexture: Nullable<BaseTexture>;
  82334. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82335. noiseStrength: Vector3;
  82336. /**
  82337. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82338. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82339. */
  82340. billboardMode: number;
  82341. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82342. limitVelocityDamping: number;
  82343. /**
  82344. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82345. */
  82346. beginAnimationOnStart: boolean;
  82347. /**
  82348. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82349. */
  82350. beginAnimationFrom: number;
  82351. /**
  82352. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82353. */
  82354. beginAnimationTo: number;
  82355. /**
  82356. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82357. */
  82358. beginAnimationLoop: boolean;
  82359. /**
  82360. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82361. */
  82362. disposeOnStop: boolean;
  82363. /**
  82364. * Gets the maximum number of particles active at the same time.
  82365. * @returns The max number of active particles.
  82366. */
  82367. getCapacity(): number;
  82368. /**
  82369. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82370. * @returns True if it has been started, otherwise false.
  82371. */
  82372. isStarted(): boolean;
  82373. /**
  82374. * Animates the particle system for this frame.
  82375. */
  82376. animate(): void;
  82377. /**
  82378. * Renders the particle system in its current state.
  82379. * @returns the current number of particles
  82380. */
  82381. render(): number;
  82382. /**
  82383. * Dispose the particle system and frees its associated resources.
  82384. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82385. */
  82386. dispose(disposeTexture?: boolean): void;
  82387. /**
  82388. * Clones the particle system.
  82389. * @param name The name of the cloned object
  82390. * @param newEmitter The new emitter to use
  82391. * @returns the cloned particle system
  82392. */
  82393. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82394. /**
  82395. * Serializes the particle system to a JSON object.
  82396. * @returns the JSON object
  82397. */
  82398. serialize(): any;
  82399. /**
  82400. * Rebuild the particle system
  82401. */
  82402. rebuild(): void;
  82403. /**
  82404. * Starts the particle system and begins to emit
  82405. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82406. */
  82407. start(delay?: number): void;
  82408. /**
  82409. * Stops the particle system.
  82410. */
  82411. stop(): void;
  82412. /**
  82413. * Remove all active particles
  82414. */
  82415. reset(): void;
  82416. /**
  82417. * Is this system ready to be used/rendered
  82418. * @return true if the system is ready
  82419. */
  82420. isReady(): boolean;
  82421. /**
  82422. * Adds a new color gradient
  82423. * @param gradient defines the gradient to use (between 0 and 1)
  82424. * @param color1 defines the color to affect to the specified gradient
  82425. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82426. * @returns the current particle system
  82427. */
  82428. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82429. /**
  82430. * Remove a specific color gradient
  82431. * @param gradient defines the gradient to remove
  82432. * @returns the current particle system
  82433. */
  82434. removeColorGradient(gradient: number): IParticleSystem;
  82435. /**
  82436. * Adds a new size gradient
  82437. * @param gradient defines the gradient to use (between 0 and 1)
  82438. * @param factor defines the size factor to affect to the specified gradient
  82439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82440. * @returns the current particle system
  82441. */
  82442. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82443. /**
  82444. * Remove a specific size gradient
  82445. * @param gradient defines the gradient to remove
  82446. * @returns the current particle system
  82447. */
  82448. removeSizeGradient(gradient: number): IParticleSystem;
  82449. /**
  82450. * Gets the current list of color gradients.
  82451. * You must use addColorGradient and removeColorGradient to udpate this list
  82452. * @returns the list of color gradients
  82453. */
  82454. getColorGradients(): Nullable<Array<ColorGradient>>;
  82455. /**
  82456. * Gets the current list of size gradients.
  82457. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82458. * @returns the list of size gradients
  82459. */
  82460. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82461. /**
  82462. * Gets the current list of angular speed gradients.
  82463. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82464. * @returns the list of angular speed gradients
  82465. */
  82466. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82467. /**
  82468. * Adds a new angular speed gradient
  82469. * @param gradient defines the gradient to use (between 0 and 1)
  82470. * @param factor defines the angular speed to affect to the specified gradient
  82471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82472. * @returns the current particle system
  82473. */
  82474. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82475. /**
  82476. * Remove a specific angular speed gradient
  82477. * @param gradient defines the gradient to remove
  82478. * @returns the current particle system
  82479. */
  82480. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82481. /**
  82482. * Gets the current list of velocity gradients.
  82483. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82484. * @returns the list of velocity gradients
  82485. */
  82486. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82487. /**
  82488. * Adds a new velocity gradient
  82489. * @param gradient defines the gradient to use (between 0 and 1)
  82490. * @param factor defines the velocity to affect to the specified gradient
  82491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82492. * @returns the current particle system
  82493. */
  82494. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82495. /**
  82496. * Remove a specific velocity gradient
  82497. * @param gradient defines the gradient to remove
  82498. * @returns the current particle system
  82499. */
  82500. removeVelocityGradient(gradient: number): IParticleSystem;
  82501. /**
  82502. * Gets the current list of limit velocity gradients.
  82503. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82504. * @returns the list of limit velocity gradients
  82505. */
  82506. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82507. /**
  82508. * Adds a new limit velocity gradient
  82509. * @param gradient defines the gradient to use (between 0 and 1)
  82510. * @param factor defines the limit velocity to affect to the specified gradient
  82511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82512. * @returns the current particle system
  82513. */
  82514. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82515. /**
  82516. * Remove a specific limit velocity gradient
  82517. * @param gradient defines the gradient to remove
  82518. * @returns the current particle system
  82519. */
  82520. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82521. /**
  82522. * Adds a new drag gradient
  82523. * @param gradient defines the gradient to use (between 0 and 1)
  82524. * @param factor defines the drag to affect to the specified gradient
  82525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82526. * @returns the current particle system
  82527. */
  82528. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82529. /**
  82530. * Remove a specific drag gradient
  82531. * @param gradient defines the gradient to remove
  82532. * @returns the current particle system
  82533. */
  82534. removeDragGradient(gradient: number): IParticleSystem;
  82535. /**
  82536. * Gets the current list of drag gradients.
  82537. * You must use addDragGradient and removeDragGradient to udpate this list
  82538. * @returns the list of drag gradients
  82539. */
  82540. getDragGradients(): Nullable<Array<FactorGradient>>;
  82541. /**
  82542. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82543. * @param gradient defines the gradient to use (between 0 and 1)
  82544. * @param factor defines the emit rate to affect to the specified gradient
  82545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82546. * @returns the current particle system
  82547. */
  82548. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82549. /**
  82550. * Remove a specific emit rate gradient
  82551. * @param gradient defines the gradient to remove
  82552. * @returns the current particle system
  82553. */
  82554. removeEmitRateGradient(gradient: number): IParticleSystem;
  82555. /**
  82556. * Gets the current list of emit rate gradients.
  82557. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82558. * @returns the list of emit rate gradients
  82559. */
  82560. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82561. /**
  82562. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82563. * @param gradient defines the gradient to use (between 0 and 1)
  82564. * @param factor defines the start size to affect to the specified gradient
  82565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82566. * @returns the current particle system
  82567. */
  82568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82569. /**
  82570. * Remove a specific start size gradient
  82571. * @param gradient defines the gradient to remove
  82572. * @returns the current particle system
  82573. */
  82574. removeStartSizeGradient(gradient: number): IParticleSystem;
  82575. /**
  82576. * Gets the current list of start size gradients.
  82577. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82578. * @returns the list of start size gradients
  82579. */
  82580. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82581. /**
  82582. * Adds a new life time gradient
  82583. * @param gradient defines the gradient to use (between 0 and 1)
  82584. * @param factor defines the life time factor to affect to the specified gradient
  82585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82586. * @returns the current particle system
  82587. */
  82588. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82589. /**
  82590. * Remove a specific life time gradient
  82591. * @param gradient defines the gradient to remove
  82592. * @returns the current particle system
  82593. */
  82594. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82595. /**
  82596. * Gets the current list of life time gradients.
  82597. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82598. * @returns the list of life time gradients
  82599. */
  82600. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82601. /**
  82602. * Gets the current list of color gradients.
  82603. * You must use addColorGradient and removeColorGradient to udpate this list
  82604. * @returns the list of color gradients
  82605. */
  82606. getColorGradients(): Nullable<Array<ColorGradient>>;
  82607. /**
  82608. * Adds a new ramp gradient used to remap particle colors
  82609. * @param gradient defines the gradient to use (between 0 and 1)
  82610. * @param color defines the color to affect to the specified gradient
  82611. * @returns the current particle system
  82612. */
  82613. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82614. /**
  82615. * Gets the current list of ramp gradients.
  82616. * You must use addRampGradient and removeRampGradient to udpate this list
  82617. * @returns the list of ramp gradients
  82618. */
  82619. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82620. /** Gets or sets a boolean indicating that ramp gradients must be used
  82621. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82622. */
  82623. useRampGradients: boolean;
  82624. /**
  82625. * Adds a new color remap gradient
  82626. * @param gradient defines the gradient to use (between 0 and 1)
  82627. * @param min defines the color remap minimal range
  82628. * @param max defines the color remap maximal range
  82629. * @returns the current particle system
  82630. */
  82631. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82632. /**
  82633. * Gets the current list of color remap gradients.
  82634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82635. * @returns the list of color remap gradients
  82636. */
  82637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82638. /**
  82639. * Adds a new alpha remap gradient
  82640. * @param gradient defines the gradient to use (between 0 and 1)
  82641. * @param min defines the alpha remap minimal range
  82642. * @param max defines the alpha remap maximal range
  82643. * @returns the current particle system
  82644. */
  82645. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82646. /**
  82647. * Gets the current list of alpha remap gradients.
  82648. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82649. * @returns the list of alpha remap gradients
  82650. */
  82651. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82652. /**
  82653. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82656. * @returns the emitter
  82657. */
  82658. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82659. /**
  82660. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82661. * @param radius The radius of the hemisphere to emit from
  82662. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82663. * @returns the emitter
  82664. */
  82665. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82666. /**
  82667. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82668. * @param radius The radius of the sphere to emit from
  82669. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82670. * @returns the emitter
  82671. */
  82672. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82673. /**
  82674. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82675. * @param radius The radius of the sphere to emit from
  82676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82678. * @returns the emitter
  82679. */
  82680. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82681. /**
  82682. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82683. * @param radius The radius of the emission cylinder
  82684. * @param height The height of the emission cylinder
  82685. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82686. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82687. * @returns the emitter
  82688. */
  82689. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82690. /**
  82691. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82692. * @param radius The radius of the cylinder to emit from
  82693. * @param height The height of the emission cylinder
  82694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82697. * @returns the emitter
  82698. */
  82699. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82700. /**
  82701. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82702. * @param radius The radius of the cone to emit from
  82703. * @param angle The base angle of the cone
  82704. * @returns the emitter
  82705. */
  82706. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82707. /**
  82708. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82711. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82712. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82713. * @returns the emitter
  82714. */
  82715. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82716. /**
  82717. * Get hosting scene
  82718. * @returns the scene
  82719. */
  82720. getScene(): Scene;
  82721. }
  82722. }
  82723. declare module BABYLON {
  82724. /**
  82725. * Creates an instance based on a source mesh.
  82726. */
  82727. export class InstancedMesh extends AbstractMesh {
  82728. private _sourceMesh;
  82729. private _currentLOD;
  82730. /** @hidden */
  82731. _indexInSourceMeshInstanceArray: number;
  82732. constructor(name: string, source: Mesh);
  82733. /**
  82734. * Returns the string "InstancedMesh".
  82735. */
  82736. getClassName(): string;
  82737. /** Gets the list of lights affecting that mesh */
  82738. readonly lightSources: Light[];
  82739. _resyncLightSources(): void;
  82740. _resyncLighSource(light: Light): void;
  82741. _removeLightSource(light: Light): void;
  82742. /**
  82743. * If the source mesh receives shadows
  82744. */
  82745. readonly receiveShadows: boolean;
  82746. /**
  82747. * The material of the source mesh
  82748. */
  82749. readonly material: Nullable<Material>;
  82750. /**
  82751. * Visibility of the source mesh
  82752. */
  82753. readonly visibility: number;
  82754. /**
  82755. * Skeleton of the source mesh
  82756. */
  82757. readonly skeleton: Nullable<Skeleton>;
  82758. /**
  82759. * Rendering ground id of the source mesh
  82760. */
  82761. renderingGroupId: number;
  82762. /**
  82763. * Returns the total number of vertices (integer).
  82764. */
  82765. getTotalVertices(): number;
  82766. /**
  82767. * Returns a positive integer : the total number of indices in this mesh geometry.
  82768. * @returns the numner of indices or zero if the mesh has no geometry.
  82769. */
  82770. getTotalIndices(): number;
  82771. /**
  82772. * The source mesh of the instance
  82773. */
  82774. readonly sourceMesh: Mesh;
  82775. /**
  82776. * Is this node ready to be used/rendered
  82777. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82778. * @return {boolean} is it ready
  82779. */
  82780. isReady(completeCheck?: boolean): boolean;
  82781. /**
  82782. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82783. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82784. * @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.
  82785. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82786. */
  82787. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82788. /**
  82789. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82790. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82791. * The `data` are either a numeric array either a Float32Array.
  82792. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82793. * 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).
  82794. * Note that a new underlying VertexBuffer object is created each call.
  82795. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82796. *
  82797. * Possible `kind` values :
  82798. * - VertexBuffer.PositionKind
  82799. * - VertexBuffer.UVKind
  82800. * - VertexBuffer.UV2Kind
  82801. * - VertexBuffer.UV3Kind
  82802. * - VertexBuffer.UV4Kind
  82803. * - VertexBuffer.UV5Kind
  82804. * - VertexBuffer.UV6Kind
  82805. * - VertexBuffer.ColorKind
  82806. * - VertexBuffer.MatricesIndicesKind
  82807. * - VertexBuffer.MatricesIndicesExtraKind
  82808. * - VertexBuffer.MatricesWeightsKind
  82809. * - VertexBuffer.MatricesWeightsExtraKind
  82810. *
  82811. * Returns the Mesh.
  82812. */
  82813. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82814. /**
  82815. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82816. * If the mesh has no geometry, it is simply returned as it is.
  82817. * The `data` are either a numeric array either a Float32Array.
  82818. * No new underlying VertexBuffer object is created.
  82819. * 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.
  82820. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82821. *
  82822. * Possible `kind` values :
  82823. * - VertexBuffer.PositionKind
  82824. * - VertexBuffer.UVKind
  82825. * - VertexBuffer.UV2Kind
  82826. * - VertexBuffer.UV3Kind
  82827. * - VertexBuffer.UV4Kind
  82828. * - VertexBuffer.UV5Kind
  82829. * - VertexBuffer.UV6Kind
  82830. * - VertexBuffer.ColorKind
  82831. * - VertexBuffer.MatricesIndicesKind
  82832. * - VertexBuffer.MatricesIndicesExtraKind
  82833. * - VertexBuffer.MatricesWeightsKind
  82834. * - VertexBuffer.MatricesWeightsExtraKind
  82835. *
  82836. * Returns the Mesh.
  82837. */
  82838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82839. /**
  82840. * Sets the mesh indices.
  82841. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82842. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82843. * This method creates a new index buffer each call.
  82844. * Returns the Mesh.
  82845. */
  82846. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82847. /**
  82848. * Boolean : True if the mesh owns the requested kind of data.
  82849. */
  82850. isVerticesDataPresent(kind: string): boolean;
  82851. /**
  82852. * Returns an array of indices (IndicesArray).
  82853. */
  82854. getIndices(): Nullable<IndicesArray>;
  82855. readonly _positions: Nullable<Vector3[]>;
  82856. /**
  82857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82858. * This means the mesh underlying bounding box and sphere are recomputed.
  82859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82860. * @returns the current mesh
  82861. */
  82862. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82863. /** @hidden */
  82864. _preActivate(): InstancedMesh;
  82865. /** @hidden */
  82866. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82867. /** @hidden */
  82868. _postActivate(): void;
  82869. getWorldMatrix(): Matrix;
  82870. readonly isAnInstance: boolean;
  82871. /**
  82872. * Returns the current associated LOD AbstractMesh.
  82873. */
  82874. getLOD(camera: Camera): AbstractMesh;
  82875. /** @hidden */
  82876. _syncSubMeshes(): InstancedMesh;
  82877. /** @hidden */
  82878. _generatePointsArray(): boolean;
  82879. /**
  82880. * Creates a new InstancedMesh from the current mesh.
  82881. * - name (string) : the cloned mesh name
  82882. * - newParent (optional Node) : the optional Node to parent the clone to.
  82883. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82884. *
  82885. * Returns the clone.
  82886. */
  82887. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82888. /**
  82889. * Disposes the InstancedMesh.
  82890. * Returns nothing.
  82891. */
  82892. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82893. }
  82894. }
  82895. declare module BABYLON {
  82896. /**
  82897. * Defines the options associated with the creation of a shader material.
  82898. */
  82899. export interface IShaderMaterialOptions {
  82900. /**
  82901. * Does the material work in alpha blend mode
  82902. */
  82903. needAlphaBlending: boolean;
  82904. /**
  82905. * Does the material work in alpha test mode
  82906. */
  82907. needAlphaTesting: boolean;
  82908. /**
  82909. * The list of attribute names used in the shader
  82910. */
  82911. attributes: string[];
  82912. /**
  82913. * The list of unifrom names used in the shader
  82914. */
  82915. uniforms: string[];
  82916. /**
  82917. * The list of UBO names used in the shader
  82918. */
  82919. uniformBuffers: string[];
  82920. /**
  82921. * The list of sampler names used in the shader
  82922. */
  82923. samplers: string[];
  82924. /**
  82925. * The list of defines used in the shader
  82926. */
  82927. defines: string[];
  82928. }
  82929. /**
  82930. * 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.
  82931. *
  82932. * This returned material effects how the mesh will look based on the code in the shaders.
  82933. *
  82934. * @see http://doc.babylonjs.com/how_to/shader_material
  82935. */
  82936. export class ShaderMaterial extends Material {
  82937. private _shaderPath;
  82938. private _options;
  82939. private _textures;
  82940. private _textureArrays;
  82941. private _floats;
  82942. private _ints;
  82943. private _floatsArrays;
  82944. private _colors3;
  82945. private _colors3Arrays;
  82946. private _colors4;
  82947. private _colors4Arrays;
  82948. private _vectors2;
  82949. private _vectors3;
  82950. private _vectors4;
  82951. private _matrices;
  82952. private _matrices3x3;
  82953. private _matrices2x2;
  82954. private _vectors2Arrays;
  82955. private _vectors3Arrays;
  82956. private _vectors4Arrays;
  82957. private _cachedWorldViewMatrix;
  82958. private _cachedWorldViewProjectionMatrix;
  82959. private _renderId;
  82960. /**
  82961. * Instantiate a new shader material.
  82962. * 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.
  82963. * This returned material effects how the mesh will look based on the code in the shaders.
  82964. * @see http://doc.babylonjs.com/how_to/shader_material
  82965. * @param name Define the name of the material in the scene
  82966. * @param scene Define the scene the material belongs to
  82967. * @param shaderPath Defines the route to the shader code in one of three ways:
  82968. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82969. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82970. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82971. * @param options Define the options used to create the shader
  82972. */
  82973. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82974. /**
  82975. * Gets the options used to compile the shader.
  82976. * They can be modified to trigger a new compilation
  82977. */
  82978. readonly options: IShaderMaterialOptions;
  82979. /**
  82980. * Gets the current class name of the material e.g. "ShaderMaterial"
  82981. * Mainly use in serialization.
  82982. * @returns the class name
  82983. */
  82984. getClassName(): string;
  82985. /**
  82986. * Specifies if the material will require alpha blending
  82987. * @returns a boolean specifying if alpha blending is needed
  82988. */
  82989. needAlphaBlending(): boolean;
  82990. /**
  82991. * Specifies if this material should be rendered in alpha test mode
  82992. * @returns a boolean specifying if an alpha test is needed.
  82993. */
  82994. needAlphaTesting(): boolean;
  82995. private _checkUniform;
  82996. /**
  82997. * Set a texture in the shader.
  82998. * @param name Define the name of the uniform samplers as defined in the shader
  82999. * @param texture Define the texture to bind to this sampler
  83000. * @return the material itself allowing "fluent" like uniform updates
  83001. */
  83002. setTexture(name: string, texture: Texture): ShaderMaterial;
  83003. /**
  83004. * Set a texture array in the shader.
  83005. * @param name Define the name of the uniform sampler array as defined in the shader
  83006. * @param textures Define the list of textures to bind to this sampler
  83007. * @return the material itself allowing "fluent" like uniform updates
  83008. */
  83009. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83010. /**
  83011. * Set a float in the shader.
  83012. * @param name Define the name of the uniform as defined in the shader
  83013. * @param value Define the value to give to the uniform
  83014. * @return the material itself allowing "fluent" like uniform updates
  83015. */
  83016. setFloat(name: string, value: number): ShaderMaterial;
  83017. /**
  83018. * Set a int in the shader.
  83019. * @param name Define the name of the uniform as defined in the shader
  83020. * @param value Define the value to give to the uniform
  83021. * @return the material itself allowing "fluent" like uniform updates
  83022. */
  83023. setInt(name: string, value: number): ShaderMaterial;
  83024. /**
  83025. * Set an array of floats in the shader.
  83026. * @param name Define the name of the uniform as defined in the shader
  83027. * @param value Define the value to give to the uniform
  83028. * @return the material itself allowing "fluent" like uniform updates
  83029. */
  83030. setFloats(name: string, value: number[]): ShaderMaterial;
  83031. /**
  83032. * Set a vec3 in the shader from a Color3.
  83033. * @param name Define the name of the uniform as defined in the shader
  83034. * @param value Define the value to give to the uniform
  83035. * @return the material itself allowing "fluent" like uniform updates
  83036. */
  83037. setColor3(name: string, value: Color3): ShaderMaterial;
  83038. /**
  83039. * Set a vec3 array in the shader from a Color3 array.
  83040. * @param name Define the name of the uniform as defined in the shader
  83041. * @param value Define the value to give to the uniform
  83042. * @return the material itself allowing "fluent" like uniform updates
  83043. */
  83044. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83045. /**
  83046. * Set a vec4 in the shader from a Color4.
  83047. * @param name Define the name of the uniform as defined in the shader
  83048. * @param value Define the value to give to the uniform
  83049. * @return the material itself allowing "fluent" like uniform updates
  83050. */
  83051. setColor4(name: string, value: Color4): ShaderMaterial;
  83052. /**
  83053. * Set a vec4 array in the shader from a Color4 array.
  83054. * @param name Define the name of the uniform as defined in the shader
  83055. * @param value Define the value to give to the uniform
  83056. * @return the material itself allowing "fluent" like uniform updates
  83057. */
  83058. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83059. /**
  83060. * Set a vec2 in the shader from a Vector2.
  83061. * @param name Define the name of the uniform as defined in the shader
  83062. * @param value Define the value to give to the uniform
  83063. * @return the material itself allowing "fluent" like uniform updates
  83064. */
  83065. setVector2(name: string, value: Vector2): ShaderMaterial;
  83066. /**
  83067. * Set a vec3 in the shader from a Vector3.
  83068. * @param name Define the name of the uniform as defined in the shader
  83069. * @param value Define the value to give to the uniform
  83070. * @return the material itself allowing "fluent" like uniform updates
  83071. */
  83072. setVector3(name: string, value: Vector3): ShaderMaterial;
  83073. /**
  83074. * Set a vec4 in the shader from a Vector4.
  83075. * @param name Define the name of the uniform as defined in the shader
  83076. * @param value Define the value to give to the uniform
  83077. * @return the material itself allowing "fluent" like uniform updates
  83078. */
  83079. setVector4(name: string, value: Vector4): ShaderMaterial;
  83080. /**
  83081. * Set a mat4 in the shader from a Matrix.
  83082. * @param name Define the name of the uniform as defined in the shader
  83083. * @param value Define the value to give to the uniform
  83084. * @return the material itself allowing "fluent" like uniform updates
  83085. */
  83086. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83087. /**
  83088. * Set a mat3 in the shader from a Float32Array.
  83089. * @param name Define the name of the uniform as defined in the shader
  83090. * @param value Define the value to give to the uniform
  83091. * @return the material itself allowing "fluent" like uniform updates
  83092. */
  83093. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83094. /**
  83095. * Set a mat2 in the shader from a Float32Array.
  83096. * @param name Define the name of the uniform as defined in the shader
  83097. * @param value Define the value to give to the uniform
  83098. * @return the material itself allowing "fluent" like uniform updates
  83099. */
  83100. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83101. /**
  83102. * Set a vec2 array in the shader from a number array.
  83103. * @param name Define the name of the uniform as defined in the shader
  83104. * @param value Define the value to give to the uniform
  83105. * @return the material itself allowing "fluent" like uniform updates
  83106. */
  83107. setArray2(name: string, value: number[]): ShaderMaterial;
  83108. /**
  83109. * Set a vec3 array in the shader from a number array.
  83110. * @param name Define the name of the uniform as defined in the shader
  83111. * @param value Define the value to give to the uniform
  83112. * @return the material itself allowing "fluent" like uniform updates
  83113. */
  83114. setArray3(name: string, value: number[]): ShaderMaterial;
  83115. /**
  83116. * Set a vec4 array in the shader from a number array.
  83117. * @param name Define the name of the uniform as defined in the shader
  83118. * @param value Define the value to give to the uniform
  83119. * @return the material itself allowing "fluent" like uniform updates
  83120. */
  83121. setArray4(name: string, value: number[]): ShaderMaterial;
  83122. private _checkCache;
  83123. /**
  83124. * Specifies that the submesh is ready to be used
  83125. * @param mesh defines the mesh to check
  83126. * @param subMesh defines which submesh to check
  83127. * @param useInstances specifies that instances should be used
  83128. * @returns a boolean indicating that the submesh is ready or not
  83129. */
  83130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83131. /**
  83132. * Checks if the material is ready to render the requested mesh
  83133. * @param mesh Define the mesh to render
  83134. * @param useInstances Define whether or not the material is used with instances
  83135. * @returns true if ready, otherwise false
  83136. */
  83137. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83138. /**
  83139. * Binds the world matrix to the material
  83140. * @param world defines the world transformation matrix
  83141. */
  83142. bindOnlyWorldMatrix(world: Matrix): void;
  83143. /**
  83144. * Binds the material to the mesh
  83145. * @param world defines the world transformation matrix
  83146. * @param mesh defines the mesh to bind the material to
  83147. */
  83148. bind(world: Matrix, mesh?: Mesh): void;
  83149. /**
  83150. * Gets the active textures from the material
  83151. * @returns an array of textures
  83152. */
  83153. getActiveTextures(): BaseTexture[];
  83154. /**
  83155. * Specifies if the material uses a texture
  83156. * @param texture defines the texture to check against the material
  83157. * @returns a boolean specifying if the material uses the texture
  83158. */
  83159. hasTexture(texture: BaseTexture): boolean;
  83160. /**
  83161. * Makes a duplicate of the material, and gives it a new name
  83162. * @param name defines the new name for the duplicated material
  83163. * @returns the cloned material
  83164. */
  83165. clone(name: string): ShaderMaterial;
  83166. /**
  83167. * Disposes the material
  83168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83171. */
  83172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83173. /**
  83174. * Serializes this material in a JSON representation
  83175. * @returns the serialized material object
  83176. */
  83177. serialize(): any;
  83178. /**
  83179. * Creates a shader material from parsed shader material data
  83180. * @param source defines the JSON represnetation of the material
  83181. * @param scene defines the hosting scene
  83182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83183. * @returns a new material
  83184. */
  83185. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83186. }
  83187. }
  83188. declare module BABYLON {
  83189. /** @hidden */
  83190. export var colorPixelShader: {
  83191. name: string;
  83192. shader: string;
  83193. };
  83194. }
  83195. declare module BABYLON {
  83196. /** @hidden */
  83197. export var colorVertexShader: {
  83198. name: string;
  83199. shader: string;
  83200. };
  83201. }
  83202. declare module BABYLON {
  83203. /**
  83204. * Line mesh
  83205. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83206. */
  83207. export class LinesMesh extends Mesh {
  83208. /**
  83209. * If vertex color should be applied to the mesh
  83210. */
  83211. readonly useVertexColor?: boolean | undefined;
  83212. /**
  83213. * If vertex alpha should be applied to the mesh
  83214. */
  83215. readonly useVertexAlpha?: boolean | undefined;
  83216. /**
  83217. * Color of the line (Default: White)
  83218. */
  83219. color: Color3;
  83220. /**
  83221. * Alpha of the line (Default: 1)
  83222. */
  83223. alpha: number;
  83224. /**
  83225. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83226. * This margin is expressed in world space coordinates, so its value may vary.
  83227. * Default value is 0.1
  83228. */
  83229. intersectionThreshold: number;
  83230. private _colorShader;
  83231. private color4;
  83232. /**
  83233. * Creates a new LinesMesh
  83234. * @param name defines the name
  83235. * @param scene defines the hosting scene
  83236. * @param parent defines the parent mesh if any
  83237. * @param source defines the optional source LinesMesh used to clone data from
  83238. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83239. * When false, achieved by calling a clone(), also passing False.
  83240. * This will make creation of children, recursive.
  83241. * @param useVertexColor defines if this LinesMesh supports vertex color
  83242. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83243. */
  83244. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83245. /**
  83246. * If vertex color should be applied to the mesh
  83247. */
  83248. useVertexColor?: boolean | undefined,
  83249. /**
  83250. * If vertex alpha should be applied to the mesh
  83251. */
  83252. useVertexAlpha?: boolean | undefined);
  83253. private _addClipPlaneDefine;
  83254. private _removeClipPlaneDefine;
  83255. isReady(): boolean;
  83256. /**
  83257. * Returns the string "LineMesh"
  83258. */
  83259. getClassName(): string;
  83260. /**
  83261. * @hidden
  83262. */
  83263. /**
  83264. * @hidden
  83265. */
  83266. material: Material;
  83267. /**
  83268. * @hidden
  83269. */
  83270. readonly checkCollisions: boolean;
  83271. /** @hidden */
  83272. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83273. /** @hidden */
  83274. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83275. /**
  83276. * Disposes of the line mesh
  83277. * @param doNotRecurse If children should be disposed
  83278. */
  83279. dispose(doNotRecurse?: boolean): void;
  83280. /**
  83281. * Returns a new LineMesh object cloned from the current one.
  83282. */
  83283. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83284. /**
  83285. * Creates a new InstancedLinesMesh object from the mesh model.
  83286. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83287. * @param name defines the name of the new instance
  83288. * @returns a new InstancedLinesMesh
  83289. */
  83290. createInstance(name: string): InstancedLinesMesh;
  83291. }
  83292. /**
  83293. * Creates an instance based on a source LinesMesh
  83294. */
  83295. export class InstancedLinesMesh extends InstancedMesh {
  83296. /**
  83297. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83298. * This margin is expressed in world space coordinates, so its value may vary.
  83299. * Initilized with the intersectionThreshold value of the source LinesMesh
  83300. */
  83301. intersectionThreshold: number;
  83302. constructor(name: string, source: LinesMesh);
  83303. /**
  83304. * Returns the string "InstancedLinesMesh".
  83305. */
  83306. getClassName(): string;
  83307. }
  83308. }
  83309. declare module BABYLON {
  83310. /** @hidden */
  83311. export var linePixelShader: {
  83312. name: string;
  83313. shader: string;
  83314. };
  83315. }
  83316. declare module BABYLON {
  83317. /** @hidden */
  83318. export var lineVertexShader: {
  83319. name: string;
  83320. shader: string;
  83321. };
  83322. }
  83323. declare module BABYLON {
  83324. interface AbstractMesh {
  83325. /**
  83326. * Gets the edgesRenderer associated with the mesh
  83327. */
  83328. edgesRenderer: Nullable<EdgesRenderer>;
  83329. }
  83330. interface LinesMesh {
  83331. /**
  83332. * Enables the edge rendering mode on the mesh.
  83333. * This mode makes the mesh edges visible
  83334. * @param epsilon defines the maximal distance between two angles to detect a face
  83335. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83336. * @returns the currentAbstractMesh
  83337. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83338. */
  83339. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83340. }
  83341. interface InstancedLinesMesh {
  83342. /**
  83343. * Enables the edge rendering mode on the mesh.
  83344. * This mode makes the mesh edges visible
  83345. * @param epsilon defines the maximal distance between two angles to detect a face
  83346. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83347. * @returns the current InstancedLinesMesh
  83348. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83349. */
  83350. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83351. }
  83352. /**
  83353. * Defines the minimum contract an Edges renderer should follow.
  83354. */
  83355. export interface IEdgesRenderer extends IDisposable {
  83356. /**
  83357. * Gets or sets a boolean indicating if the edgesRenderer is active
  83358. */
  83359. isEnabled: boolean;
  83360. /**
  83361. * Renders the edges of the attached mesh,
  83362. */
  83363. render(): void;
  83364. /**
  83365. * Checks wether or not the edges renderer is ready to render.
  83366. * @return true if ready, otherwise false.
  83367. */
  83368. isReady(): boolean;
  83369. }
  83370. /**
  83371. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83372. */
  83373. export class EdgesRenderer implements IEdgesRenderer {
  83374. /**
  83375. * Define the size of the edges with an orthographic camera
  83376. */
  83377. edgesWidthScalerForOrthographic: number;
  83378. /**
  83379. * Define the size of the edges with a perspective camera
  83380. */
  83381. edgesWidthScalerForPerspective: number;
  83382. protected _source: AbstractMesh;
  83383. protected _linesPositions: number[];
  83384. protected _linesNormals: number[];
  83385. protected _linesIndices: number[];
  83386. protected _epsilon: number;
  83387. protected _indicesCount: number;
  83388. protected _lineShader: ShaderMaterial;
  83389. protected _ib: DataBuffer;
  83390. protected _buffers: {
  83391. [key: string]: Nullable<VertexBuffer>;
  83392. };
  83393. protected _checkVerticesInsteadOfIndices: boolean;
  83394. private _meshRebuildObserver;
  83395. private _meshDisposeObserver;
  83396. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83397. isEnabled: boolean;
  83398. /**
  83399. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83400. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83401. * @param source Mesh used to create edges
  83402. * @param epsilon sum of angles in adjacency to check for edge
  83403. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83404. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83405. */
  83406. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83407. protected _prepareRessources(): void;
  83408. /** @hidden */
  83409. _rebuild(): void;
  83410. /**
  83411. * Releases the required resources for the edges renderer
  83412. */
  83413. dispose(): void;
  83414. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83415. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83416. /**
  83417. * Checks if the pair of p0 and p1 is en edge
  83418. * @param faceIndex
  83419. * @param edge
  83420. * @param faceNormals
  83421. * @param p0
  83422. * @param p1
  83423. * @private
  83424. */
  83425. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83426. /**
  83427. * push line into the position, normal and index buffer
  83428. * @protected
  83429. */
  83430. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83431. /**
  83432. * Generates lines edges from adjacencjes
  83433. * @private
  83434. */
  83435. _generateEdgesLines(): void;
  83436. /**
  83437. * Checks wether or not the edges renderer is ready to render.
  83438. * @return true if ready, otherwise false.
  83439. */
  83440. isReady(): boolean;
  83441. /**
  83442. * Renders the edges of the attached mesh,
  83443. */
  83444. render(): void;
  83445. }
  83446. /**
  83447. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83448. */
  83449. export class LineEdgesRenderer extends EdgesRenderer {
  83450. /**
  83451. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83452. * @param source LineMesh used to generate edges
  83453. * @param epsilon not important (specified angle for edge detection)
  83454. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83455. */
  83456. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83457. /**
  83458. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83459. */
  83460. _generateEdgesLines(): void;
  83461. }
  83462. }
  83463. declare module BABYLON {
  83464. /**
  83465. * This represents the object necessary to create a rendering group.
  83466. * This is exclusively used and created by the rendering manager.
  83467. * To modify the behavior, you use the available helpers in your scene or meshes.
  83468. * @hidden
  83469. */
  83470. export class RenderingGroup {
  83471. index: number;
  83472. private static _zeroVector;
  83473. private _scene;
  83474. private _opaqueSubMeshes;
  83475. private _transparentSubMeshes;
  83476. private _alphaTestSubMeshes;
  83477. private _depthOnlySubMeshes;
  83478. private _particleSystems;
  83479. private _spriteManagers;
  83480. private _opaqueSortCompareFn;
  83481. private _alphaTestSortCompareFn;
  83482. private _transparentSortCompareFn;
  83483. private _renderOpaque;
  83484. private _renderAlphaTest;
  83485. private _renderTransparent;
  83486. /** @hidden */
  83487. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83488. onBeforeTransparentRendering: () => void;
  83489. /**
  83490. * Set the opaque sort comparison function.
  83491. * If null the sub meshes will be render in the order they were created
  83492. */
  83493. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83494. /**
  83495. * Set the alpha test sort comparison function.
  83496. * If null the sub meshes will be render in the order they were created
  83497. */
  83498. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83499. /**
  83500. * Set the transparent sort comparison function.
  83501. * If null the sub meshes will be render in the order they were created
  83502. */
  83503. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83504. /**
  83505. * Creates a new rendering group.
  83506. * @param index The rendering group index
  83507. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83508. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83509. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83510. */
  83511. 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>);
  83512. /**
  83513. * Render all the sub meshes contained in the group.
  83514. * @param customRenderFunction Used to override the default render behaviour of the group.
  83515. * @returns true if rendered some submeshes.
  83516. */
  83517. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83518. /**
  83519. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83520. * @param subMeshes The submeshes to render
  83521. */
  83522. private renderOpaqueSorted;
  83523. /**
  83524. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83525. * @param subMeshes The submeshes to render
  83526. */
  83527. private renderAlphaTestSorted;
  83528. /**
  83529. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83530. * @param subMeshes The submeshes to render
  83531. */
  83532. private renderTransparentSorted;
  83533. /**
  83534. * Renders the submeshes in a specified order.
  83535. * @param subMeshes The submeshes to sort before render
  83536. * @param sortCompareFn The comparison function use to sort
  83537. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83538. * @param transparent Specifies to activate blending if true
  83539. */
  83540. private static renderSorted;
  83541. /**
  83542. * Renders the submeshes in the order they were dispatched (no sort applied).
  83543. * @param subMeshes The submeshes to render
  83544. */
  83545. private static renderUnsorted;
  83546. /**
  83547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83548. * are rendered back to front if in the same alpha index.
  83549. *
  83550. * @param a The first submesh
  83551. * @param b The second submesh
  83552. * @returns The result of the comparison
  83553. */
  83554. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83555. /**
  83556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83557. * are rendered back to front.
  83558. *
  83559. * @param a The first submesh
  83560. * @param b The second submesh
  83561. * @returns The result of the comparison
  83562. */
  83563. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83564. /**
  83565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83566. * are rendered front to back (prevent overdraw).
  83567. *
  83568. * @param a The first submesh
  83569. * @param b The second submesh
  83570. * @returns The result of the comparison
  83571. */
  83572. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83573. /**
  83574. * Resets the different lists of submeshes to prepare a new frame.
  83575. */
  83576. prepare(): void;
  83577. dispose(): void;
  83578. /**
  83579. * Inserts the submesh in its correct queue depending on its material.
  83580. * @param subMesh The submesh to dispatch
  83581. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83582. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83583. */
  83584. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83585. dispatchSprites(spriteManager: ISpriteManager): void;
  83586. dispatchParticles(particleSystem: IParticleSystem): void;
  83587. private _renderParticles;
  83588. private _renderSprites;
  83589. }
  83590. }
  83591. declare module BABYLON {
  83592. /**
  83593. * Interface describing the different options available in the rendering manager
  83594. * regarding Auto Clear between groups.
  83595. */
  83596. export interface IRenderingManagerAutoClearSetup {
  83597. /**
  83598. * Defines whether or not autoclear is enable.
  83599. */
  83600. autoClear: boolean;
  83601. /**
  83602. * Defines whether or not to autoclear the depth buffer.
  83603. */
  83604. depth: boolean;
  83605. /**
  83606. * Defines whether or not to autoclear the stencil buffer.
  83607. */
  83608. stencil: boolean;
  83609. }
  83610. /**
  83611. * This class is used by the onRenderingGroupObservable
  83612. */
  83613. export class RenderingGroupInfo {
  83614. /**
  83615. * The Scene that being rendered
  83616. */
  83617. scene: Scene;
  83618. /**
  83619. * The camera currently used for the rendering pass
  83620. */
  83621. camera: Nullable<Camera>;
  83622. /**
  83623. * The ID of the renderingGroup being processed
  83624. */
  83625. renderingGroupId: number;
  83626. }
  83627. /**
  83628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83629. * It is enable to manage the different groups as well as the different necessary sort functions.
  83630. * This should not be used directly aside of the few static configurations
  83631. */
  83632. export class RenderingManager {
  83633. /**
  83634. * The max id used for rendering groups (not included)
  83635. */
  83636. static MAX_RENDERINGGROUPS: number;
  83637. /**
  83638. * The min id used for rendering groups (included)
  83639. */
  83640. static MIN_RENDERINGGROUPS: number;
  83641. /**
  83642. * Used to globally prevent autoclearing scenes.
  83643. */
  83644. static AUTOCLEAR: boolean;
  83645. /**
  83646. * @hidden
  83647. */
  83648. _useSceneAutoClearSetup: boolean;
  83649. private _scene;
  83650. private _renderingGroups;
  83651. private _depthStencilBufferAlreadyCleaned;
  83652. private _autoClearDepthStencil;
  83653. private _customOpaqueSortCompareFn;
  83654. private _customAlphaTestSortCompareFn;
  83655. private _customTransparentSortCompareFn;
  83656. private _renderingGroupInfo;
  83657. /**
  83658. * Instantiates a new rendering group for a particular scene
  83659. * @param scene Defines the scene the groups belongs to
  83660. */
  83661. constructor(scene: Scene);
  83662. private _clearDepthStencilBuffer;
  83663. /**
  83664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83665. * @hidden
  83666. */
  83667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83668. /**
  83669. * Resets the different information of the group to prepare a new frame
  83670. * @hidden
  83671. */
  83672. reset(): void;
  83673. /**
  83674. * Dispose and release the group and its associated resources.
  83675. * @hidden
  83676. */
  83677. dispose(): void;
  83678. /**
  83679. * Clear the info related to rendering groups preventing retention points during dispose.
  83680. */
  83681. freeRenderingGroups(): void;
  83682. private _prepareRenderingGroup;
  83683. /**
  83684. * Add a sprite manager to the rendering manager in order to render it this frame.
  83685. * @param spriteManager Define the sprite manager to render
  83686. */
  83687. dispatchSprites(spriteManager: ISpriteManager): void;
  83688. /**
  83689. * Add a particle system to the rendering manager in order to render it this frame.
  83690. * @param particleSystem Define the particle system to render
  83691. */
  83692. dispatchParticles(particleSystem: IParticleSystem): void;
  83693. /**
  83694. * Add a submesh to the manager in order to render it this frame
  83695. * @param subMesh The submesh to dispatch
  83696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83698. */
  83699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83700. /**
  83701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83702. * This allowed control for front to back rendering or reversly depending of the special needs.
  83703. *
  83704. * @param renderingGroupId The rendering group id corresponding to its index
  83705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83708. */
  83709. 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;
  83710. /**
  83711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83712. *
  83713. * @param renderingGroupId The rendering group id corresponding to its index
  83714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83717. */
  83718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83719. /**
  83720. * Gets the current auto clear configuration for one rendering group of the rendering
  83721. * manager.
  83722. * @param index the rendering group index to get the information for
  83723. * @returns The auto clear setup for the requested rendering group
  83724. */
  83725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83726. }
  83727. }
  83728. declare module BABYLON {
  83729. /**
  83730. * This Helps creating a texture that will be created from a camera in your scene.
  83731. * It is basically a dynamic texture that could be used to create special effects for instance.
  83732. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83733. */
  83734. export class RenderTargetTexture extends Texture {
  83735. isCube: boolean;
  83736. /**
  83737. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83738. */
  83739. static readonly REFRESHRATE_RENDER_ONCE: number;
  83740. /**
  83741. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83742. */
  83743. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83744. /**
  83745. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83746. * the central point of your effect and can save a lot of performances.
  83747. */
  83748. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83749. /**
  83750. * Use this predicate to dynamically define the list of mesh you want to render.
  83751. * If set, the renderList property will be overwritten.
  83752. */
  83753. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83754. private _renderList;
  83755. /**
  83756. * Use this list to define the list of mesh you want to render.
  83757. */
  83758. renderList: Nullable<Array<AbstractMesh>>;
  83759. private _hookArray;
  83760. /**
  83761. * Define if particles should be rendered in your texture.
  83762. */
  83763. renderParticles: boolean;
  83764. /**
  83765. * Define if sprites should be rendered in your texture.
  83766. */
  83767. renderSprites: boolean;
  83768. /**
  83769. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83770. */
  83771. coordinatesMode: number;
  83772. /**
  83773. * Define the camera used to render the texture.
  83774. */
  83775. activeCamera: Nullable<Camera>;
  83776. /**
  83777. * Override the render function of the texture with your own one.
  83778. */
  83779. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83780. /**
  83781. * Define if camera post processes should be use while rendering the texture.
  83782. */
  83783. useCameraPostProcesses: boolean;
  83784. /**
  83785. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83786. */
  83787. ignoreCameraViewport: boolean;
  83788. private _postProcessManager;
  83789. private _postProcesses;
  83790. private _resizeObserver;
  83791. /**
  83792. * An event triggered when the texture is unbind.
  83793. */
  83794. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83795. /**
  83796. * An event triggered when the texture is unbind.
  83797. */
  83798. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83799. private _onAfterUnbindObserver;
  83800. /**
  83801. * Set a after unbind callback in the texture.
  83802. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83803. */
  83804. onAfterUnbind: () => void;
  83805. /**
  83806. * An event triggered before rendering the texture
  83807. */
  83808. onBeforeRenderObservable: Observable<number>;
  83809. private _onBeforeRenderObserver;
  83810. /**
  83811. * Set a before render callback in the texture.
  83812. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83813. */
  83814. onBeforeRender: (faceIndex: number) => void;
  83815. /**
  83816. * An event triggered after rendering the texture
  83817. */
  83818. onAfterRenderObservable: Observable<number>;
  83819. private _onAfterRenderObserver;
  83820. /**
  83821. * Set a after render callback in the texture.
  83822. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83823. */
  83824. onAfterRender: (faceIndex: number) => void;
  83825. /**
  83826. * An event triggered after the texture clear
  83827. */
  83828. onClearObservable: Observable<Engine>;
  83829. private _onClearObserver;
  83830. /**
  83831. * Set a clear callback in the texture.
  83832. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83833. */
  83834. onClear: (Engine: Engine) => void;
  83835. /**
  83836. * An event triggered when the texture is resized.
  83837. */
  83838. onResizeObservable: Observable<RenderTargetTexture>;
  83839. /**
  83840. * Define the clear color of the Render Target if it should be different from the scene.
  83841. */
  83842. clearColor: Color4;
  83843. protected _size: number | {
  83844. width: number;
  83845. height: number;
  83846. };
  83847. protected _initialSizeParameter: number | {
  83848. width: number;
  83849. height: number;
  83850. } | {
  83851. ratio: number;
  83852. };
  83853. protected _sizeRatio: Nullable<number>;
  83854. /** @hidden */
  83855. _generateMipMaps: boolean;
  83856. protected _renderingManager: RenderingManager;
  83857. /** @hidden */
  83858. _waitingRenderList: string[];
  83859. protected _doNotChangeAspectRatio: boolean;
  83860. protected _currentRefreshId: number;
  83861. protected _refreshRate: number;
  83862. protected _textureMatrix: Matrix;
  83863. protected _samples: number;
  83864. protected _renderTargetOptions: RenderTargetCreationOptions;
  83865. /**
  83866. * Gets render target creation options that were used.
  83867. */
  83868. readonly renderTargetOptions: RenderTargetCreationOptions;
  83869. protected _engine: Engine;
  83870. protected _onRatioRescale(): void;
  83871. /**
  83872. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83873. * It must define where the camera used to render the texture is set
  83874. */
  83875. boundingBoxPosition: Vector3;
  83876. private _boundingBoxSize;
  83877. /**
  83878. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83879. * When defined, the cubemap will switch to local mode
  83880. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83881. * @example https://www.babylonjs-playground.com/#RNASML
  83882. */
  83883. boundingBoxSize: Vector3;
  83884. /**
  83885. * In case the RTT has been created with a depth texture, get the associated
  83886. * depth texture.
  83887. * Otherwise, return null.
  83888. */
  83889. depthStencilTexture: Nullable<InternalTexture>;
  83890. /**
  83891. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83892. * or used a shadow, depth texture...
  83893. * @param name The friendly name of the texture
  83894. * @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)
  83895. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83896. * @param generateMipMaps True if mip maps need to be generated after render.
  83897. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83898. * @param type The type of the buffer in the RTT (int, half float, float...)
  83899. * @param isCube True if a cube texture needs to be created
  83900. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83901. * @param generateDepthBuffer True to generate a depth buffer
  83902. * @param generateStencilBuffer True to generate a stencil buffer
  83903. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83904. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83905. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83906. */
  83907. constructor(name: string, size: number | {
  83908. width: number;
  83909. height: number;
  83910. } | {
  83911. ratio: number;
  83912. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83913. /**
  83914. * Creates a depth stencil texture.
  83915. * This is only available in WebGL 2 or with the depth texture extension available.
  83916. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83917. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83918. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83919. */
  83920. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83921. private _processSizeParameter;
  83922. /**
  83923. * Define the number of samples to use in case of MSAA.
  83924. * It defaults to one meaning no MSAA has been enabled.
  83925. */
  83926. samples: number;
  83927. /**
  83928. * Resets the refresh counter of the texture and start bak from scratch.
  83929. * Could be useful to regenerate the texture if it is setup to render only once.
  83930. */
  83931. resetRefreshCounter(): void;
  83932. /**
  83933. * Define the refresh rate of the texture or the rendering frequency.
  83934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83935. */
  83936. refreshRate: number;
  83937. /**
  83938. * Adds a post process to the render target rendering passes.
  83939. * @param postProcess define the post process to add
  83940. */
  83941. addPostProcess(postProcess: PostProcess): void;
  83942. /**
  83943. * Clear all the post processes attached to the render target
  83944. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83945. */
  83946. clearPostProcesses(dispose?: boolean): void;
  83947. /**
  83948. * Remove one of the post process from the list of attached post processes to the texture
  83949. * @param postProcess define the post process to remove from the list
  83950. */
  83951. removePostProcess(postProcess: PostProcess): void;
  83952. /** @hidden */
  83953. _shouldRender(): boolean;
  83954. /**
  83955. * Gets the actual render size of the texture.
  83956. * @returns the width of the render size
  83957. */
  83958. getRenderSize(): number;
  83959. /**
  83960. * Gets the actual render width of the texture.
  83961. * @returns the width of the render size
  83962. */
  83963. getRenderWidth(): number;
  83964. /**
  83965. * Gets the actual render height of the texture.
  83966. * @returns the height of the render size
  83967. */
  83968. getRenderHeight(): number;
  83969. /**
  83970. * Get if the texture can be rescaled or not.
  83971. */
  83972. readonly canRescale: boolean;
  83973. /**
  83974. * Resize the texture using a ratio.
  83975. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83976. */
  83977. scale(ratio: number): void;
  83978. /**
  83979. * Get the texture reflection matrix used to rotate/transform the reflection.
  83980. * @returns the reflection matrix
  83981. */
  83982. getReflectionTextureMatrix(): Matrix;
  83983. /**
  83984. * Resize the texture to a new desired size.
  83985. * Be carrefull as it will recreate all the data in the new texture.
  83986. * @param size Define the new size. It can be:
  83987. * - a number for squared texture,
  83988. * - an object containing { width: number, height: number }
  83989. * - or an object containing a ratio { ratio: number }
  83990. */
  83991. resize(size: number | {
  83992. width: number;
  83993. height: number;
  83994. } | {
  83995. ratio: number;
  83996. }): void;
  83997. /**
  83998. * Renders all the objects from the render list into the texture.
  83999. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84000. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84001. */
  84002. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84003. private _bestReflectionRenderTargetDimension;
  84004. /**
  84005. * @hidden
  84006. * @param faceIndex face index to bind to if this is a cubetexture
  84007. */
  84008. _bindFrameBuffer(faceIndex?: number): void;
  84009. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84010. private renderToTarget;
  84011. /**
  84012. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84013. * This allowed control for front to back rendering or reversly depending of the special needs.
  84014. *
  84015. * @param renderingGroupId The rendering group id corresponding to its index
  84016. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84017. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84018. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84019. */
  84020. 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;
  84021. /**
  84022. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84023. *
  84024. * @param renderingGroupId The rendering group id corresponding to its index
  84025. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84026. */
  84027. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84028. /**
  84029. * Clones the texture.
  84030. * @returns the cloned texture
  84031. */
  84032. clone(): RenderTargetTexture;
  84033. /**
  84034. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84035. * @returns The JSON representation of the texture
  84036. */
  84037. serialize(): any;
  84038. /**
  84039. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84040. */
  84041. disposeFramebufferObjects(): void;
  84042. /**
  84043. * Dispose the texture and release its associated resources.
  84044. */
  84045. dispose(): void;
  84046. /** @hidden */
  84047. _rebuild(): void;
  84048. /**
  84049. * Clear the info related to rendering groups preventing retention point in material dispose.
  84050. */
  84051. freeRenderingGroups(): void;
  84052. /**
  84053. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84054. * @returns the view count
  84055. */
  84056. getViewCount(): number;
  84057. }
  84058. }
  84059. declare module BABYLON {
  84060. /**
  84061. * Base class for the main features of a material in Babylon.js
  84062. */
  84063. export class Material implements IAnimatable {
  84064. /**
  84065. * Returns the triangle fill mode
  84066. */
  84067. static readonly TriangleFillMode: number;
  84068. /**
  84069. * Returns the wireframe mode
  84070. */
  84071. static readonly WireFrameFillMode: number;
  84072. /**
  84073. * Returns the point fill mode
  84074. */
  84075. static readonly PointFillMode: number;
  84076. /**
  84077. * Returns the point list draw mode
  84078. */
  84079. static readonly PointListDrawMode: number;
  84080. /**
  84081. * Returns the line list draw mode
  84082. */
  84083. static readonly LineListDrawMode: number;
  84084. /**
  84085. * Returns the line loop draw mode
  84086. */
  84087. static readonly LineLoopDrawMode: number;
  84088. /**
  84089. * Returns the line strip draw mode
  84090. */
  84091. static readonly LineStripDrawMode: number;
  84092. /**
  84093. * Returns the triangle strip draw mode
  84094. */
  84095. static readonly TriangleStripDrawMode: number;
  84096. /**
  84097. * Returns the triangle fan draw mode
  84098. */
  84099. static readonly TriangleFanDrawMode: number;
  84100. /**
  84101. * Stores the clock-wise side orientation
  84102. */
  84103. static readonly ClockWiseSideOrientation: number;
  84104. /**
  84105. * Stores the counter clock-wise side orientation
  84106. */
  84107. static readonly CounterClockWiseSideOrientation: number;
  84108. /**
  84109. * The dirty texture flag value
  84110. */
  84111. static readonly TextureDirtyFlag: number;
  84112. /**
  84113. * The dirty light flag value
  84114. */
  84115. static readonly LightDirtyFlag: number;
  84116. /**
  84117. * The dirty fresnel flag value
  84118. */
  84119. static readonly FresnelDirtyFlag: number;
  84120. /**
  84121. * The dirty attribute flag value
  84122. */
  84123. static readonly AttributesDirtyFlag: number;
  84124. /**
  84125. * The dirty misc flag value
  84126. */
  84127. static readonly MiscDirtyFlag: number;
  84128. /**
  84129. * The all dirty flag value
  84130. */
  84131. static readonly AllDirtyFlag: number;
  84132. /**
  84133. * The ID of the material
  84134. */
  84135. id: string;
  84136. /**
  84137. * Gets or sets the unique id of the material
  84138. */
  84139. uniqueId: number;
  84140. /**
  84141. * The name of the material
  84142. */
  84143. name: string;
  84144. /**
  84145. * Gets or sets user defined metadata
  84146. */
  84147. metadata: any;
  84148. /**
  84149. * For internal use only. Please do not use.
  84150. */
  84151. reservedDataStore: any;
  84152. /**
  84153. * Specifies if the ready state should be checked on each call
  84154. */
  84155. checkReadyOnEveryCall: boolean;
  84156. /**
  84157. * Specifies if the ready state should be checked once
  84158. */
  84159. checkReadyOnlyOnce: boolean;
  84160. /**
  84161. * The state of the material
  84162. */
  84163. state: string;
  84164. /**
  84165. * The alpha value of the material
  84166. */
  84167. protected _alpha: number;
  84168. /**
  84169. * List of inspectable custom properties (used by the Inspector)
  84170. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84171. */
  84172. inspectableCustomProperties: IInspectable[];
  84173. /**
  84174. * Sets the alpha value of the material
  84175. */
  84176. /**
  84177. * Gets the alpha value of the material
  84178. */
  84179. alpha: number;
  84180. /**
  84181. * Specifies if back face culling is enabled
  84182. */
  84183. protected _backFaceCulling: boolean;
  84184. /**
  84185. * Sets the back-face culling state
  84186. */
  84187. /**
  84188. * Gets the back-face culling state
  84189. */
  84190. backFaceCulling: boolean;
  84191. /**
  84192. * Stores the value for side orientation
  84193. */
  84194. sideOrientation: number;
  84195. /**
  84196. * Callback triggered when the material is compiled
  84197. */
  84198. onCompiled: Nullable<(effect: Effect) => void>;
  84199. /**
  84200. * Callback triggered when an error occurs
  84201. */
  84202. onError: Nullable<(effect: Effect, errors: string) => void>;
  84203. /**
  84204. * Callback triggered to get the render target textures
  84205. */
  84206. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84207. /**
  84208. * Gets a boolean indicating that current material needs to register RTT
  84209. */
  84210. readonly hasRenderTargetTextures: boolean;
  84211. /**
  84212. * Specifies if the material should be serialized
  84213. */
  84214. doNotSerialize: boolean;
  84215. /**
  84216. * @hidden
  84217. */
  84218. _storeEffectOnSubMeshes: boolean;
  84219. /**
  84220. * Stores the animations for the material
  84221. */
  84222. animations: Nullable<Array<Animation>>;
  84223. /**
  84224. * An event triggered when the material is disposed
  84225. */
  84226. onDisposeObservable: Observable<Material>;
  84227. /**
  84228. * An observer which watches for dispose events
  84229. */
  84230. private _onDisposeObserver;
  84231. private _onUnBindObservable;
  84232. /**
  84233. * Called during a dispose event
  84234. */
  84235. onDispose: () => void;
  84236. private _onBindObservable;
  84237. /**
  84238. * An event triggered when the material is bound
  84239. */
  84240. readonly onBindObservable: Observable<AbstractMesh>;
  84241. /**
  84242. * An observer which watches for bind events
  84243. */
  84244. private _onBindObserver;
  84245. /**
  84246. * Called during a bind event
  84247. */
  84248. onBind: (Mesh: AbstractMesh) => void;
  84249. /**
  84250. * An event triggered when the material is unbound
  84251. */
  84252. readonly onUnBindObservable: Observable<Material>;
  84253. /**
  84254. * Stores the value of the alpha mode
  84255. */
  84256. private _alphaMode;
  84257. /**
  84258. * Sets the value of the alpha mode.
  84259. *
  84260. * | Value | Type | Description |
  84261. * | --- | --- | --- |
  84262. * | 0 | ALPHA_DISABLE | |
  84263. * | 1 | ALPHA_ADD | |
  84264. * | 2 | ALPHA_COMBINE | |
  84265. * | 3 | ALPHA_SUBTRACT | |
  84266. * | 4 | ALPHA_MULTIPLY | |
  84267. * | 5 | ALPHA_MAXIMIZED | |
  84268. * | 6 | ALPHA_ONEONE | |
  84269. * | 7 | ALPHA_PREMULTIPLIED | |
  84270. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84271. * | 9 | ALPHA_INTERPOLATE | |
  84272. * | 10 | ALPHA_SCREENMODE | |
  84273. *
  84274. */
  84275. /**
  84276. * Gets the value of the alpha mode
  84277. */
  84278. alphaMode: number;
  84279. /**
  84280. * Stores the state of the need depth pre-pass value
  84281. */
  84282. private _needDepthPrePass;
  84283. /**
  84284. * Sets the need depth pre-pass value
  84285. */
  84286. /**
  84287. * Gets the depth pre-pass value
  84288. */
  84289. needDepthPrePass: boolean;
  84290. /**
  84291. * Specifies if depth writing should be disabled
  84292. */
  84293. disableDepthWrite: boolean;
  84294. /**
  84295. * Specifies if depth writing should be forced
  84296. */
  84297. forceDepthWrite: boolean;
  84298. /**
  84299. * Specifies if there should be a separate pass for culling
  84300. */
  84301. separateCullingPass: boolean;
  84302. /**
  84303. * Stores the state specifing if fog should be enabled
  84304. */
  84305. private _fogEnabled;
  84306. /**
  84307. * Sets the state for enabling fog
  84308. */
  84309. /**
  84310. * Gets the value of the fog enabled state
  84311. */
  84312. fogEnabled: boolean;
  84313. /**
  84314. * Stores the size of points
  84315. */
  84316. pointSize: number;
  84317. /**
  84318. * Stores the z offset value
  84319. */
  84320. zOffset: number;
  84321. /**
  84322. * Gets a value specifying if wireframe mode is enabled
  84323. */
  84324. /**
  84325. * Sets the state of wireframe mode
  84326. */
  84327. wireframe: boolean;
  84328. /**
  84329. * Gets the value specifying if point clouds are enabled
  84330. */
  84331. /**
  84332. * Sets the state of point cloud mode
  84333. */
  84334. pointsCloud: boolean;
  84335. /**
  84336. * Gets the material fill mode
  84337. */
  84338. /**
  84339. * Sets the material fill mode
  84340. */
  84341. fillMode: number;
  84342. /**
  84343. * @hidden
  84344. * Stores the effects for the material
  84345. */
  84346. _effect: Nullable<Effect>;
  84347. /**
  84348. * @hidden
  84349. * Specifies if the material was previously ready
  84350. */
  84351. _wasPreviouslyReady: boolean;
  84352. /**
  84353. * Specifies if uniform buffers should be used
  84354. */
  84355. private _useUBO;
  84356. /**
  84357. * Stores a reference to the scene
  84358. */
  84359. private _scene;
  84360. /**
  84361. * Stores the fill mode state
  84362. */
  84363. private _fillMode;
  84364. /**
  84365. * Specifies if the depth write state should be cached
  84366. */
  84367. private _cachedDepthWriteState;
  84368. /**
  84369. * Stores the uniform buffer
  84370. */
  84371. protected _uniformBuffer: UniformBuffer;
  84372. /** @hidden */
  84373. _indexInSceneMaterialArray: number;
  84374. /** @hidden */
  84375. meshMap: Nullable<{
  84376. [id: string]: AbstractMesh | undefined;
  84377. }>;
  84378. /**
  84379. * Creates a material instance
  84380. * @param name defines the name of the material
  84381. * @param scene defines the scene to reference
  84382. * @param doNotAdd specifies if the material should be added to the scene
  84383. */
  84384. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84385. /**
  84386. * Returns a string representation of the current material
  84387. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84388. * @returns a string with material information
  84389. */
  84390. toString(fullDetails?: boolean): string;
  84391. /**
  84392. * Gets the class name of the material
  84393. * @returns a string with the class name of the material
  84394. */
  84395. getClassName(): string;
  84396. /**
  84397. * Specifies if updates for the material been locked
  84398. */
  84399. readonly isFrozen: boolean;
  84400. /**
  84401. * Locks updates for the material
  84402. */
  84403. freeze(): void;
  84404. /**
  84405. * Unlocks updates for the material
  84406. */
  84407. unfreeze(): void;
  84408. /**
  84409. * Specifies if the material is ready to be used
  84410. * @param mesh defines the mesh to check
  84411. * @param useInstances specifies if instances should be used
  84412. * @returns a boolean indicating if the material is ready to be used
  84413. */
  84414. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84415. /**
  84416. * Specifies that the submesh is ready to be used
  84417. * @param mesh defines the mesh to check
  84418. * @param subMesh defines which submesh to check
  84419. * @param useInstances specifies that instances should be used
  84420. * @returns a boolean indicating that the submesh is ready or not
  84421. */
  84422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84423. /**
  84424. * Returns the material effect
  84425. * @returns the effect associated with the material
  84426. */
  84427. getEffect(): Nullable<Effect>;
  84428. /**
  84429. * Returns the current scene
  84430. * @returns a Scene
  84431. */
  84432. getScene(): Scene;
  84433. /**
  84434. * Specifies if the material will require alpha blending
  84435. * @returns a boolean specifying if alpha blending is needed
  84436. */
  84437. needAlphaBlending(): boolean;
  84438. /**
  84439. * Specifies if the mesh will require alpha blending
  84440. * @param mesh defines the mesh to check
  84441. * @returns a boolean specifying if alpha blending is needed for the mesh
  84442. */
  84443. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84444. /**
  84445. * Specifies if this material should be rendered in alpha test mode
  84446. * @returns a boolean specifying if an alpha test is needed.
  84447. */
  84448. needAlphaTesting(): boolean;
  84449. /**
  84450. * Gets the texture used for the alpha test
  84451. * @returns the texture to use for alpha testing
  84452. */
  84453. getAlphaTestTexture(): Nullable<BaseTexture>;
  84454. /**
  84455. * Marks the material to indicate that it needs to be re-calculated
  84456. */
  84457. markDirty(): void;
  84458. /** @hidden */
  84459. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84460. /**
  84461. * Binds the material to the mesh
  84462. * @param world defines the world transformation matrix
  84463. * @param mesh defines the mesh to bind the material to
  84464. */
  84465. bind(world: Matrix, mesh?: Mesh): void;
  84466. /**
  84467. * Binds the submesh to the material
  84468. * @param world defines the world transformation matrix
  84469. * @param mesh defines the mesh containing the submesh
  84470. * @param subMesh defines the submesh to bind the material to
  84471. */
  84472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84473. /**
  84474. * Binds the world matrix to the material
  84475. * @param world defines the world transformation matrix
  84476. */
  84477. bindOnlyWorldMatrix(world: Matrix): void;
  84478. /**
  84479. * Binds the scene's uniform buffer to the effect.
  84480. * @param effect defines the effect to bind to the scene uniform buffer
  84481. * @param sceneUbo defines the uniform buffer storing scene data
  84482. */
  84483. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84484. /**
  84485. * Binds the view matrix to the effect
  84486. * @param effect defines the effect to bind the view matrix to
  84487. */
  84488. bindView(effect: Effect): void;
  84489. /**
  84490. * Binds the view projection matrix to the effect
  84491. * @param effect defines the effect to bind the view projection matrix to
  84492. */
  84493. bindViewProjection(effect: Effect): void;
  84494. /**
  84495. * Specifies if material alpha testing should be turned on for the mesh
  84496. * @param mesh defines the mesh to check
  84497. */
  84498. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84499. /**
  84500. * Processes to execute after binding the material to a mesh
  84501. * @param mesh defines the rendered mesh
  84502. */
  84503. protected _afterBind(mesh?: Mesh): void;
  84504. /**
  84505. * Unbinds the material from the mesh
  84506. */
  84507. unbind(): void;
  84508. /**
  84509. * Gets the active textures from the material
  84510. * @returns an array of textures
  84511. */
  84512. getActiveTextures(): BaseTexture[];
  84513. /**
  84514. * Specifies if the material uses a texture
  84515. * @param texture defines the texture to check against the material
  84516. * @returns a boolean specifying if the material uses the texture
  84517. */
  84518. hasTexture(texture: BaseTexture): boolean;
  84519. /**
  84520. * Makes a duplicate of the material, and gives it a new name
  84521. * @param name defines the new name for the duplicated material
  84522. * @returns the cloned material
  84523. */
  84524. clone(name: string): Nullable<Material>;
  84525. /**
  84526. * Gets the meshes bound to the material
  84527. * @returns an array of meshes bound to the material
  84528. */
  84529. getBindedMeshes(): AbstractMesh[];
  84530. /**
  84531. * Force shader compilation
  84532. * @param mesh defines the mesh associated with this material
  84533. * @param onCompiled defines a function to execute once the material is compiled
  84534. * @param options defines the options to configure the compilation
  84535. */
  84536. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84537. clipPlane: boolean;
  84538. }>): void;
  84539. /**
  84540. * Force shader compilation
  84541. * @param mesh defines the mesh that will use this material
  84542. * @param options defines additional options for compiling the shaders
  84543. * @returns a promise that resolves when the compilation completes
  84544. */
  84545. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84546. clipPlane: boolean;
  84547. }>): Promise<void>;
  84548. private static readonly _AllDirtyCallBack;
  84549. private static readonly _ImageProcessingDirtyCallBack;
  84550. private static readonly _TextureDirtyCallBack;
  84551. private static readonly _FresnelDirtyCallBack;
  84552. private static readonly _MiscDirtyCallBack;
  84553. private static readonly _LightsDirtyCallBack;
  84554. private static readonly _AttributeDirtyCallBack;
  84555. private static _FresnelAndMiscDirtyCallBack;
  84556. private static _TextureAndMiscDirtyCallBack;
  84557. private static readonly _DirtyCallbackArray;
  84558. private static readonly _RunDirtyCallBacks;
  84559. /**
  84560. * Marks a define in the material to indicate that it needs to be re-computed
  84561. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84562. */
  84563. markAsDirty(flag: number): void;
  84564. /**
  84565. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84566. * @param func defines a function which checks material defines against the submeshes
  84567. */
  84568. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84569. /**
  84570. * Indicates that we need to re-calculated for all submeshes
  84571. */
  84572. protected _markAllSubMeshesAsAllDirty(): void;
  84573. /**
  84574. * Indicates that image processing needs to be re-calculated for all submeshes
  84575. */
  84576. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84577. /**
  84578. * Indicates that textures need to be re-calculated for all submeshes
  84579. */
  84580. protected _markAllSubMeshesAsTexturesDirty(): void;
  84581. /**
  84582. * Indicates that fresnel needs to be re-calculated for all submeshes
  84583. */
  84584. protected _markAllSubMeshesAsFresnelDirty(): void;
  84585. /**
  84586. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84587. */
  84588. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84589. /**
  84590. * Indicates that lights need to be re-calculated for all submeshes
  84591. */
  84592. protected _markAllSubMeshesAsLightsDirty(): void;
  84593. /**
  84594. * Indicates that attributes need to be re-calculated for all submeshes
  84595. */
  84596. protected _markAllSubMeshesAsAttributesDirty(): void;
  84597. /**
  84598. * Indicates that misc needs to be re-calculated for all submeshes
  84599. */
  84600. protected _markAllSubMeshesAsMiscDirty(): void;
  84601. /**
  84602. * Indicates that textures and misc need to be re-calculated for all submeshes
  84603. */
  84604. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84605. /**
  84606. * Disposes the material
  84607. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84608. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84609. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84610. */
  84611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84612. /** @hidden */
  84613. private releaseVertexArrayObject;
  84614. /**
  84615. * Serializes this material
  84616. * @returns the serialized material object
  84617. */
  84618. serialize(): any;
  84619. /**
  84620. * Creates a material from parsed material data
  84621. * @param parsedMaterial defines parsed material data
  84622. * @param scene defines the hosting scene
  84623. * @param rootUrl defines the root URL to use to load textures
  84624. * @returns a new material
  84625. */
  84626. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84627. }
  84628. }
  84629. declare module BABYLON {
  84630. /**
  84631. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84632. * separate meshes. This can be use to improve performances.
  84633. * @see http://doc.babylonjs.com/how_to/multi_materials
  84634. */
  84635. export class MultiMaterial extends Material {
  84636. private _subMaterials;
  84637. /**
  84638. * Gets or Sets the list of Materials used within the multi material.
  84639. * They need to be ordered according to the submeshes order in the associated mesh
  84640. */
  84641. subMaterials: Nullable<Material>[];
  84642. /**
  84643. * Function used to align with Node.getChildren()
  84644. * @returns the list of Materials used within the multi material
  84645. */
  84646. getChildren(): Nullable<Material>[];
  84647. /**
  84648. * Instantiates a new Multi Material
  84649. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84650. * separate meshes. This can be use to improve performances.
  84651. * @see http://doc.babylonjs.com/how_to/multi_materials
  84652. * @param name Define the name in the scene
  84653. * @param scene Define the scene the material belongs to
  84654. */
  84655. constructor(name: string, scene: Scene);
  84656. private _hookArray;
  84657. /**
  84658. * Get one of the submaterial by its index in the submaterials array
  84659. * @param index The index to look the sub material at
  84660. * @returns The Material if the index has been defined
  84661. */
  84662. getSubMaterial(index: number): Nullable<Material>;
  84663. /**
  84664. * Get the list of active textures for the whole sub materials list.
  84665. * @returns All the textures that will be used during the rendering
  84666. */
  84667. getActiveTextures(): BaseTexture[];
  84668. /**
  84669. * Gets the current class name of the material e.g. "MultiMaterial"
  84670. * Mainly use in serialization.
  84671. * @returns the class name
  84672. */
  84673. getClassName(): string;
  84674. /**
  84675. * Checks if the material is ready to render the requested sub mesh
  84676. * @param mesh Define the mesh the submesh belongs to
  84677. * @param subMesh Define the sub mesh to look readyness for
  84678. * @param useInstances Define whether or not the material is used with instances
  84679. * @returns true if ready, otherwise false
  84680. */
  84681. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84682. /**
  84683. * Clones the current material and its related sub materials
  84684. * @param name Define the name of the newly cloned material
  84685. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84686. * @returns the cloned material
  84687. */
  84688. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84689. /**
  84690. * Serializes the materials into a JSON representation.
  84691. * @returns the JSON representation
  84692. */
  84693. serialize(): any;
  84694. /**
  84695. * Dispose the material and release its associated resources
  84696. * @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)
  84697. * @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)
  84698. * @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)
  84699. */
  84700. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84701. /**
  84702. * Creates a MultiMaterial from parsed MultiMaterial data.
  84703. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84704. * @param scene defines the hosting scene
  84705. * @returns a new MultiMaterial
  84706. */
  84707. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84708. }
  84709. }
  84710. declare module BABYLON {
  84711. /**
  84712. * Base class for submeshes
  84713. */
  84714. export class BaseSubMesh {
  84715. /** @hidden */
  84716. _materialDefines: Nullable<MaterialDefines>;
  84717. /** @hidden */
  84718. _materialEffect: Nullable<Effect>;
  84719. /**
  84720. * Gets associated effect
  84721. */
  84722. readonly effect: Nullable<Effect>;
  84723. /**
  84724. * Sets associated effect (effect used to render this submesh)
  84725. * @param effect defines the effect to associate with
  84726. * @param defines defines the set of defines used to compile this effect
  84727. */
  84728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84729. }
  84730. /**
  84731. * Defines a subdivision inside a mesh
  84732. */
  84733. export class SubMesh extends BaseSubMesh implements ICullable {
  84734. /** the material index to use */
  84735. materialIndex: number;
  84736. /** vertex index start */
  84737. verticesStart: number;
  84738. /** vertices count */
  84739. verticesCount: number;
  84740. /** index start */
  84741. indexStart: number;
  84742. /** indices count */
  84743. indexCount: number;
  84744. /** @hidden */
  84745. _linesIndexCount: number;
  84746. private _mesh;
  84747. private _renderingMesh;
  84748. private _boundingInfo;
  84749. private _linesIndexBuffer;
  84750. /** @hidden */
  84751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84752. /** @hidden */
  84753. _trianglePlanes: Plane[];
  84754. /** @hidden */
  84755. _lastColliderTransformMatrix: Nullable<Matrix>;
  84756. /** @hidden */
  84757. _renderId: number;
  84758. /** @hidden */
  84759. _alphaIndex: number;
  84760. /** @hidden */
  84761. _distanceToCamera: number;
  84762. /** @hidden */
  84763. _id: number;
  84764. private _currentMaterial;
  84765. /**
  84766. * Add a new submesh to a mesh
  84767. * @param materialIndex defines the material index to use
  84768. * @param verticesStart defines vertex index start
  84769. * @param verticesCount defines vertices count
  84770. * @param indexStart defines index start
  84771. * @param indexCount defines indices count
  84772. * @param mesh defines the parent mesh
  84773. * @param renderingMesh defines an optional rendering mesh
  84774. * @param createBoundingBox defines if bounding box should be created for this submesh
  84775. * @returns the new submesh
  84776. */
  84777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84778. /**
  84779. * Creates a new submesh
  84780. * @param materialIndex defines the material index to use
  84781. * @param verticesStart defines vertex index start
  84782. * @param verticesCount defines vertices count
  84783. * @param indexStart defines index start
  84784. * @param indexCount defines indices count
  84785. * @param mesh defines the parent mesh
  84786. * @param renderingMesh defines an optional rendering mesh
  84787. * @param createBoundingBox defines if bounding box should be created for this submesh
  84788. */
  84789. constructor(
  84790. /** the material index to use */
  84791. materialIndex: number,
  84792. /** vertex index start */
  84793. verticesStart: number,
  84794. /** vertices count */
  84795. verticesCount: number,
  84796. /** index start */
  84797. indexStart: number,
  84798. /** indices count */
  84799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84800. /**
  84801. * Returns true if this submesh covers the entire parent mesh
  84802. * @ignorenaming
  84803. */
  84804. readonly IsGlobal: boolean;
  84805. /**
  84806. * Returns the submesh BoudingInfo object
  84807. * @returns current bounding info (or mesh's one if the submesh is global)
  84808. */
  84809. getBoundingInfo(): BoundingInfo;
  84810. /**
  84811. * Sets the submesh BoundingInfo
  84812. * @param boundingInfo defines the new bounding info to use
  84813. * @returns the SubMesh
  84814. */
  84815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84816. /**
  84817. * Returns the mesh of the current submesh
  84818. * @return the parent mesh
  84819. */
  84820. getMesh(): AbstractMesh;
  84821. /**
  84822. * Returns the rendering mesh of the submesh
  84823. * @returns the rendering mesh (could be different from parent mesh)
  84824. */
  84825. getRenderingMesh(): Mesh;
  84826. /**
  84827. * Returns the submesh material
  84828. * @returns null or the current material
  84829. */
  84830. getMaterial(): Nullable<Material>;
  84831. /**
  84832. * Sets a new updated BoundingInfo object to the submesh
  84833. * @param data defines an optional position array to use to determine the bounding info
  84834. * @returns the SubMesh
  84835. */
  84836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84837. /** @hidden */
  84838. _checkCollision(collider: Collider): boolean;
  84839. /**
  84840. * Updates the submesh BoundingInfo
  84841. * @param world defines the world matrix to use to update the bounding info
  84842. * @returns the submesh
  84843. */
  84844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84845. /**
  84846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84847. * @param frustumPlanes defines the frustum planes
  84848. * @returns true if the submesh is intersecting with the frustum
  84849. */
  84850. isInFrustum(frustumPlanes: Plane[]): boolean;
  84851. /**
  84852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84853. * @param frustumPlanes defines the frustum planes
  84854. * @returns true if the submesh is inside the frustum
  84855. */
  84856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84857. /**
  84858. * Renders the submesh
  84859. * @param enableAlphaMode defines if alpha needs to be used
  84860. * @returns the submesh
  84861. */
  84862. render(enableAlphaMode: boolean): SubMesh;
  84863. /**
  84864. * @hidden
  84865. */
  84866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84867. /**
  84868. * Checks if the submesh intersects with a ray
  84869. * @param ray defines the ray to test
  84870. * @returns true is the passed ray intersects the submesh bounding box
  84871. */
  84872. canIntersects(ray: Ray): boolean;
  84873. /**
  84874. * Intersects current submesh with a ray
  84875. * @param ray defines the ray to test
  84876. * @param positions defines mesh's positions array
  84877. * @param indices defines mesh's indices array
  84878. * @param fastCheck defines if only bounding info should be used
  84879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84880. * @returns intersection info or null if no intersection
  84881. */
  84882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84883. /** @hidden */
  84884. private _intersectLines;
  84885. /** @hidden */
  84886. private _intersectUnIndexedLines;
  84887. /** @hidden */
  84888. private _intersectTriangles;
  84889. /** @hidden */
  84890. private _intersectUnIndexedTriangles;
  84891. /** @hidden */
  84892. _rebuild(): void;
  84893. /**
  84894. * Creates a new submesh from the passed mesh
  84895. * @param newMesh defines the new hosting mesh
  84896. * @param newRenderingMesh defines an optional rendering mesh
  84897. * @returns the new submesh
  84898. */
  84899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84900. /**
  84901. * Release associated resources
  84902. */
  84903. dispose(): void;
  84904. /**
  84905. * Gets the class name
  84906. * @returns the string "SubMesh".
  84907. */
  84908. getClassName(): string;
  84909. /**
  84910. * Creates a new submesh from indices data
  84911. * @param materialIndex the index of the main mesh material
  84912. * @param startIndex the index where to start the copy in the mesh indices array
  84913. * @param indexCount the number of indices to copy then from the startIndex
  84914. * @param mesh the main mesh to create the submesh from
  84915. * @param renderingMesh the optional rendering mesh
  84916. * @returns a new submesh
  84917. */
  84918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84919. }
  84920. }
  84921. declare module BABYLON {
  84922. /**
  84923. * Class used to represent data loading progression
  84924. */
  84925. export class SceneLoaderFlags {
  84926. private static _ForceFullSceneLoadingForIncremental;
  84927. private static _ShowLoadingScreen;
  84928. private static _CleanBoneMatrixWeights;
  84929. private static _loggingLevel;
  84930. /**
  84931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84932. */
  84933. static ForceFullSceneLoadingForIncremental: boolean;
  84934. /**
  84935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84936. */
  84937. static ShowLoadingScreen: boolean;
  84938. /**
  84939. * Defines the current logging level (while loading the scene)
  84940. * @ignorenaming
  84941. */
  84942. static loggingLevel: number;
  84943. /**
  84944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84945. */
  84946. static CleanBoneMatrixWeights: boolean;
  84947. }
  84948. }
  84949. declare module BABYLON {
  84950. /**
  84951. * Class used to store geometry data (vertex buffers + index buffer)
  84952. */
  84953. export class Geometry implements IGetSetVerticesData {
  84954. /**
  84955. * Gets or sets the ID of the geometry
  84956. */
  84957. id: string;
  84958. /**
  84959. * Gets or sets the unique ID of the geometry
  84960. */
  84961. uniqueId: number;
  84962. /**
  84963. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84964. */
  84965. delayLoadState: number;
  84966. /**
  84967. * Gets the file containing the data to load when running in delay load state
  84968. */
  84969. delayLoadingFile: Nullable<string>;
  84970. /**
  84971. * Callback called when the geometry is updated
  84972. */
  84973. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84974. private _scene;
  84975. private _engine;
  84976. private _meshes;
  84977. private _totalVertices;
  84978. /** @hidden */
  84979. _indices: IndicesArray;
  84980. /** @hidden */
  84981. _vertexBuffers: {
  84982. [key: string]: VertexBuffer;
  84983. };
  84984. private _isDisposed;
  84985. private _extend;
  84986. private _boundingBias;
  84987. /** @hidden */
  84988. _delayInfo: Array<string>;
  84989. private _indexBuffer;
  84990. private _indexBufferIsUpdatable;
  84991. /** @hidden */
  84992. _boundingInfo: Nullable<BoundingInfo>;
  84993. /** @hidden */
  84994. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84995. /** @hidden */
  84996. _softwareSkinningFrameId: number;
  84997. private _vertexArrayObjects;
  84998. private _updatable;
  84999. /** @hidden */
  85000. _positions: Nullable<Vector3[]>;
  85001. /**
  85002. * 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
  85003. */
  85004. /**
  85005. * 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
  85006. */
  85007. boundingBias: Vector2;
  85008. /**
  85009. * Static function used to attach a new empty geometry to a mesh
  85010. * @param mesh defines the mesh to attach the geometry to
  85011. * @returns the new Geometry
  85012. */
  85013. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85014. /**
  85015. * Creates a new geometry
  85016. * @param id defines the unique ID
  85017. * @param scene defines the hosting scene
  85018. * @param vertexData defines the VertexData used to get geometry data
  85019. * @param updatable defines if geometry must be updatable (false by default)
  85020. * @param mesh defines the mesh that will be associated with the geometry
  85021. */
  85022. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85023. /**
  85024. * Gets the current extend of the geometry
  85025. */
  85026. readonly extend: {
  85027. minimum: Vector3;
  85028. maximum: Vector3;
  85029. };
  85030. /**
  85031. * Gets the hosting scene
  85032. * @returns the hosting Scene
  85033. */
  85034. getScene(): Scene;
  85035. /**
  85036. * Gets the hosting engine
  85037. * @returns the hosting Engine
  85038. */
  85039. getEngine(): Engine;
  85040. /**
  85041. * Defines if the geometry is ready to use
  85042. * @returns true if the geometry is ready to be used
  85043. */
  85044. isReady(): boolean;
  85045. /**
  85046. * Gets a value indicating that the geometry should not be serialized
  85047. */
  85048. readonly doNotSerialize: boolean;
  85049. /** @hidden */
  85050. _rebuild(): void;
  85051. /**
  85052. * Affects all geometry data in one call
  85053. * @param vertexData defines the geometry data
  85054. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85055. */
  85056. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85057. /**
  85058. * Set specific vertex data
  85059. * @param kind defines the data kind (Position, normal, etc...)
  85060. * @param data defines the vertex data to use
  85061. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85062. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85063. */
  85064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85065. /**
  85066. * Removes a specific vertex data
  85067. * @param kind defines the data kind (Position, normal, etc...)
  85068. */
  85069. removeVerticesData(kind: string): void;
  85070. /**
  85071. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85072. * @param buffer defines the vertex buffer to use
  85073. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85074. */
  85075. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85076. /**
  85077. * Update a specific vertex buffer
  85078. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85079. * It will do nothing if the buffer is not updatable
  85080. * @param kind defines the data kind (Position, normal, etc...)
  85081. * @param data defines the data to use
  85082. * @param offset defines the offset in the target buffer where to store the data
  85083. * @param useBytes set to true if the offset is in bytes
  85084. */
  85085. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85086. /**
  85087. * Update a specific vertex buffer
  85088. * This function will create a new buffer if the current one is not updatable
  85089. * @param kind defines the data kind (Position, normal, etc...)
  85090. * @param data defines the data to use
  85091. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85092. */
  85093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85094. private _updateBoundingInfo;
  85095. /** @hidden */
  85096. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85097. /**
  85098. * Gets total number of vertices
  85099. * @returns the total number of vertices
  85100. */
  85101. getTotalVertices(): number;
  85102. /**
  85103. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85104. * @param kind defines the data kind (Position, normal, etc...)
  85105. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85106. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85107. * @returns a float array containing vertex data
  85108. */
  85109. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85110. /**
  85111. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85112. * @param kind defines the data kind (Position, normal, etc...)
  85113. * @returns true if the vertex buffer with the specified kind is updatable
  85114. */
  85115. isVertexBufferUpdatable(kind: string): boolean;
  85116. /**
  85117. * Gets a specific vertex buffer
  85118. * @param kind defines the data kind (Position, normal, etc...)
  85119. * @returns a VertexBuffer
  85120. */
  85121. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85122. /**
  85123. * Returns all vertex buffers
  85124. * @return an object holding all vertex buffers indexed by kind
  85125. */
  85126. getVertexBuffers(): Nullable<{
  85127. [key: string]: VertexBuffer;
  85128. }>;
  85129. /**
  85130. * Gets a boolean indicating if specific vertex buffer is present
  85131. * @param kind defines the data kind (Position, normal, etc...)
  85132. * @returns true if data is present
  85133. */
  85134. isVerticesDataPresent(kind: string): boolean;
  85135. /**
  85136. * Gets a list of all attached data kinds (Position, normal, etc...)
  85137. * @returns a list of string containing all kinds
  85138. */
  85139. getVerticesDataKinds(): string[];
  85140. /**
  85141. * Update index buffer
  85142. * @param indices defines the indices to store in the index buffer
  85143. * @param offset defines the offset in the target buffer where to store the data
  85144. * @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)
  85145. */
  85146. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85147. /**
  85148. * Creates a new index buffer
  85149. * @param indices defines the indices to store in the index buffer
  85150. * @param totalVertices defines the total number of vertices (could be null)
  85151. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85152. */
  85153. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85154. /**
  85155. * Return the total number of indices
  85156. * @returns the total number of indices
  85157. */
  85158. getTotalIndices(): number;
  85159. /**
  85160. * Gets the index buffer array
  85161. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85162. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85163. * @returns the index buffer array
  85164. */
  85165. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85166. /**
  85167. * Gets the index buffer
  85168. * @return the index buffer
  85169. */
  85170. getIndexBuffer(): Nullable<DataBuffer>;
  85171. /** @hidden */
  85172. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85173. /**
  85174. * Release the associated resources for a specific mesh
  85175. * @param mesh defines the source mesh
  85176. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85177. */
  85178. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85179. /**
  85180. * Apply current geometry to a given mesh
  85181. * @param mesh defines the mesh to apply geometry to
  85182. */
  85183. applyToMesh(mesh: Mesh): void;
  85184. private _updateExtend;
  85185. private _applyToMesh;
  85186. private notifyUpdate;
  85187. /**
  85188. * Load the geometry if it was flagged as delay loaded
  85189. * @param scene defines the hosting scene
  85190. * @param onLoaded defines a callback called when the geometry is loaded
  85191. */
  85192. load(scene: Scene, onLoaded?: () => void): void;
  85193. private _queueLoad;
  85194. /**
  85195. * Invert the geometry to move from a right handed system to a left handed one.
  85196. */
  85197. toLeftHanded(): void;
  85198. /** @hidden */
  85199. _resetPointsArrayCache(): void;
  85200. /** @hidden */
  85201. _generatePointsArray(): boolean;
  85202. /**
  85203. * Gets a value indicating if the geometry is disposed
  85204. * @returns true if the geometry was disposed
  85205. */
  85206. isDisposed(): boolean;
  85207. private _disposeVertexArrayObjects;
  85208. /**
  85209. * Free all associated resources
  85210. */
  85211. dispose(): void;
  85212. /**
  85213. * Clone the current geometry into a new geometry
  85214. * @param id defines the unique ID of the new geometry
  85215. * @returns a new geometry object
  85216. */
  85217. copy(id: string): Geometry;
  85218. /**
  85219. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85220. * @return a JSON representation of the current geometry data (without the vertices data)
  85221. */
  85222. serialize(): any;
  85223. private toNumberArray;
  85224. /**
  85225. * Serialize all vertices data into a JSON oject
  85226. * @returns a JSON representation of the current geometry data
  85227. */
  85228. serializeVerticeData(): any;
  85229. /**
  85230. * Extracts a clone of a mesh geometry
  85231. * @param mesh defines the source mesh
  85232. * @param id defines the unique ID of the new geometry object
  85233. * @returns the new geometry object
  85234. */
  85235. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85236. /**
  85237. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85238. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85239. * Be aware Math.random() could cause collisions, but:
  85240. * "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"
  85241. * @returns a string containing a new GUID
  85242. */
  85243. static RandomId(): string;
  85244. /** @hidden */
  85245. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85246. private static _CleanMatricesWeights;
  85247. /**
  85248. * Create a new geometry from persisted data (Using .babylon file format)
  85249. * @param parsedVertexData defines the persisted data
  85250. * @param scene defines the hosting scene
  85251. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85252. * @returns the new geometry object
  85253. */
  85254. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85255. }
  85256. }
  85257. declare module BABYLON {
  85258. /**
  85259. * Define an interface for all classes that will get and set the data on vertices
  85260. */
  85261. export interface IGetSetVerticesData {
  85262. /**
  85263. * Gets a boolean indicating if specific vertex data is present
  85264. * @param kind defines the vertex data kind to use
  85265. * @returns true is data kind is present
  85266. */
  85267. isVerticesDataPresent(kind: string): boolean;
  85268. /**
  85269. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85270. * @param kind defines the data kind (Position, normal, etc...)
  85271. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85272. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85273. * @returns a float array containing vertex data
  85274. */
  85275. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85276. /**
  85277. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85278. * @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.
  85279. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85280. * @returns the indices array or an empty array if the mesh has no geometry
  85281. */
  85282. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85283. /**
  85284. * Set specific vertex data
  85285. * @param kind defines the data kind (Position, normal, etc...)
  85286. * @param data defines the vertex data to use
  85287. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85288. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85289. */
  85290. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85291. /**
  85292. * Update a specific associated vertex buffer
  85293. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85294. * - VertexBuffer.PositionKind
  85295. * - VertexBuffer.UVKind
  85296. * - VertexBuffer.UV2Kind
  85297. * - VertexBuffer.UV3Kind
  85298. * - VertexBuffer.UV4Kind
  85299. * - VertexBuffer.UV5Kind
  85300. * - VertexBuffer.UV6Kind
  85301. * - VertexBuffer.ColorKind
  85302. * - VertexBuffer.MatricesIndicesKind
  85303. * - VertexBuffer.MatricesIndicesExtraKind
  85304. * - VertexBuffer.MatricesWeightsKind
  85305. * - VertexBuffer.MatricesWeightsExtraKind
  85306. * @param data defines the data source
  85307. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85308. * @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)
  85309. */
  85310. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85311. /**
  85312. * Creates a new index buffer
  85313. * @param indices defines the indices to store in the index buffer
  85314. * @param totalVertices defines the total number of vertices (could be null)
  85315. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85316. */
  85317. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85318. }
  85319. /**
  85320. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85321. */
  85322. export class VertexData {
  85323. /**
  85324. * Mesh side orientation : usually the external or front surface
  85325. */
  85326. static readonly FRONTSIDE: number;
  85327. /**
  85328. * Mesh side orientation : usually the internal or back surface
  85329. */
  85330. static readonly BACKSIDE: number;
  85331. /**
  85332. * Mesh side orientation : both internal and external or front and back surfaces
  85333. */
  85334. static readonly DOUBLESIDE: number;
  85335. /**
  85336. * Mesh side orientation : by default, `FRONTSIDE`
  85337. */
  85338. static readonly DEFAULTSIDE: number;
  85339. /**
  85340. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85341. */
  85342. positions: Nullable<FloatArray>;
  85343. /**
  85344. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85345. */
  85346. normals: Nullable<FloatArray>;
  85347. /**
  85348. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85349. */
  85350. tangents: Nullable<FloatArray>;
  85351. /**
  85352. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85353. */
  85354. uvs: Nullable<FloatArray>;
  85355. /**
  85356. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85357. */
  85358. uvs2: Nullable<FloatArray>;
  85359. /**
  85360. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85361. */
  85362. uvs3: Nullable<FloatArray>;
  85363. /**
  85364. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85365. */
  85366. uvs4: Nullable<FloatArray>;
  85367. /**
  85368. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85369. */
  85370. uvs5: Nullable<FloatArray>;
  85371. /**
  85372. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85373. */
  85374. uvs6: Nullable<FloatArray>;
  85375. /**
  85376. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85377. */
  85378. colors: Nullable<FloatArray>;
  85379. /**
  85380. * 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).
  85381. */
  85382. matricesIndices: Nullable<FloatArray>;
  85383. /**
  85384. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85385. */
  85386. matricesWeights: Nullable<FloatArray>;
  85387. /**
  85388. * An array extending the number of possible indices
  85389. */
  85390. matricesIndicesExtra: Nullable<FloatArray>;
  85391. /**
  85392. * An array extending the number of possible weights when the number of indices is extended
  85393. */
  85394. matricesWeightsExtra: Nullable<FloatArray>;
  85395. /**
  85396. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85397. */
  85398. indices: Nullable<IndicesArray>;
  85399. /**
  85400. * Uses the passed data array to set the set the values for the specified kind of data
  85401. * @param data a linear array of floating numbers
  85402. * @param kind the type of data that is being set, eg positions, colors etc
  85403. */
  85404. set(data: FloatArray, kind: string): void;
  85405. /**
  85406. * Associates the vertexData to the passed Mesh.
  85407. * Sets it as updatable or not (default `false`)
  85408. * @param mesh the mesh the vertexData is applied to
  85409. * @param updatable when used and having the value true allows new data to update the vertexData
  85410. * @returns the VertexData
  85411. */
  85412. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85413. /**
  85414. * Associates the vertexData to the passed Geometry.
  85415. * Sets it as updatable or not (default `false`)
  85416. * @param geometry the geometry the vertexData is applied to
  85417. * @param updatable when used and having the value true allows new data to update the vertexData
  85418. * @returns VertexData
  85419. */
  85420. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85421. /**
  85422. * Updates the associated mesh
  85423. * @param mesh the mesh to be updated
  85424. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85425. * @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
  85426. * @returns VertexData
  85427. */
  85428. updateMesh(mesh: Mesh): VertexData;
  85429. /**
  85430. * Updates the associated geometry
  85431. * @param geometry the geometry to be updated
  85432. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85433. * @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
  85434. * @returns VertexData.
  85435. */
  85436. updateGeometry(geometry: Geometry): VertexData;
  85437. private _applyTo;
  85438. private _update;
  85439. /**
  85440. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85441. * @param matrix the transforming matrix
  85442. * @returns the VertexData
  85443. */
  85444. transform(matrix: Matrix): VertexData;
  85445. /**
  85446. * Merges the passed VertexData into the current one
  85447. * @param other the VertexData to be merged into the current one
  85448. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85449. * @returns the modified VertexData
  85450. */
  85451. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85452. private _mergeElement;
  85453. private _validate;
  85454. /**
  85455. * Serializes the VertexData
  85456. * @returns a serialized object
  85457. */
  85458. serialize(): any;
  85459. /**
  85460. * Extracts the vertexData from a mesh
  85461. * @param mesh the mesh from which to extract the VertexData
  85462. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85463. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85464. * @returns the object VertexData associated to the passed mesh
  85465. */
  85466. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85467. /**
  85468. * Extracts the vertexData from the geometry
  85469. * @param geometry the geometry from which to extract the VertexData
  85470. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85471. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85472. * @returns the object VertexData associated to the passed mesh
  85473. */
  85474. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85475. private static _ExtractFrom;
  85476. /**
  85477. * Creates the VertexData for a Ribbon
  85478. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85479. * * pathArray array of paths, each of which an array of successive Vector3
  85480. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85481. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85482. * * 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
  85483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85484. * * 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)
  85485. * * 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)
  85486. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85487. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85488. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85489. * @returns the VertexData of the ribbon
  85490. */
  85491. static CreateRibbon(options: {
  85492. pathArray: Vector3[][];
  85493. closeArray?: boolean;
  85494. closePath?: boolean;
  85495. offset?: number;
  85496. sideOrientation?: number;
  85497. frontUVs?: Vector4;
  85498. backUVs?: Vector4;
  85499. invertUV?: boolean;
  85500. uvs?: Vector2[];
  85501. colors?: Color4[];
  85502. }): VertexData;
  85503. /**
  85504. * Creates the VertexData for a box
  85505. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85506. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85507. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85508. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85509. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85510. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85511. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85513. * * 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)
  85514. * * 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)
  85515. * @returns the VertexData of the box
  85516. */
  85517. static CreateBox(options: {
  85518. size?: number;
  85519. width?: number;
  85520. height?: number;
  85521. depth?: number;
  85522. faceUV?: Vector4[];
  85523. faceColors?: Color4[];
  85524. sideOrientation?: number;
  85525. frontUVs?: Vector4;
  85526. backUVs?: Vector4;
  85527. }): VertexData;
  85528. /**
  85529. * Creates the VertexData for a tiled box
  85530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85531. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85532. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85533. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85535. * @returns the VertexData of the box
  85536. */
  85537. static CreateTiledBox(options: {
  85538. pattern?: number;
  85539. width?: number;
  85540. height?: number;
  85541. depth?: number;
  85542. tileSize?: number;
  85543. tileWidth?: number;
  85544. tileHeight?: number;
  85545. alignHorizontal?: number;
  85546. alignVertical?: number;
  85547. faceUV?: Vector4[];
  85548. faceColors?: Color4[];
  85549. sideOrientation?: number;
  85550. }): VertexData;
  85551. /**
  85552. * Creates the VertexData for a tiled plane
  85553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85554. * * pattern a limited pattern arrangement depending on the number
  85555. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85556. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85557. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85559. * * 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)
  85560. * * 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)
  85561. * @returns the VertexData of the tiled plane
  85562. */
  85563. static CreateTiledPlane(options: {
  85564. pattern?: number;
  85565. tileSize?: number;
  85566. tileWidth?: number;
  85567. tileHeight?: number;
  85568. size?: number;
  85569. width?: number;
  85570. height?: number;
  85571. alignHorizontal?: number;
  85572. alignVertical?: number;
  85573. sideOrientation?: number;
  85574. frontUVs?: Vector4;
  85575. backUVs?: Vector4;
  85576. }): VertexData;
  85577. /**
  85578. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85580. * * segments sets the number of horizontal strips optional, default 32
  85581. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85582. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85583. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85584. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85585. * * 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
  85586. * * 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
  85587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85588. * * 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)
  85589. * * 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)
  85590. * @returns the VertexData of the ellipsoid
  85591. */
  85592. static CreateSphere(options: {
  85593. segments?: number;
  85594. diameter?: number;
  85595. diameterX?: number;
  85596. diameterY?: number;
  85597. diameterZ?: number;
  85598. arc?: number;
  85599. slice?: number;
  85600. sideOrientation?: number;
  85601. frontUVs?: Vector4;
  85602. backUVs?: Vector4;
  85603. }): VertexData;
  85604. /**
  85605. * Creates the VertexData for a cylinder, cone or prism
  85606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85607. * * height sets the height (y direction) of the cylinder, optional, default 2
  85608. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85609. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85610. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85611. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85612. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85613. * * 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
  85614. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85615. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85616. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85617. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85619. * * 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)
  85620. * * 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)
  85621. * @returns the VertexData of the cylinder, cone or prism
  85622. */
  85623. static CreateCylinder(options: {
  85624. height?: number;
  85625. diameterTop?: number;
  85626. diameterBottom?: number;
  85627. diameter?: number;
  85628. tessellation?: number;
  85629. subdivisions?: number;
  85630. arc?: number;
  85631. faceColors?: Color4[];
  85632. faceUV?: Vector4[];
  85633. hasRings?: boolean;
  85634. enclose?: boolean;
  85635. sideOrientation?: number;
  85636. frontUVs?: Vector4;
  85637. backUVs?: Vector4;
  85638. }): VertexData;
  85639. /**
  85640. * Creates the VertexData for a torus
  85641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85642. * * diameter the diameter of the torus, optional default 1
  85643. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85644. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85646. * * 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)
  85647. * * 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)
  85648. * @returns the VertexData of the torus
  85649. */
  85650. static CreateTorus(options: {
  85651. diameter?: number;
  85652. thickness?: number;
  85653. tessellation?: number;
  85654. sideOrientation?: number;
  85655. frontUVs?: Vector4;
  85656. backUVs?: Vector4;
  85657. }): VertexData;
  85658. /**
  85659. * Creates the VertexData of the LineSystem
  85660. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85661. * - lines an array of lines, each line being an array of successive Vector3
  85662. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85663. * @returns the VertexData of the LineSystem
  85664. */
  85665. static CreateLineSystem(options: {
  85666. lines: Vector3[][];
  85667. colors?: Nullable<Color4[][]>;
  85668. }): VertexData;
  85669. /**
  85670. * Create the VertexData for a DashedLines
  85671. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85672. * - points an array successive Vector3
  85673. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85674. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85675. * - dashNb the intended total number of dashes, optional, default 200
  85676. * @returns the VertexData for the DashedLines
  85677. */
  85678. static CreateDashedLines(options: {
  85679. points: Vector3[];
  85680. dashSize?: number;
  85681. gapSize?: number;
  85682. dashNb?: number;
  85683. }): VertexData;
  85684. /**
  85685. * Creates the VertexData for a Ground
  85686. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85687. * - width the width (x direction) of the ground, optional, default 1
  85688. * - height the height (z direction) of the ground, optional, default 1
  85689. * - subdivisions the number of subdivisions per side, optional, default 1
  85690. * @returns the VertexData of the Ground
  85691. */
  85692. static CreateGround(options: {
  85693. width?: number;
  85694. height?: number;
  85695. subdivisions?: number;
  85696. subdivisionsX?: number;
  85697. subdivisionsY?: number;
  85698. }): VertexData;
  85699. /**
  85700. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85702. * * xmin the ground minimum X coordinate, optional, default -1
  85703. * * zmin the ground minimum Z coordinate, optional, default -1
  85704. * * xmax the ground maximum X coordinate, optional, default 1
  85705. * * zmax the ground maximum Z coordinate, optional, default 1
  85706. * * 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}
  85707. * * 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}
  85708. * @returns the VertexData of the TiledGround
  85709. */
  85710. static CreateTiledGround(options: {
  85711. xmin: number;
  85712. zmin: number;
  85713. xmax: number;
  85714. zmax: number;
  85715. subdivisions?: {
  85716. w: number;
  85717. h: number;
  85718. };
  85719. precision?: {
  85720. w: number;
  85721. h: number;
  85722. };
  85723. }): VertexData;
  85724. /**
  85725. * Creates the VertexData of the Ground designed from a heightmap
  85726. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85727. * * width the width (x direction) of the ground
  85728. * * height the height (z direction) of the ground
  85729. * * subdivisions the number of subdivisions per side
  85730. * * minHeight the minimum altitude on the ground, optional, default 0
  85731. * * maxHeight the maximum altitude on the ground, optional default 1
  85732. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85733. * * buffer the array holding the image color data
  85734. * * bufferWidth the width of image
  85735. * * bufferHeight the height of image
  85736. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85737. * @returns the VertexData of the Ground designed from a heightmap
  85738. */
  85739. static CreateGroundFromHeightMap(options: {
  85740. width: number;
  85741. height: number;
  85742. subdivisions: number;
  85743. minHeight: number;
  85744. maxHeight: number;
  85745. colorFilter: Color3;
  85746. buffer: Uint8Array;
  85747. bufferWidth: number;
  85748. bufferHeight: number;
  85749. alphaFilter: number;
  85750. }): VertexData;
  85751. /**
  85752. * Creates the VertexData for a Plane
  85753. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85754. * * size sets the width and height of the plane to the value of size, optional default 1
  85755. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85756. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85758. * * 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)
  85759. * * 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)
  85760. * @returns the VertexData of the box
  85761. */
  85762. static CreatePlane(options: {
  85763. size?: number;
  85764. width?: number;
  85765. height?: number;
  85766. sideOrientation?: number;
  85767. frontUVs?: Vector4;
  85768. backUVs?: Vector4;
  85769. }): VertexData;
  85770. /**
  85771. * Creates the VertexData of the Disc or regular Polygon
  85772. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85773. * * radius the radius of the disc, optional default 0.5
  85774. * * tessellation the number of polygon sides, optional, default 64
  85775. * * 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
  85776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85777. * * 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)
  85778. * * 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)
  85779. * @returns the VertexData of the box
  85780. */
  85781. static CreateDisc(options: {
  85782. radius?: number;
  85783. tessellation?: number;
  85784. arc?: number;
  85785. sideOrientation?: number;
  85786. frontUVs?: Vector4;
  85787. backUVs?: Vector4;
  85788. }): VertexData;
  85789. /**
  85790. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85791. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85792. * @param polygon a mesh built from polygonTriangulation.build()
  85793. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85794. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85795. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85796. * @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)
  85797. * @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)
  85798. * @returns the VertexData of the Polygon
  85799. */
  85800. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85801. /**
  85802. * Creates the VertexData of the IcoSphere
  85803. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85804. * * radius the radius of the IcoSphere, optional default 1
  85805. * * radiusX allows stretching in the x direction, optional, default radius
  85806. * * radiusY allows stretching in the y direction, optional, default radius
  85807. * * radiusZ allows stretching in the z direction, optional, default radius
  85808. * * flat when true creates a flat shaded mesh, optional, default true
  85809. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85811. * * 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)
  85812. * * 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)
  85813. * @returns the VertexData of the IcoSphere
  85814. */
  85815. static CreateIcoSphere(options: {
  85816. radius?: number;
  85817. radiusX?: number;
  85818. radiusY?: number;
  85819. radiusZ?: number;
  85820. flat?: boolean;
  85821. subdivisions?: number;
  85822. sideOrientation?: number;
  85823. frontUVs?: Vector4;
  85824. backUVs?: Vector4;
  85825. }): VertexData;
  85826. /**
  85827. * Creates the VertexData for a Polyhedron
  85828. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85829. * * type provided types are:
  85830. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85831. * * 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)
  85832. * * size the size of the IcoSphere, optional default 1
  85833. * * sizeX allows stretching in the x direction, optional, default size
  85834. * * sizeY allows stretching in the y direction, optional, default size
  85835. * * sizeZ allows stretching in the z direction, optional, default size
  85836. * * 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
  85837. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85838. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85839. * * flat when true creates a flat shaded mesh, optional, default true
  85840. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85842. * * 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)
  85843. * * 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)
  85844. * @returns the VertexData of the Polyhedron
  85845. */
  85846. static CreatePolyhedron(options: {
  85847. type?: number;
  85848. size?: number;
  85849. sizeX?: number;
  85850. sizeY?: number;
  85851. sizeZ?: number;
  85852. custom?: any;
  85853. faceUV?: Vector4[];
  85854. faceColors?: Color4[];
  85855. flat?: boolean;
  85856. sideOrientation?: number;
  85857. frontUVs?: Vector4;
  85858. backUVs?: Vector4;
  85859. }): VertexData;
  85860. /**
  85861. * Creates the VertexData for a TorusKnot
  85862. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85863. * * radius the radius of the torus knot, optional, default 2
  85864. * * tube the thickness of the tube, optional, default 0.5
  85865. * * radialSegments the number of sides on each tube segments, optional, default 32
  85866. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85867. * * p the number of windings around the z axis, optional, default 2
  85868. * * q the number of windings around the x axis, optional, default 3
  85869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85870. * * 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)
  85871. * * 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)
  85872. * @returns the VertexData of the Torus Knot
  85873. */
  85874. static CreateTorusKnot(options: {
  85875. radius?: number;
  85876. tube?: number;
  85877. radialSegments?: number;
  85878. tubularSegments?: number;
  85879. p?: number;
  85880. q?: number;
  85881. sideOrientation?: number;
  85882. frontUVs?: Vector4;
  85883. backUVs?: Vector4;
  85884. }): VertexData;
  85885. /**
  85886. * Compute normals for given positions and indices
  85887. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85888. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85889. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85890. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85891. * * facetNormals : optional array of facet normals (vector3)
  85892. * * facetPositions : optional array of facet positions (vector3)
  85893. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85894. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85895. * * bInfo : optional bounding info, required for facetPartitioning computation
  85896. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85897. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85898. * * useRightHandedSystem: optional boolean to for right handed system computation
  85899. * * depthSort : optional boolean to enable the facet depth sort computation
  85900. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85901. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85902. */
  85903. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85904. facetNormals?: any;
  85905. facetPositions?: any;
  85906. facetPartitioning?: any;
  85907. ratio?: number;
  85908. bInfo?: any;
  85909. bbSize?: Vector3;
  85910. subDiv?: any;
  85911. useRightHandedSystem?: boolean;
  85912. depthSort?: boolean;
  85913. distanceTo?: Vector3;
  85914. depthSortedFacets?: any;
  85915. }): void;
  85916. /** @hidden */
  85917. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85918. /**
  85919. * Applies VertexData created from the imported parameters to the geometry
  85920. * @param parsedVertexData the parsed data from an imported file
  85921. * @param geometry the geometry to apply the VertexData to
  85922. */
  85923. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85924. }
  85925. }
  85926. declare module BABYLON {
  85927. /**
  85928. * Defines a target to use with MorphTargetManager
  85929. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85930. */
  85931. export class MorphTarget implements IAnimatable {
  85932. /** defines the name of the target */
  85933. name: string;
  85934. /**
  85935. * Gets or sets the list of animations
  85936. */
  85937. animations: Animation[];
  85938. private _scene;
  85939. private _positions;
  85940. private _normals;
  85941. private _tangents;
  85942. private _uvs;
  85943. private _influence;
  85944. /**
  85945. * Observable raised when the influence changes
  85946. */
  85947. onInfluenceChanged: Observable<boolean>;
  85948. /** @hidden */
  85949. _onDataLayoutChanged: Observable<void>;
  85950. /**
  85951. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85952. */
  85953. influence: number;
  85954. /**
  85955. * Gets or sets the id of the morph Target
  85956. */
  85957. id: string;
  85958. private _animationPropertiesOverride;
  85959. /**
  85960. * Gets or sets the animation properties override
  85961. */
  85962. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85963. /**
  85964. * Creates a new MorphTarget
  85965. * @param name defines the name of the target
  85966. * @param influence defines the influence to use
  85967. * @param scene defines the scene the morphtarget belongs to
  85968. */
  85969. constructor(
  85970. /** defines the name of the target */
  85971. name: string, influence?: number, scene?: Nullable<Scene>);
  85972. /**
  85973. * Gets a boolean defining if the target contains position data
  85974. */
  85975. readonly hasPositions: boolean;
  85976. /**
  85977. * Gets a boolean defining if the target contains normal data
  85978. */
  85979. readonly hasNormals: boolean;
  85980. /**
  85981. * Gets a boolean defining if the target contains tangent data
  85982. */
  85983. readonly hasTangents: boolean;
  85984. /**
  85985. * Gets a boolean defining if the target contains texture coordinates data
  85986. */
  85987. readonly hasUVs: boolean;
  85988. /**
  85989. * Affects position data to this target
  85990. * @param data defines the position data to use
  85991. */
  85992. setPositions(data: Nullable<FloatArray>): void;
  85993. /**
  85994. * Gets the position data stored in this target
  85995. * @returns a FloatArray containing the position data (or null if not present)
  85996. */
  85997. getPositions(): Nullable<FloatArray>;
  85998. /**
  85999. * Affects normal data to this target
  86000. * @param data defines the normal data to use
  86001. */
  86002. setNormals(data: Nullable<FloatArray>): void;
  86003. /**
  86004. * Gets the normal data stored in this target
  86005. * @returns a FloatArray containing the normal data (or null if not present)
  86006. */
  86007. getNormals(): Nullable<FloatArray>;
  86008. /**
  86009. * Affects tangent data to this target
  86010. * @param data defines the tangent data to use
  86011. */
  86012. setTangents(data: Nullable<FloatArray>): void;
  86013. /**
  86014. * Gets the tangent data stored in this target
  86015. * @returns a FloatArray containing the tangent data (or null if not present)
  86016. */
  86017. getTangents(): Nullable<FloatArray>;
  86018. /**
  86019. * Affects texture coordinates data to this target
  86020. * @param data defines the texture coordinates data to use
  86021. */
  86022. setUVs(data: Nullable<FloatArray>): void;
  86023. /**
  86024. * Gets the texture coordinates data stored in this target
  86025. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86026. */
  86027. getUVs(): Nullable<FloatArray>;
  86028. /**
  86029. * Serializes the current target into a Serialization object
  86030. * @returns the serialized object
  86031. */
  86032. serialize(): any;
  86033. /**
  86034. * Returns the string "MorphTarget"
  86035. * @returns "MorphTarget"
  86036. */
  86037. getClassName(): string;
  86038. /**
  86039. * Creates a new target from serialized data
  86040. * @param serializationObject defines the serialized data to use
  86041. * @returns a new MorphTarget
  86042. */
  86043. static Parse(serializationObject: any): MorphTarget;
  86044. /**
  86045. * Creates a MorphTarget from mesh data
  86046. * @param mesh defines the source mesh
  86047. * @param name defines the name to use for the new target
  86048. * @param influence defines the influence to attach to the target
  86049. * @returns a new MorphTarget
  86050. */
  86051. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86052. }
  86053. }
  86054. declare module BABYLON {
  86055. /**
  86056. * This class is used to deform meshes using morphing between different targets
  86057. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86058. */
  86059. export class MorphTargetManager {
  86060. private _targets;
  86061. private _targetInfluenceChangedObservers;
  86062. private _targetDataLayoutChangedObservers;
  86063. private _activeTargets;
  86064. private _scene;
  86065. private _influences;
  86066. private _supportsNormals;
  86067. private _supportsTangents;
  86068. private _supportsUVs;
  86069. private _vertexCount;
  86070. private _uniqueId;
  86071. private _tempInfluences;
  86072. /**
  86073. * Gets or sets a boolean indicating if normals must be morphed
  86074. */
  86075. enableNormalMorphing: boolean;
  86076. /**
  86077. * Gets or sets a boolean indicating if tangents must be morphed
  86078. */
  86079. enableTangentMorphing: boolean;
  86080. /**
  86081. * Gets or sets a boolean indicating if UV must be morphed
  86082. */
  86083. enableUVMorphing: boolean;
  86084. /**
  86085. * Creates a new MorphTargetManager
  86086. * @param scene defines the current scene
  86087. */
  86088. constructor(scene?: Nullable<Scene>);
  86089. /**
  86090. * Gets the unique ID of this manager
  86091. */
  86092. readonly uniqueId: number;
  86093. /**
  86094. * Gets the number of vertices handled by this manager
  86095. */
  86096. readonly vertexCount: number;
  86097. /**
  86098. * Gets a boolean indicating if this manager supports morphing of normals
  86099. */
  86100. readonly supportsNormals: boolean;
  86101. /**
  86102. * Gets a boolean indicating if this manager supports morphing of tangents
  86103. */
  86104. readonly supportsTangents: boolean;
  86105. /**
  86106. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86107. */
  86108. readonly supportsUVs: boolean;
  86109. /**
  86110. * Gets the number of targets stored in this manager
  86111. */
  86112. readonly numTargets: number;
  86113. /**
  86114. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86115. */
  86116. readonly numInfluencers: number;
  86117. /**
  86118. * Gets the list of influences (one per target)
  86119. */
  86120. readonly influences: Float32Array;
  86121. /**
  86122. * Gets the active target at specified index. An active target is a target with an influence > 0
  86123. * @param index defines the index to check
  86124. * @returns the requested target
  86125. */
  86126. getActiveTarget(index: number): MorphTarget;
  86127. /**
  86128. * Gets the target at specified index
  86129. * @param index defines the index to check
  86130. * @returns the requested target
  86131. */
  86132. getTarget(index: number): MorphTarget;
  86133. /**
  86134. * Add a new target to this manager
  86135. * @param target defines the target to add
  86136. */
  86137. addTarget(target: MorphTarget): void;
  86138. /**
  86139. * Removes a target from the manager
  86140. * @param target defines the target to remove
  86141. */
  86142. removeTarget(target: MorphTarget): void;
  86143. /**
  86144. * Serializes the current manager into a Serialization object
  86145. * @returns the serialized object
  86146. */
  86147. serialize(): any;
  86148. private _syncActiveTargets;
  86149. /**
  86150. * Syncrhonize the targets with all the meshes using this morph target manager
  86151. */
  86152. synchronize(): void;
  86153. /**
  86154. * Creates a new MorphTargetManager from serialized data
  86155. * @param serializationObject defines the serialized data
  86156. * @param scene defines the hosting scene
  86157. * @returns the new MorphTargetManager
  86158. */
  86159. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86160. }
  86161. }
  86162. declare module BABYLON {
  86163. /**
  86164. * Class used to represent a specific level of detail of a mesh
  86165. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86166. */
  86167. export class MeshLODLevel {
  86168. /** Defines the distance where this level should star being displayed */
  86169. distance: number;
  86170. /** Defines the mesh to use to render this level */
  86171. mesh: Nullable<Mesh>;
  86172. /**
  86173. * Creates a new LOD level
  86174. * @param distance defines the distance where this level should star being displayed
  86175. * @param mesh defines the mesh to use to render this level
  86176. */
  86177. constructor(
  86178. /** Defines the distance where this level should star being displayed */
  86179. distance: number,
  86180. /** Defines the mesh to use to render this level */
  86181. mesh: Nullable<Mesh>);
  86182. }
  86183. }
  86184. declare module BABYLON {
  86185. /**
  86186. * Mesh representing the gorund
  86187. */
  86188. export class GroundMesh extends Mesh {
  86189. /** If octree should be generated */
  86190. generateOctree: boolean;
  86191. private _heightQuads;
  86192. /** @hidden */
  86193. _subdivisionsX: number;
  86194. /** @hidden */
  86195. _subdivisionsY: number;
  86196. /** @hidden */
  86197. _width: number;
  86198. /** @hidden */
  86199. _height: number;
  86200. /** @hidden */
  86201. _minX: number;
  86202. /** @hidden */
  86203. _maxX: number;
  86204. /** @hidden */
  86205. _minZ: number;
  86206. /** @hidden */
  86207. _maxZ: number;
  86208. constructor(name: string, scene: Scene);
  86209. /**
  86210. * "GroundMesh"
  86211. * @returns "GroundMesh"
  86212. */
  86213. getClassName(): string;
  86214. /**
  86215. * The minimum of x and y subdivisions
  86216. */
  86217. readonly subdivisions: number;
  86218. /**
  86219. * X subdivisions
  86220. */
  86221. readonly subdivisionsX: number;
  86222. /**
  86223. * Y subdivisions
  86224. */
  86225. readonly subdivisionsY: number;
  86226. /**
  86227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86229. * @param chunksCount the number of subdivisions for x and y
  86230. * @param octreeBlocksSize (Default: 32)
  86231. */
  86232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86233. /**
  86234. * Returns a height (y) value in the Worl system :
  86235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86236. * @param x x coordinate
  86237. * @param z z coordinate
  86238. * @returns the ground y position if (x, z) are outside the ground surface.
  86239. */
  86240. getHeightAtCoordinates(x: number, z: number): number;
  86241. /**
  86242. * Returns a normalized vector (Vector3) orthogonal to the ground
  86243. * at the ground coordinates (x, z) expressed in the World system.
  86244. * @param x x coordinate
  86245. * @param z z coordinate
  86246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86247. */
  86248. getNormalAtCoordinates(x: number, z: number): Vector3;
  86249. /**
  86250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86251. * at the ground coordinates (x, z) expressed in the World system.
  86252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86253. * @param x x coordinate
  86254. * @param z z coordinate
  86255. * @param ref vector to store the result
  86256. * @returns the GroundMesh.
  86257. */
  86258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86259. /**
  86260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86261. * if the ground has been updated.
  86262. * This can be used in the render loop.
  86263. * @returns the GroundMesh.
  86264. */
  86265. updateCoordinateHeights(): GroundMesh;
  86266. private _getFacetAt;
  86267. private _initHeightQuads;
  86268. private _computeHeightQuads;
  86269. /**
  86270. * Serializes this ground mesh
  86271. * @param serializationObject object to write serialization to
  86272. */
  86273. serialize(serializationObject: any): void;
  86274. /**
  86275. * Parses a serialized ground mesh
  86276. * @param parsedMesh the serialized mesh
  86277. * @param scene the scene to create the ground mesh in
  86278. * @returns the created ground mesh
  86279. */
  86280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86281. }
  86282. }
  86283. declare module BABYLON {
  86284. /**
  86285. * Interface for Physics-Joint data
  86286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86287. */
  86288. export interface PhysicsJointData {
  86289. /**
  86290. * The main pivot of the joint
  86291. */
  86292. mainPivot?: Vector3;
  86293. /**
  86294. * The connected pivot of the joint
  86295. */
  86296. connectedPivot?: Vector3;
  86297. /**
  86298. * The main axis of the joint
  86299. */
  86300. mainAxis?: Vector3;
  86301. /**
  86302. * The connected axis of the joint
  86303. */
  86304. connectedAxis?: Vector3;
  86305. /**
  86306. * The collision of the joint
  86307. */
  86308. collision?: boolean;
  86309. /**
  86310. * Native Oimo/Cannon/Energy data
  86311. */
  86312. nativeParams?: any;
  86313. }
  86314. /**
  86315. * This is a holder class for the physics joint created by the physics plugin
  86316. * It holds a set of functions to control the underlying joint
  86317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86318. */
  86319. export class PhysicsJoint {
  86320. /**
  86321. * The type of the physics joint
  86322. */
  86323. type: number;
  86324. /**
  86325. * The data for the physics joint
  86326. */
  86327. jointData: PhysicsJointData;
  86328. private _physicsJoint;
  86329. protected _physicsPlugin: IPhysicsEnginePlugin;
  86330. /**
  86331. * Initializes the physics joint
  86332. * @param type The type of the physics joint
  86333. * @param jointData The data for the physics joint
  86334. */
  86335. constructor(
  86336. /**
  86337. * The type of the physics joint
  86338. */
  86339. type: number,
  86340. /**
  86341. * The data for the physics joint
  86342. */
  86343. jointData: PhysicsJointData);
  86344. /**
  86345. * Gets the physics joint
  86346. */
  86347. /**
  86348. * Sets the physics joint
  86349. */
  86350. physicsJoint: any;
  86351. /**
  86352. * Sets the physics plugin
  86353. */
  86354. physicsPlugin: IPhysicsEnginePlugin;
  86355. /**
  86356. * Execute a function that is physics-plugin specific.
  86357. * @param {Function} func the function that will be executed.
  86358. * It accepts two parameters: the physics world and the physics joint
  86359. */
  86360. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86361. /**
  86362. * Distance-Joint type
  86363. */
  86364. static DistanceJoint: number;
  86365. /**
  86366. * Hinge-Joint type
  86367. */
  86368. static HingeJoint: number;
  86369. /**
  86370. * Ball-and-Socket joint type
  86371. */
  86372. static BallAndSocketJoint: number;
  86373. /**
  86374. * Wheel-Joint type
  86375. */
  86376. static WheelJoint: number;
  86377. /**
  86378. * Slider-Joint type
  86379. */
  86380. static SliderJoint: number;
  86381. /**
  86382. * Prismatic-Joint type
  86383. */
  86384. static PrismaticJoint: number;
  86385. /**
  86386. * Universal-Joint type
  86387. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86388. */
  86389. static UniversalJoint: number;
  86390. /**
  86391. * Hinge-Joint 2 type
  86392. */
  86393. static Hinge2Joint: number;
  86394. /**
  86395. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86396. */
  86397. static PointToPointJoint: number;
  86398. /**
  86399. * Spring-Joint type
  86400. */
  86401. static SpringJoint: number;
  86402. /**
  86403. * Lock-Joint type
  86404. */
  86405. static LockJoint: number;
  86406. }
  86407. /**
  86408. * A class representing a physics distance joint
  86409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86410. */
  86411. export class DistanceJoint extends PhysicsJoint {
  86412. /**
  86413. *
  86414. * @param jointData The data for the Distance-Joint
  86415. */
  86416. constructor(jointData: DistanceJointData);
  86417. /**
  86418. * Update the predefined distance.
  86419. * @param maxDistance The maximum preferred distance
  86420. * @param minDistance The minimum preferred distance
  86421. */
  86422. updateDistance(maxDistance: number, minDistance?: number): void;
  86423. }
  86424. /**
  86425. * Represents a Motor-Enabled Joint
  86426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86427. */
  86428. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86429. /**
  86430. * Initializes the Motor-Enabled Joint
  86431. * @param type The type of the joint
  86432. * @param jointData The physica joint data for the joint
  86433. */
  86434. constructor(type: number, jointData: PhysicsJointData);
  86435. /**
  86436. * Set the motor values.
  86437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86438. * @param force the force to apply
  86439. * @param maxForce max force for this motor.
  86440. */
  86441. setMotor(force?: number, maxForce?: number): void;
  86442. /**
  86443. * Set the motor's limits.
  86444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86445. * @param upperLimit The upper limit of the motor
  86446. * @param lowerLimit The lower limit of the motor
  86447. */
  86448. setLimit(upperLimit: number, lowerLimit?: number): void;
  86449. }
  86450. /**
  86451. * This class represents a single physics Hinge-Joint
  86452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86453. */
  86454. export class HingeJoint extends MotorEnabledJoint {
  86455. /**
  86456. * Initializes the Hinge-Joint
  86457. * @param jointData The joint data for the Hinge-Joint
  86458. */
  86459. constructor(jointData: PhysicsJointData);
  86460. /**
  86461. * Set the motor values.
  86462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86463. * @param {number} force the force to apply
  86464. * @param {number} maxForce max force for this motor.
  86465. */
  86466. setMotor(force?: number, maxForce?: number): void;
  86467. /**
  86468. * Set the motor's limits.
  86469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86470. * @param upperLimit The upper limit of the motor
  86471. * @param lowerLimit The lower limit of the motor
  86472. */
  86473. setLimit(upperLimit: number, lowerLimit?: number): void;
  86474. }
  86475. /**
  86476. * This class represents a dual hinge physics joint (same as wheel joint)
  86477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86478. */
  86479. export class Hinge2Joint extends MotorEnabledJoint {
  86480. /**
  86481. * Initializes the Hinge2-Joint
  86482. * @param jointData The joint data for the Hinge2-Joint
  86483. */
  86484. constructor(jointData: PhysicsJointData);
  86485. /**
  86486. * Set the motor values.
  86487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86488. * @param {number} targetSpeed the speed the motor is to reach
  86489. * @param {number} maxForce max force for this motor.
  86490. * @param {motorIndex} the motor's index, 0 or 1.
  86491. */
  86492. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86493. /**
  86494. * Set the motor limits.
  86495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86496. * @param {number} upperLimit the upper limit
  86497. * @param {number} lowerLimit lower limit
  86498. * @param {motorIndex} the motor's index, 0 or 1.
  86499. */
  86500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86501. }
  86502. /**
  86503. * Interface for a motor enabled joint
  86504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86505. */
  86506. export interface IMotorEnabledJoint {
  86507. /**
  86508. * Physics joint
  86509. */
  86510. physicsJoint: any;
  86511. /**
  86512. * Sets the motor of the motor-enabled joint
  86513. * @param force The force of the motor
  86514. * @param maxForce The maximum force of the motor
  86515. * @param motorIndex The index of the motor
  86516. */
  86517. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86518. /**
  86519. * Sets the limit of the motor
  86520. * @param upperLimit The upper limit of the motor
  86521. * @param lowerLimit The lower limit of the motor
  86522. * @param motorIndex The index of the motor
  86523. */
  86524. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86525. }
  86526. /**
  86527. * Joint data for a Distance-Joint
  86528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86529. */
  86530. export interface DistanceJointData extends PhysicsJointData {
  86531. /**
  86532. * Max distance the 2 joint objects can be apart
  86533. */
  86534. maxDistance: number;
  86535. }
  86536. /**
  86537. * Joint data from a spring joint
  86538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86539. */
  86540. export interface SpringJointData extends PhysicsJointData {
  86541. /**
  86542. * Length of the spring
  86543. */
  86544. length: number;
  86545. /**
  86546. * Stiffness of the spring
  86547. */
  86548. stiffness: number;
  86549. /**
  86550. * Damping of the spring
  86551. */
  86552. damping: number;
  86553. /** this callback will be called when applying the force to the impostors. */
  86554. forceApplicationCallback: () => void;
  86555. }
  86556. }
  86557. declare module BABYLON {
  86558. /**
  86559. * Holds the data for the raycast result
  86560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86561. */
  86562. export class PhysicsRaycastResult {
  86563. private _hasHit;
  86564. private _hitDistance;
  86565. private _hitNormalWorld;
  86566. private _hitPointWorld;
  86567. private _rayFromWorld;
  86568. private _rayToWorld;
  86569. /**
  86570. * Gets if there was a hit
  86571. */
  86572. readonly hasHit: boolean;
  86573. /**
  86574. * Gets the distance from the hit
  86575. */
  86576. readonly hitDistance: number;
  86577. /**
  86578. * Gets the hit normal/direction in the world
  86579. */
  86580. readonly hitNormalWorld: Vector3;
  86581. /**
  86582. * Gets the hit point in the world
  86583. */
  86584. readonly hitPointWorld: Vector3;
  86585. /**
  86586. * Gets the ray "start point" of the ray in the world
  86587. */
  86588. readonly rayFromWorld: Vector3;
  86589. /**
  86590. * Gets the ray "end point" of the ray in the world
  86591. */
  86592. readonly rayToWorld: Vector3;
  86593. /**
  86594. * Sets the hit data (normal & point in world space)
  86595. * @param hitNormalWorld defines the normal in world space
  86596. * @param hitPointWorld defines the point in world space
  86597. */
  86598. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86599. /**
  86600. * Sets the distance from the start point to the hit point
  86601. * @param distance
  86602. */
  86603. setHitDistance(distance: number): void;
  86604. /**
  86605. * Calculates the distance manually
  86606. */
  86607. calculateHitDistance(): void;
  86608. /**
  86609. * Resets all the values to default
  86610. * @param from The from point on world space
  86611. * @param to The to point on world space
  86612. */
  86613. reset(from?: Vector3, to?: Vector3): void;
  86614. }
  86615. /**
  86616. * Interface for the size containing width and height
  86617. */
  86618. interface IXYZ {
  86619. /**
  86620. * X
  86621. */
  86622. x: number;
  86623. /**
  86624. * Y
  86625. */
  86626. y: number;
  86627. /**
  86628. * Z
  86629. */
  86630. z: number;
  86631. }
  86632. }
  86633. declare module BABYLON {
  86634. /**
  86635. * Interface used to describe a physics joint
  86636. */
  86637. export interface PhysicsImpostorJoint {
  86638. /** Defines the main impostor to which the joint is linked */
  86639. mainImpostor: PhysicsImpostor;
  86640. /** Defines the impostor that is connected to the main impostor using this joint */
  86641. connectedImpostor: PhysicsImpostor;
  86642. /** Defines the joint itself */
  86643. joint: PhysicsJoint;
  86644. }
  86645. /** @hidden */
  86646. export interface IPhysicsEnginePlugin {
  86647. world: any;
  86648. name: string;
  86649. setGravity(gravity: Vector3): void;
  86650. setTimeStep(timeStep: number): void;
  86651. getTimeStep(): number;
  86652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86656. removePhysicsBody(impostor: PhysicsImpostor): void;
  86657. generateJoint(joint: PhysicsImpostorJoint): void;
  86658. removeJoint(joint: PhysicsImpostorJoint): void;
  86659. isSupported(): boolean;
  86660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86667. getBodyMass(impostor: PhysicsImpostor): number;
  86668. getBodyFriction(impostor: PhysicsImpostor): number;
  86669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86670. getBodyRestitution(impostor: PhysicsImpostor): number;
  86671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86672. getBodyPressure?(impostor: PhysicsImpostor): number;
  86673. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86674. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86675. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86676. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86677. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86678. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86679. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86680. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86681. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86682. sleepBody(impostor: PhysicsImpostor): void;
  86683. wakeUpBody(impostor: PhysicsImpostor): void;
  86684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86688. getRadius(impostor: PhysicsImpostor): number;
  86689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86691. dispose(): void;
  86692. }
  86693. /**
  86694. * Interface used to define a physics engine
  86695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86696. */
  86697. export interface IPhysicsEngine {
  86698. /**
  86699. * Gets the gravity vector used by the simulation
  86700. */
  86701. gravity: Vector3;
  86702. /**
  86703. * Sets the gravity vector used by the simulation
  86704. * @param gravity defines the gravity vector to use
  86705. */
  86706. setGravity(gravity: Vector3): void;
  86707. /**
  86708. * Set the time step of the physics engine.
  86709. * Default is 1/60.
  86710. * To slow it down, enter 1/600 for example.
  86711. * To speed it up, 1/30
  86712. * @param newTimeStep the new timestep to apply to this world.
  86713. */
  86714. setTimeStep(newTimeStep: number): void;
  86715. /**
  86716. * Get the time step of the physics engine.
  86717. * @returns the current time step
  86718. */
  86719. getTimeStep(): number;
  86720. /**
  86721. * Release all resources
  86722. */
  86723. dispose(): void;
  86724. /**
  86725. * Gets the name of the current physics plugin
  86726. * @returns the name of the plugin
  86727. */
  86728. getPhysicsPluginName(): string;
  86729. /**
  86730. * Adding a new impostor for the impostor tracking.
  86731. * This will be done by the impostor itself.
  86732. * @param impostor the impostor to add
  86733. */
  86734. addImpostor(impostor: PhysicsImpostor): void;
  86735. /**
  86736. * Remove an impostor from the engine.
  86737. * This impostor and its mesh will not longer be updated by the physics engine.
  86738. * @param impostor the impostor to remove
  86739. */
  86740. removeImpostor(impostor: PhysicsImpostor): void;
  86741. /**
  86742. * Add a joint to the physics engine
  86743. * @param mainImpostor defines the main impostor to which the joint is added.
  86744. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86745. * @param joint defines the joint that will connect both impostors.
  86746. */
  86747. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86748. /**
  86749. * Removes a joint from the simulation
  86750. * @param mainImpostor defines the impostor used with the joint
  86751. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86752. * @param joint defines the joint to remove
  86753. */
  86754. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86755. /**
  86756. * Gets the current plugin used to run the simulation
  86757. * @returns current plugin
  86758. */
  86759. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86760. /**
  86761. * Gets the list of physic impostors
  86762. * @returns an array of PhysicsImpostor
  86763. */
  86764. getImpostors(): Array<PhysicsImpostor>;
  86765. /**
  86766. * Gets the impostor for a physics enabled object
  86767. * @param object defines the object impersonated by the impostor
  86768. * @returns the PhysicsImpostor or null if not found
  86769. */
  86770. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86771. /**
  86772. * Gets the impostor for a physics body object
  86773. * @param body defines physics body used by the impostor
  86774. * @returns the PhysicsImpostor or null if not found
  86775. */
  86776. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86777. /**
  86778. * Does a raycast in the physics world
  86779. * @param from when should the ray start?
  86780. * @param to when should the ray end?
  86781. * @returns PhysicsRaycastResult
  86782. */
  86783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86784. /**
  86785. * Called by the scene. No need to call it.
  86786. * @param delta defines the timespam between frames
  86787. */
  86788. _step(delta: number): void;
  86789. }
  86790. }
  86791. declare module BABYLON {
  86792. /**
  86793. * The interface for the physics imposter parameters
  86794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86795. */
  86796. export interface PhysicsImpostorParameters {
  86797. /**
  86798. * The mass of the physics imposter
  86799. */
  86800. mass: number;
  86801. /**
  86802. * The friction of the physics imposter
  86803. */
  86804. friction?: number;
  86805. /**
  86806. * The coefficient of restitution of the physics imposter
  86807. */
  86808. restitution?: number;
  86809. /**
  86810. * The native options of the physics imposter
  86811. */
  86812. nativeOptions?: any;
  86813. /**
  86814. * Specifies if the parent should be ignored
  86815. */
  86816. ignoreParent?: boolean;
  86817. /**
  86818. * Specifies if bi-directional transformations should be disabled
  86819. */
  86820. disableBidirectionalTransformation?: boolean;
  86821. /**
  86822. * The pressure inside the physics imposter, soft object only
  86823. */
  86824. pressure?: number;
  86825. /**
  86826. * The stiffness the physics imposter, soft object only
  86827. */
  86828. stiffness?: number;
  86829. /**
  86830. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86831. */
  86832. velocityIterations?: number;
  86833. /**
  86834. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86835. */
  86836. positionIterations?: number;
  86837. /**
  86838. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86839. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86840. * Add to fix multiple points
  86841. */
  86842. fixedPoints?: number;
  86843. /**
  86844. * The collision margin around a soft object
  86845. */
  86846. margin?: number;
  86847. /**
  86848. * The collision margin around a soft object
  86849. */
  86850. damping?: number;
  86851. /**
  86852. * The path for a rope based on an extrusion
  86853. */
  86854. path?: any;
  86855. /**
  86856. * The shape of an extrusion used for a rope based on an extrusion
  86857. */
  86858. shape?: any;
  86859. }
  86860. /**
  86861. * Interface for a physics-enabled object
  86862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86863. */
  86864. export interface IPhysicsEnabledObject {
  86865. /**
  86866. * The position of the physics-enabled object
  86867. */
  86868. position: Vector3;
  86869. /**
  86870. * The rotation of the physics-enabled object
  86871. */
  86872. rotationQuaternion: Nullable<Quaternion>;
  86873. /**
  86874. * The scale of the physics-enabled object
  86875. */
  86876. scaling: Vector3;
  86877. /**
  86878. * The rotation of the physics-enabled object
  86879. */
  86880. rotation?: Vector3;
  86881. /**
  86882. * The parent of the physics-enabled object
  86883. */
  86884. parent?: any;
  86885. /**
  86886. * The bounding info of the physics-enabled object
  86887. * @returns The bounding info of the physics-enabled object
  86888. */
  86889. getBoundingInfo(): BoundingInfo;
  86890. /**
  86891. * Computes the world matrix
  86892. * @param force Specifies if the world matrix should be computed by force
  86893. * @returns A world matrix
  86894. */
  86895. computeWorldMatrix(force: boolean): Matrix;
  86896. /**
  86897. * Gets the world matrix
  86898. * @returns A world matrix
  86899. */
  86900. getWorldMatrix?(): Matrix;
  86901. /**
  86902. * Gets the child meshes
  86903. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86904. * @returns An array of abstract meshes
  86905. */
  86906. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86907. /**
  86908. * Gets the vertex data
  86909. * @param kind The type of vertex data
  86910. * @returns A nullable array of numbers, or a float32 array
  86911. */
  86912. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86913. /**
  86914. * Gets the indices from the mesh
  86915. * @returns A nullable array of index arrays
  86916. */
  86917. getIndices?(): Nullable<IndicesArray>;
  86918. /**
  86919. * Gets the scene from the mesh
  86920. * @returns the indices array or null
  86921. */
  86922. getScene?(): Scene;
  86923. /**
  86924. * Gets the absolute position from the mesh
  86925. * @returns the absolute position
  86926. */
  86927. getAbsolutePosition(): Vector3;
  86928. /**
  86929. * Gets the absolute pivot point from the mesh
  86930. * @returns the absolute pivot point
  86931. */
  86932. getAbsolutePivotPoint(): Vector3;
  86933. /**
  86934. * Rotates the mesh
  86935. * @param axis The axis of rotation
  86936. * @param amount The amount of rotation
  86937. * @param space The space of the rotation
  86938. * @returns The rotation transform node
  86939. */
  86940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86941. /**
  86942. * Translates the mesh
  86943. * @param axis The axis of translation
  86944. * @param distance The distance of translation
  86945. * @param space The space of the translation
  86946. * @returns The transform node
  86947. */
  86948. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86949. /**
  86950. * Sets the absolute position of the mesh
  86951. * @param absolutePosition The absolute position of the mesh
  86952. * @returns The transform node
  86953. */
  86954. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86955. /**
  86956. * Gets the class name of the mesh
  86957. * @returns The class name
  86958. */
  86959. getClassName(): string;
  86960. }
  86961. /**
  86962. * Represents a physics imposter
  86963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86964. */
  86965. export class PhysicsImpostor {
  86966. /**
  86967. * The physics-enabled object used as the physics imposter
  86968. */
  86969. object: IPhysicsEnabledObject;
  86970. /**
  86971. * The type of the physics imposter
  86972. */
  86973. type: number;
  86974. private _options;
  86975. private _scene?;
  86976. /**
  86977. * The default object size of the imposter
  86978. */
  86979. static DEFAULT_OBJECT_SIZE: Vector3;
  86980. /**
  86981. * The identity quaternion of the imposter
  86982. */
  86983. static IDENTITY_QUATERNION: Quaternion;
  86984. /** @hidden */
  86985. _pluginData: any;
  86986. private _physicsEngine;
  86987. private _physicsBody;
  86988. private _bodyUpdateRequired;
  86989. private _onBeforePhysicsStepCallbacks;
  86990. private _onAfterPhysicsStepCallbacks;
  86991. /** @hidden */
  86992. _onPhysicsCollideCallbacks: Array<{
  86993. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86994. otherImpostors: Array<PhysicsImpostor>;
  86995. }>;
  86996. private _deltaPosition;
  86997. private _deltaRotation;
  86998. private _deltaRotationConjugated;
  86999. /** @hidden */
  87000. _isFromLine: boolean;
  87001. private _parent;
  87002. private _isDisposed;
  87003. private static _tmpVecs;
  87004. private static _tmpQuat;
  87005. /**
  87006. * Specifies if the physics imposter is disposed
  87007. */
  87008. readonly isDisposed: boolean;
  87009. /**
  87010. * Gets the mass of the physics imposter
  87011. */
  87012. mass: number;
  87013. /**
  87014. * Gets the coefficient of friction
  87015. */
  87016. /**
  87017. * Sets the coefficient of friction
  87018. */
  87019. friction: number;
  87020. /**
  87021. * Gets the coefficient of restitution
  87022. */
  87023. /**
  87024. * Sets the coefficient of restitution
  87025. */
  87026. restitution: number;
  87027. /**
  87028. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87029. */
  87030. /**
  87031. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87032. */
  87033. pressure: number;
  87034. /**
  87035. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87036. */
  87037. /**
  87038. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87039. */
  87040. stiffness: number;
  87041. /**
  87042. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87043. */
  87044. /**
  87045. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87046. */
  87047. velocityIterations: number;
  87048. /**
  87049. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87050. */
  87051. /**
  87052. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87053. */
  87054. positionIterations: number;
  87055. /**
  87056. * The unique id of the physics imposter
  87057. * set by the physics engine when adding this impostor to the array
  87058. */
  87059. uniqueId: number;
  87060. /**
  87061. * @hidden
  87062. */
  87063. soft: boolean;
  87064. /**
  87065. * @hidden
  87066. */
  87067. segments: number;
  87068. private _joints;
  87069. /**
  87070. * Initializes the physics imposter
  87071. * @param object The physics-enabled object used as the physics imposter
  87072. * @param type The type of the physics imposter
  87073. * @param _options The options for the physics imposter
  87074. * @param _scene The Babylon scene
  87075. */
  87076. constructor(
  87077. /**
  87078. * The physics-enabled object used as the physics imposter
  87079. */
  87080. object: IPhysicsEnabledObject,
  87081. /**
  87082. * The type of the physics imposter
  87083. */
  87084. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87085. /**
  87086. * This function will completly initialize this impostor.
  87087. * It will create a new body - but only if this mesh has no parent.
  87088. * If it has, this impostor will not be used other than to define the impostor
  87089. * of the child mesh.
  87090. * @hidden
  87091. */
  87092. _init(): void;
  87093. private _getPhysicsParent;
  87094. /**
  87095. * Should a new body be generated.
  87096. * @returns boolean specifying if body initialization is required
  87097. */
  87098. isBodyInitRequired(): boolean;
  87099. /**
  87100. * Sets the updated scaling
  87101. * @param updated Specifies if the scaling is updated
  87102. */
  87103. setScalingUpdated(): void;
  87104. /**
  87105. * Force a regeneration of this or the parent's impostor's body.
  87106. * Use under cautious - This will remove all joints already implemented.
  87107. */
  87108. forceUpdate(): void;
  87109. /**
  87110. * Gets the body that holds this impostor. Either its own, or its parent.
  87111. */
  87112. /**
  87113. * Set the physics body. Used mainly by the physics engine/plugin
  87114. */
  87115. physicsBody: any;
  87116. /**
  87117. * Get the parent of the physics imposter
  87118. * @returns Physics imposter or null
  87119. */
  87120. /**
  87121. * Sets the parent of the physics imposter
  87122. */
  87123. parent: Nullable<PhysicsImpostor>;
  87124. /**
  87125. * Resets the update flags
  87126. */
  87127. resetUpdateFlags(): void;
  87128. /**
  87129. * Gets the object extend size
  87130. * @returns the object extend size
  87131. */
  87132. getObjectExtendSize(): Vector3;
  87133. /**
  87134. * Gets the object center
  87135. * @returns The object center
  87136. */
  87137. getObjectCenter(): Vector3;
  87138. /**
  87139. * Get a specific parametes from the options parameter
  87140. * @param paramName The object parameter name
  87141. * @returns The object parameter
  87142. */
  87143. getParam(paramName: string): any;
  87144. /**
  87145. * Sets a specific parameter in the options given to the physics plugin
  87146. * @param paramName The parameter name
  87147. * @param value The value of the parameter
  87148. */
  87149. setParam(paramName: string, value: number): void;
  87150. /**
  87151. * Specifically change the body's mass option. Won't recreate the physics body object
  87152. * @param mass The mass of the physics imposter
  87153. */
  87154. setMass(mass: number): void;
  87155. /**
  87156. * Gets the linear velocity
  87157. * @returns linear velocity or null
  87158. */
  87159. getLinearVelocity(): Nullable<Vector3>;
  87160. /**
  87161. * Sets the linear velocity
  87162. * @param velocity linear velocity or null
  87163. */
  87164. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87165. /**
  87166. * Gets the angular velocity
  87167. * @returns angular velocity or null
  87168. */
  87169. getAngularVelocity(): Nullable<Vector3>;
  87170. /**
  87171. * Sets the angular velocity
  87172. * @param velocity The velocity or null
  87173. */
  87174. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87175. /**
  87176. * Execute a function with the physics plugin native code
  87177. * Provide a function the will have two variables - the world object and the physics body object
  87178. * @param func The function to execute with the physics plugin native code
  87179. */
  87180. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87181. /**
  87182. * Register a function that will be executed before the physics world is stepping forward
  87183. * @param func The function to execute before the physics world is stepped forward
  87184. */
  87185. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87186. /**
  87187. * Unregister a function that will be executed before the physics world is stepping forward
  87188. * @param func The function to execute before the physics world is stepped forward
  87189. */
  87190. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87191. /**
  87192. * Register a function that will be executed after the physics step
  87193. * @param func The function to execute after physics step
  87194. */
  87195. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87196. /**
  87197. * Unregisters a function that will be executed after the physics step
  87198. * @param func The function to execute after physics step
  87199. */
  87200. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87201. /**
  87202. * register a function that will be executed when this impostor collides against a different body
  87203. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87204. * @param func Callback that is executed on collision
  87205. */
  87206. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87207. /**
  87208. * Unregisters the physics imposter on contact
  87209. * @param collideAgainst The physics object to collide against
  87210. * @param func Callback to execute on collision
  87211. */
  87212. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87213. private _tmpQuat;
  87214. private _tmpQuat2;
  87215. /**
  87216. * Get the parent rotation
  87217. * @returns The parent rotation
  87218. */
  87219. getParentsRotation(): Quaternion;
  87220. /**
  87221. * this function is executed by the physics engine.
  87222. */
  87223. beforeStep: () => void;
  87224. /**
  87225. * this function is executed by the physics engine
  87226. */
  87227. afterStep: () => void;
  87228. /**
  87229. * Legacy collision detection event support
  87230. */
  87231. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87232. /**
  87233. * event and body object due to cannon's event-based architecture.
  87234. */
  87235. onCollide: (e: {
  87236. body: any;
  87237. }) => void;
  87238. /**
  87239. * Apply a force
  87240. * @param force The force to apply
  87241. * @param contactPoint The contact point for the force
  87242. * @returns The physics imposter
  87243. */
  87244. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87245. /**
  87246. * Apply an impulse
  87247. * @param force The impulse force
  87248. * @param contactPoint The contact point for the impulse force
  87249. * @returns The physics imposter
  87250. */
  87251. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87252. /**
  87253. * A help function to create a joint
  87254. * @param otherImpostor A physics imposter used to create a joint
  87255. * @param jointType The type of joint
  87256. * @param jointData The data for the joint
  87257. * @returns The physics imposter
  87258. */
  87259. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87260. /**
  87261. * Add a joint to this impostor with a different impostor
  87262. * @param otherImpostor A physics imposter used to add a joint
  87263. * @param joint The joint to add
  87264. * @returns The physics imposter
  87265. */
  87266. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87267. /**
  87268. * Add an anchor to a cloth impostor
  87269. * @param otherImpostor rigid impostor to anchor to
  87270. * @param width ratio across width from 0 to 1
  87271. * @param height ratio up height from 0 to 1
  87272. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87273. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87274. * @returns impostor the soft imposter
  87275. */
  87276. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87277. /**
  87278. * Add a hook to a rope impostor
  87279. * @param otherImpostor rigid impostor to anchor to
  87280. * @param length ratio across rope from 0 to 1
  87281. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87282. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87283. * @returns impostor the rope imposter
  87284. */
  87285. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87286. /**
  87287. * Will keep this body still, in a sleep mode.
  87288. * @returns the physics imposter
  87289. */
  87290. sleep(): PhysicsImpostor;
  87291. /**
  87292. * Wake the body up.
  87293. * @returns The physics imposter
  87294. */
  87295. wakeUp(): PhysicsImpostor;
  87296. /**
  87297. * Clones the physics imposter
  87298. * @param newObject The physics imposter clones to this physics-enabled object
  87299. * @returns A nullable physics imposter
  87300. */
  87301. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87302. /**
  87303. * Disposes the physics imposter
  87304. */
  87305. dispose(): void;
  87306. /**
  87307. * Sets the delta position
  87308. * @param position The delta position amount
  87309. */
  87310. setDeltaPosition(position: Vector3): void;
  87311. /**
  87312. * Sets the delta rotation
  87313. * @param rotation The delta rotation amount
  87314. */
  87315. setDeltaRotation(rotation: Quaternion): void;
  87316. /**
  87317. * Gets the box size of the physics imposter and stores the result in the input parameter
  87318. * @param result Stores the box size
  87319. * @returns The physics imposter
  87320. */
  87321. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87322. /**
  87323. * Gets the radius of the physics imposter
  87324. * @returns Radius of the physics imposter
  87325. */
  87326. getRadius(): number;
  87327. /**
  87328. * Sync a bone with this impostor
  87329. * @param bone The bone to sync to the impostor.
  87330. * @param boneMesh The mesh that the bone is influencing.
  87331. * @param jointPivot The pivot of the joint / bone in local space.
  87332. * @param distToJoint Optional distance from the impostor to the joint.
  87333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87334. */
  87335. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87336. /**
  87337. * Sync impostor to a bone
  87338. * @param bone The bone that the impostor will be synced to.
  87339. * @param boneMesh The mesh that the bone is influencing.
  87340. * @param jointPivot The pivot of the joint / bone in local space.
  87341. * @param distToJoint Optional distance from the impostor to the joint.
  87342. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87343. * @param boneAxis Optional vector3 axis the bone is aligned with
  87344. */
  87345. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87346. /**
  87347. * No-Imposter type
  87348. */
  87349. static NoImpostor: number;
  87350. /**
  87351. * Sphere-Imposter type
  87352. */
  87353. static SphereImpostor: number;
  87354. /**
  87355. * Box-Imposter type
  87356. */
  87357. static BoxImpostor: number;
  87358. /**
  87359. * Plane-Imposter type
  87360. */
  87361. static PlaneImpostor: number;
  87362. /**
  87363. * Mesh-imposter type
  87364. */
  87365. static MeshImpostor: number;
  87366. /**
  87367. * Capsule-Impostor type (Ammo.js plugin only)
  87368. */
  87369. static CapsuleImpostor: number;
  87370. /**
  87371. * Cylinder-Imposter type
  87372. */
  87373. static CylinderImpostor: number;
  87374. /**
  87375. * Particle-Imposter type
  87376. */
  87377. static ParticleImpostor: number;
  87378. /**
  87379. * Heightmap-Imposter type
  87380. */
  87381. static HeightmapImpostor: number;
  87382. /**
  87383. * ConvexHull-Impostor type (Ammo.js plugin only)
  87384. */
  87385. static ConvexHullImpostor: number;
  87386. /**
  87387. * Rope-Imposter type
  87388. */
  87389. static RopeImpostor: number;
  87390. /**
  87391. * Cloth-Imposter type
  87392. */
  87393. static ClothImpostor: number;
  87394. /**
  87395. * Softbody-Imposter type
  87396. */
  87397. static SoftbodyImpostor: number;
  87398. }
  87399. }
  87400. declare module BABYLON {
  87401. /**
  87402. * @hidden
  87403. **/
  87404. export class _CreationDataStorage {
  87405. closePath?: boolean;
  87406. closeArray?: boolean;
  87407. idx: number[];
  87408. dashSize: number;
  87409. gapSize: number;
  87410. path3D: Path3D;
  87411. pathArray: Vector3[][];
  87412. arc: number;
  87413. radius: number;
  87414. cap: number;
  87415. tessellation: number;
  87416. }
  87417. /**
  87418. * @hidden
  87419. **/
  87420. class _InstanceDataStorage {
  87421. visibleInstances: any;
  87422. batchCache: _InstancesBatch;
  87423. instancesBufferSize: number;
  87424. instancesBuffer: Nullable<Buffer>;
  87425. instancesData: Float32Array;
  87426. overridenInstanceCount: number;
  87427. isFrozen: boolean;
  87428. previousBatch: Nullable<_InstancesBatch>;
  87429. hardwareInstancedRendering: boolean;
  87430. sideOrientation: number;
  87431. }
  87432. /**
  87433. * @hidden
  87434. **/
  87435. export class _InstancesBatch {
  87436. mustReturn: boolean;
  87437. visibleInstances: Nullable<InstancedMesh[]>[];
  87438. renderSelf: boolean[];
  87439. hardwareInstancedRendering: boolean[];
  87440. }
  87441. /**
  87442. * Class used to represent renderable models
  87443. */
  87444. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87445. /**
  87446. * Mesh side orientation : usually the external or front surface
  87447. */
  87448. static readonly FRONTSIDE: number;
  87449. /**
  87450. * Mesh side orientation : usually the internal or back surface
  87451. */
  87452. static readonly BACKSIDE: number;
  87453. /**
  87454. * Mesh side orientation : both internal and external or front and back surfaces
  87455. */
  87456. static readonly DOUBLESIDE: number;
  87457. /**
  87458. * Mesh side orientation : by default, `FRONTSIDE`
  87459. */
  87460. static readonly DEFAULTSIDE: number;
  87461. /**
  87462. * Mesh cap setting : no cap
  87463. */
  87464. static readonly NO_CAP: number;
  87465. /**
  87466. * Mesh cap setting : one cap at the beginning of the mesh
  87467. */
  87468. static readonly CAP_START: number;
  87469. /**
  87470. * Mesh cap setting : one cap at the end of the mesh
  87471. */
  87472. static readonly CAP_END: number;
  87473. /**
  87474. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87475. */
  87476. static readonly CAP_ALL: number;
  87477. /**
  87478. * Mesh pattern setting : no flip or rotate
  87479. */
  87480. static readonly NO_FLIP: number;
  87481. /**
  87482. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87483. */
  87484. static readonly FLIP_TILE: number;
  87485. /**
  87486. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87487. */
  87488. static readonly ROTATE_TILE: number;
  87489. /**
  87490. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87491. */
  87492. static readonly FLIP_ROW: number;
  87493. /**
  87494. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87495. */
  87496. static readonly ROTATE_ROW: number;
  87497. /**
  87498. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87499. */
  87500. static readonly FLIP_N_ROTATE_TILE: number;
  87501. /**
  87502. * Mesh pattern setting : rotate pattern and rotate
  87503. */
  87504. static readonly FLIP_N_ROTATE_ROW: number;
  87505. /**
  87506. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87507. */
  87508. static readonly CENTER: number;
  87509. /**
  87510. * Mesh tile positioning : part tiles on left
  87511. */
  87512. static readonly LEFT: number;
  87513. /**
  87514. * Mesh tile positioning : part tiles on right
  87515. */
  87516. static readonly RIGHT: number;
  87517. /**
  87518. * Mesh tile positioning : part tiles on top
  87519. */
  87520. static readonly TOP: number;
  87521. /**
  87522. * Mesh tile positioning : part tiles on bottom
  87523. */
  87524. static readonly BOTTOM: number;
  87525. /**
  87526. * Gets the default side orientation.
  87527. * @param orientation the orientation to value to attempt to get
  87528. * @returns the default orientation
  87529. * @hidden
  87530. */
  87531. static _GetDefaultSideOrientation(orientation?: number): number;
  87532. private _internalMeshDataInfo;
  87533. /**
  87534. * An event triggered before rendering the mesh
  87535. */
  87536. readonly onBeforeRenderObservable: Observable<Mesh>;
  87537. /**
  87538. * An event triggered before binding the mesh
  87539. */
  87540. readonly onBeforeBindObservable: Observable<Mesh>;
  87541. /**
  87542. * An event triggered after rendering the mesh
  87543. */
  87544. readonly onAfterRenderObservable: Observable<Mesh>;
  87545. /**
  87546. * An event triggered before drawing the mesh
  87547. */
  87548. readonly onBeforeDrawObservable: Observable<Mesh>;
  87549. private _onBeforeDrawObserver;
  87550. /**
  87551. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87552. */
  87553. onBeforeDraw: () => void;
  87554. /**
  87555. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87556. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87557. */
  87558. delayLoadState: number;
  87559. /**
  87560. * Gets the list of instances created from this mesh
  87561. * it is not supposed to be modified manually.
  87562. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87563. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87564. */
  87565. instances: InstancedMesh[];
  87566. /**
  87567. * Gets the file containing delay loading data for this mesh
  87568. */
  87569. delayLoadingFile: string;
  87570. /** @hidden */
  87571. _binaryInfo: any;
  87572. /**
  87573. * User defined function used to change how LOD level selection is done
  87574. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87575. */
  87576. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87577. /**
  87578. * Gets or sets the morph target manager
  87579. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87580. */
  87581. morphTargetManager: Nullable<MorphTargetManager>;
  87582. /** @hidden */
  87583. _creationDataStorage: Nullable<_CreationDataStorage>;
  87584. /** @hidden */
  87585. _geometry: Nullable<Geometry>;
  87586. /** @hidden */
  87587. _delayInfo: Array<string>;
  87588. /** @hidden */
  87589. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87590. /** @hidden */
  87591. _instanceDataStorage: _InstanceDataStorage;
  87592. private _effectiveMaterial;
  87593. /** @hidden */
  87594. _shouldGenerateFlatShading: boolean;
  87595. /** @hidden */
  87596. _originalBuilderSideOrientation: number;
  87597. /**
  87598. * Use this property to change the original side orientation defined at construction time
  87599. */
  87600. overrideMaterialSideOrientation: Nullable<number>;
  87601. /**
  87602. * Gets the source mesh (the one used to clone this one from)
  87603. */
  87604. readonly source: Nullable<Mesh>;
  87605. /**
  87606. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87607. */
  87608. isUnIndexed: boolean;
  87609. /**
  87610. * @constructor
  87611. * @param name The value used by scene.getMeshByName() to do a lookup.
  87612. * @param scene The scene to add this mesh to.
  87613. * @param parent The parent of this mesh, if it has one
  87614. * @param source An optional Mesh from which geometry is shared, cloned.
  87615. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87616. * When false, achieved by calling a clone(), also passing False.
  87617. * This will make creation of children, recursive.
  87618. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87619. */
  87620. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87621. /**
  87622. * Gets the class name
  87623. * @returns the string "Mesh".
  87624. */
  87625. getClassName(): string;
  87626. /** @hidden */
  87627. readonly _isMesh: boolean;
  87628. /**
  87629. * Returns a description of this mesh
  87630. * @param fullDetails define if full details about this mesh must be used
  87631. * @returns a descriptive string representing this mesh
  87632. */
  87633. toString(fullDetails?: boolean): string;
  87634. /** @hidden */
  87635. _unBindEffect(): void;
  87636. /**
  87637. * Gets a boolean indicating if this mesh has LOD
  87638. */
  87639. readonly hasLODLevels: boolean;
  87640. /**
  87641. * Gets the list of MeshLODLevel associated with the current mesh
  87642. * @returns an array of MeshLODLevel
  87643. */
  87644. getLODLevels(): MeshLODLevel[];
  87645. private _sortLODLevels;
  87646. /**
  87647. * Add a mesh as LOD level triggered at the given distance.
  87648. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87649. * @param distance The distance from the center of the object to show this level
  87650. * @param mesh The mesh to be added as LOD level (can be null)
  87651. * @return This mesh (for chaining)
  87652. */
  87653. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87654. /**
  87655. * Returns the LOD level mesh at the passed distance or null if not found.
  87656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87657. * @param distance The distance from the center of the object to show this level
  87658. * @returns a Mesh or `null`
  87659. */
  87660. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87661. /**
  87662. * Remove a mesh from the LOD array
  87663. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87664. * @param mesh defines the mesh to be removed
  87665. * @return This mesh (for chaining)
  87666. */
  87667. removeLODLevel(mesh: Mesh): Mesh;
  87668. /**
  87669. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87670. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87671. * @param camera defines the camera to use to compute distance
  87672. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87673. * @return This mesh (for chaining)
  87674. */
  87675. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87676. /**
  87677. * Gets the mesh internal Geometry object
  87678. */
  87679. readonly geometry: Nullable<Geometry>;
  87680. /**
  87681. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87682. * @returns the total number of vertices
  87683. */
  87684. getTotalVertices(): number;
  87685. /**
  87686. * Returns the content of an associated vertex buffer
  87687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87688. * - VertexBuffer.PositionKind
  87689. * - VertexBuffer.UVKind
  87690. * - VertexBuffer.UV2Kind
  87691. * - VertexBuffer.UV3Kind
  87692. * - VertexBuffer.UV4Kind
  87693. * - VertexBuffer.UV5Kind
  87694. * - VertexBuffer.UV6Kind
  87695. * - VertexBuffer.ColorKind
  87696. * - VertexBuffer.MatricesIndicesKind
  87697. * - VertexBuffer.MatricesIndicesExtraKind
  87698. * - VertexBuffer.MatricesWeightsKind
  87699. * - VertexBuffer.MatricesWeightsExtraKind
  87700. * @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
  87701. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87702. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87703. */
  87704. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87705. /**
  87706. * Returns the mesh VertexBuffer object from the requested `kind`
  87707. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87708. * - VertexBuffer.PositionKind
  87709. * - VertexBuffer.NormalKind
  87710. * - VertexBuffer.UVKind
  87711. * - VertexBuffer.UV2Kind
  87712. * - VertexBuffer.UV3Kind
  87713. * - VertexBuffer.UV4Kind
  87714. * - VertexBuffer.UV5Kind
  87715. * - VertexBuffer.UV6Kind
  87716. * - VertexBuffer.ColorKind
  87717. * - VertexBuffer.MatricesIndicesKind
  87718. * - VertexBuffer.MatricesIndicesExtraKind
  87719. * - VertexBuffer.MatricesWeightsKind
  87720. * - VertexBuffer.MatricesWeightsExtraKind
  87721. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87722. */
  87723. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87724. /**
  87725. * Tests if a specific vertex buffer is associated with this mesh
  87726. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87727. * - VertexBuffer.PositionKind
  87728. * - VertexBuffer.NormalKind
  87729. * - VertexBuffer.UVKind
  87730. * - VertexBuffer.UV2Kind
  87731. * - VertexBuffer.UV3Kind
  87732. * - VertexBuffer.UV4Kind
  87733. * - VertexBuffer.UV5Kind
  87734. * - VertexBuffer.UV6Kind
  87735. * - VertexBuffer.ColorKind
  87736. * - VertexBuffer.MatricesIndicesKind
  87737. * - VertexBuffer.MatricesIndicesExtraKind
  87738. * - VertexBuffer.MatricesWeightsKind
  87739. * - VertexBuffer.MatricesWeightsExtraKind
  87740. * @returns a boolean
  87741. */
  87742. isVerticesDataPresent(kind: string): boolean;
  87743. /**
  87744. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87745. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87746. * - VertexBuffer.PositionKind
  87747. * - VertexBuffer.UVKind
  87748. * - VertexBuffer.UV2Kind
  87749. * - VertexBuffer.UV3Kind
  87750. * - VertexBuffer.UV4Kind
  87751. * - VertexBuffer.UV5Kind
  87752. * - VertexBuffer.UV6Kind
  87753. * - VertexBuffer.ColorKind
  87754. * - VertexBuffer.MatricesIndicesKind
  87755. * - VertexBuffer.MatricesIndicesExtraKind
  87756. * - VertexBuffer.MatricesWeightsKind
  87757. * - VertexBuffer.MatricesWeightsExtraKind
  87758. * @returns a boolean
  87759. */
  87760. isVertexBufferUpdatable(kind: string): boolean;
  87761. /**
  87762. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87764. * - VertexBuffer.PositionKind
  87765. * - VertexBuffer.NormalKind
  87766. * - VertexBuffer.UVKind
  87767. * - VertexBuffer.UV2Kind
  87768. * - VertexBuffer.UV3Kind
  87769. * - VertexBuffer.UV4Kind
  87770. * - VertexBuffer.UV5Kind
  87771. * - VertexBuffer.UV6Kind
  87772. * - VertexBuffer.ColorKind
  87773. * - VertexBuffer.MatricesIndicesKind
  87774. * - VertexBuffer.MatricesIndicesExtraKind
  87775. * - VertexBuffer.MatricesWeightsKind
  87776. * - VertexBuffer.MatricesWeightsExtraKind
  87777. * @returns an array of strings
  87778. */
  87779. getVerticesDataKinds(): string[];
  87780. /**
  87781. * Returns a positive integer : the total number of indices in this mesh geometry.
  87782. * @returns the numner of indices or zero if the mesh has no geometry.
  87783. */
  87784. getTotalIndices(): number;
  87785. /**
  87786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87787. * @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.
  87788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87789. * @returns the indices array or an empty array if the mesh has no geometry
  87790. */
  87791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87792. readonly isBlocked: boolean;
  87793. /**
  87794. * Determine if the current mesh is ready to be rendered
  87795. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87796. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87797. * @returns true if all associated assets are ready (material, textures, shaders)
  87798. */
  87799. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87800. /**
  87801. * 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.
  87802. */
  87803. readonly areNormalsFrozen: boolean;
  87804. /**
  87805. * 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.
  87806. * @returns the current mesh
  87807. */
  87808. freezeNormals(): Mesh;
  87809. /**
  87810. * 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
  87811. * @returns the current mesh
  87812. */
  87813. unfreezeNormals(): Mesh;
  87814. /**
  87815. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87816. */
  87817. overridenInstanceCount: number;
  87818. /** @hidden */
  87819. _preActivate(): Mesh;
  87820. /** @hidden */
  87821. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87822. /** @hidden */
  87823. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87824. /**
  87825. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87826. * This means the mesh underlying bounding box and sphere are recomputed.
  87827. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87828. * @returns the current mesh
  87829. */
  87830. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87831. /** @hidden */
  87832. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87833. /**
  87834. * This function will subdivide the mesh into multiple submeshes
  87835. * @param count defines the expected number of submeshes
  87836. */
  87837. subdivide(count: number): void;
  87838. /**
  87839. * Copy a FloatArray into a specific associated vertex buffer
  87840. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87841. * - VertexBuffer.PositionKind
  87842. * - VertexBuffer.UVKind
  87843. * - VertexBuffer.UV2Kind
  87844. * - VertexBuffer.UV3Kind
  87845. * - VertexBuffer.UV4Kind
  87846. * - VertexBuffer.UV5Kind
  87847. * - VertexBuffer.UV6Kind
  87848. * - VertexBuffer.ColorKind
  87849. * - VertexBuffer.MatricesIndicesKind
  87850. * - VertexBuffer.MatricesIndicesExtraKind
  87851. * - VertexBuffer.MatricesWeightsKind
  87852. * - VertexBuffer.MatricesWeightsExtraKind
  87853. * @param data defines the data source
  87854. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87855. * @param stride defines the data stride size (can be null)
  87856. * @returns the current mesh
  87857. */
  87858. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87859. /**
  87860. * Flags an associated vertex buffer as updatable
  87861. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87862. * - VertexBuffer.PositionKind
  87863. * - VertexBuffer.UVKind
  87864. * - VertexBuffer.UV2Kind
  87865. * - VertexBuffer.UV3Kind
  87866. * - VertexBuffer.UV4Kind
  87867. * - VertexBuffer.UV5Kind
  87868. * - VertexBuffer.UV6Kind
  87869. * - VertexBuffer.ColorKind
  87870. * - VertexBuffer.MatricesIndicesKind
  87871. * - VertexBuffer.MatricesIndicesExtraKind
  87872. * - VertexBuffer.MatricesWeightsKind
  87873. * - VertexBuffer.MatricesWeightsExtraKind
  87874. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87875. */
  87876. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87877. /**
  87878. * Sets the mesh global Vertex Buffer
  87879. * @param buffer defines the buffer to use
  87880. * @returns the current mesh
  87881. */
  87882. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87883. /**
  87884. * Update a specific associated vertex buffer
  87885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87886. * - VertexBuffer.PositionKind
  87887. * - VertexBuffer.UVKind
  87888. * - VertexBuffer.UV2Kind
  87889. * - VertexBuffer.UV3Kind
  87890. * - VertexBuffer.UV4Kind
  87891. * - VertexBuffer.UV5Kind
  87892. * - VertexBuffer.UV6Kind
  87893. * - VertexBuffer.ColorKind
  87894. * - VertexBuffer.MatricesIndicesKind
  87895. * - VertexBuffer.MatricesIndicesExtraKind
  87896. * - VertexBuffer.MatricesWeightsKind
  87897. * - VertexBuffer.MatricesWeightsExtraKind
  87898. * @param data defines the data source
  87899. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87900. * @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)
  87901. * @returns the current mesh
  87902. */
  87903. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87904. /**
  87905. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87906. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87907. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87908. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87909. * @returns the current mesh
  87910. */
  87911. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87912. /**
  87913. * Creates a un-shared specific occurence of the geometry for the mesh.
  87914. * @returns the current mesh
  87915. */
  87916. makeGeometryUnique(): Mesh;
  87917. /**
  87918. * Set the index buffer of this mesh
  87919. * @param indices defines the source data
  87920. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87921. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87922. * @returns the current mesh
  87923. */
  87924. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87925. /**
  87926. * Update the current index buffer
  87927. * @param indices defines the source data
  87928. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87929. * @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)
  87930. * @returns the current mesh
  87931. */
  87932. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87933. /**
  87934. * Invert the geometry to move from a right handed system to a left handed one.
  87935. * @returns the current mesh
  87936. */
  87937. toLeftHanded(): Mesh;
  87938. /** @hidden */
  87939. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87940. /** @hidden */
  87941. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87942. /**
  87943. * Registers for this mesh a javascript function called just before the rendering process
  87944. * @param func defines the function to call before rendering this mesh
  87945. * @returns the current mesh
  87946. */
  87947. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87948. /**
  87949. * Disposes a previously registered javascript function called before the rendering
  87950. * @param func defines the function to remove
  87951. * @returns the current mesh
  87952. */
  87953. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87954. /**
  87955. * Registers for this mesh a javascript function called just after the rendering is complete
  87956. * @param func defines the function to call after rendering this mesh
  87957. * @returns the current mesh
  87958. */
  87959. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87960. /**
  87961. * Disposes a previously registered javascript function called after the rendering.
  87962. * @param func defines the function to remove
  87963. * @returns the current mesh
  87964. */
  87965. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87966. /** @hidden */
  87967. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87968. /** @hidden */
  87969. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87970. /** @hidden */
  87971. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87972. /** @hidden */
  87973. _rebuild(): void;
  87974. /** @hidden */
  87975. _freeze(): void;
  87976. /** @hidden */
  87977. _unFreeze(): void;
  87978. /**
  87979. * 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
  87980. * @param subMesh defines the subMesh to render
  87981. * @param enableAlphaMode defines if alpha mode can be changed
  87982. * @returns the current mesh
  87983. */
  87984. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87985. private _onBeforeDraw;
  87986. /**
  87987. * Renormalize the mesh and patch it up if there are no weights
  87988. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87989. * However in the case of zero weights then we set just a single influence to 1.
  87990. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87991. */
  87992. cleanMatrixWeights(): void;
  87993. private normalizeSkinFourWeights;
  87994. private normalizeSkinWeightsAndExtra;
  87995. /**
  87996. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87997. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87998. * the user know there was an issue with importing the mesh
  87999. * @returns a validation object with skinned, valid and report string
  88000. */
  88001. validateSkinning(): {
  88002. skinned: boolean;
  88003. valid: boolean;
  88004. report: string;
  88005. };
  88006. /** @hidden */
  88007. _checkDelayState(): Mesh;
  88008. private _queueLoad;
  88009. /**
  88010. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88011. * A mesh is in the frustum if its bounding box intersects the frustum
  88012. * @param frustumPlanes defines the frustum to test
  88013. * @returns true if the mesh is in the frustum planes
  88014. */
  88015. isInFrustum(frustumPlanes: Plane[]): boolean;
  88016. /**
  88017. * Sets the mesh material by the material or multiMaterial `id` property
  88018. * @param id is a string identifying the material or the multiMaterial
  88019. * @returns the current mesh
  88020. */
  88021. setMaterialByID(id: string): Mesh;
  88022. /**
  88023. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88024. * @returns an array of IAnimatable
  88025. */
  88026. getAnimatables(): IAnimatable[];
  88027. /**
  88028. * Modifies the mesh geometry according to the passed transformation matrix.
  88029. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88030. * The mesh normals are modified using the same transformation.
  88031. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88032. * @param transform defines the transform matrix to use
  88033. * @see http://doc.babylonjs.com/resources/baking_transformations
  88034. * @returns the current mesh
  88035. */
  88036. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88037. /**
  88038. * Modifies the mesh geometry according to its own current World Matrix.
  88039. * The mesh World Matrix is then reset.
  88040. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88041. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88042. * @see http://doc.babylonjs.com/resources/baking_transformations
  88043. * @returns the current mesh
  88044. */
  88045. bakeCurrentTransformIntoVertices(): Mesh;
  88046. /** @hidden */
  88047. readonly _positions: Nullable<Vector3[]>;
  88048. /** @hidden */
  88049. _resetPointsArrayCache(): Mesh;
  88050. /** @hidden */
  88051. _generatePointsArray(): boolean;
  88052. /**
  88053. * Returns a new Mesh object generated from the current mesh properties.
  88054. * This method must not get confused with createInstance()
  88055. * @param name is a string, the name given to the new mesh
  88056. * @param newParent can be any Node object (default `null`)
  88057. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88058. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88059. * @returns a new mesh
  88060. */
  88061. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  88062. /**
  88063. * Releases resources associated with this mesh.
  88064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88066. */
  88067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88068. /**
  88069. * Modifies the mesh geometry according to a displacement map.
  88070. * 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.
  88071. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88072. * @param url is a string, the URL from the image file is to be downloaded.
  88073. * @param minHeight is the lower limit of the displacement.
  88074. * @param maxHeight is the upper limit of the displacement.
  88075. * @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.
  88076. * @param uvOffset is an optional vector2 used to offset UV.
  88077. * @param uvScale is an optional vector2 used to scale UV.
  88078. * @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.
  88079. * @returns the Mesh.
  88080. */
  88081. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88082. /**
  88083. * Modifies the mesh geometry according to a displacementMap buffer.
  88084. * 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.
  88085. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88086. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88087. * @param heightMapWidth is the width of the buffer image.
  88088. * @param heightMapHeight is the height of the buffer image.
  88089. * @param minHeight is the lower limit of the displacement.
  88090. * @param maxHeight is the upper limit of the displacement.
  88091. * @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.
  88092. * @param uvOffset is an optional vector2 used to offset UV.
  88093. * @param uvScale is an optional vector2 used to scale UV.
  88094. * @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.
  88095. * @returns the Mesh.
  88096. */
  88097. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88098. /**
  88099. * Modify the mesh to get a flat shading rendering.
  88100. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88101. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88102. * @returns current mesh
  88103. */
  88104. convertToFlatShadedMesh(): Mesh;
  88105. /**
  88106. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88107. * In other words, more vertices, no more indices and a single bigger VBO.
  88108. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88109. * @returns current mesh
  88110. */
  88111. convertToUnIndexedMesh(): Mesh;
  88112. /**
  88113. * Inverses facet orientations.
  88114. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88115. * @param flipNormals will also inverts the normals
  88116. * @returns current mesh
  88117. */
  88118. flipFaces(flipNormals?: boolean): Mesh;
  88119. /**
  88120. * Increase the number of facets and hence vertices in a mesh
  88121. * Vertex normals are interpolated from existing vertex normals
  88122. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88123. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88124. */
  88125. increaseVertices(numberPerEdge: number): void;
  88126. /**
  88127. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88128. * This will undo any application of covertToFlatShadedMesh
  88129. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88130. */
  88131. forceSharedVertices(): void;
  88132. /** @hidden */
  88133. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88134. /** @hidden */
  88135. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88136. /**
  88137. * Creates a new InstancedMesh object from the mesh model.
  88138. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88139. * @param name defines the name of the new instance
  88140. * @returns a new InstancedMesh
  88141. */
  88142. createInstance(name: string): InstancedMesh;
  88143. /**
  88144. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88145. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88146. * @returns the current mesh
  88147. */
  88148. synchronizeInstances(): Mesh;
  88149. /**
  88150. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88151. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88152. * This should be used together with the simplification to avoid disappearing triangles.
  88153. * @param successCallback an optional success callback to be called after the optimization finished.
  88154. * @returns the current mesh
  88155. */
  88156. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88157. /**
  88158. * Serialize current mesh
  88159. * @param serializationObject defines the object which will receive the serialization data
  88160. */
  88161. serialize(serializationObject: any): void;
  88162. /** @hidden */
  88163. _syncGeometryWithMorphTargetManager(): void;
  88164. /** @hidden */
  88165. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88166. /**
  88167. * Returns a new Mesh object parsed from the source provided.
  88168. * @param parsedMesh is the source
  88169. * @param scene defines the hosting scene
  88170. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88171. * @returns a new Mesh
  88172. */
  88173. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88174. /**
  88175. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88176. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88177. * @param name defines the name of the mesh to create
  88178. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88179. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88180. * @param closePath creates a seam between the first and the last points of each path of the path array
  88181. * @param offset is taken in account only if the `pathArray` is containing a single path
  88182. * @param scene defines the hosting scene
  88183. * @param updatable defines if the mesh must be flagged as updatable
  88184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88185. * @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)
  88186. * @returns a new Mesh
  88187. */
  88188. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88189. /**
  88190. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88191. * @param name defines the name of the mesh to create
  88192. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88193. * @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
  88194. * @param scene defines the hosting scene
  88195. * @param updatable defines if the mesh must be flagged as updatable
  88196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88197. * @returns a new Mesh
  88198. */
  88199. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88200. /**
  88201. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88202. * @param name defines the name of the mesh to create
  88203. * @param size sets the size (float) of each box side (default 1)
  88204. * @param scene defines the hosting scene
  88205. * @param updatable defines if the mesh must be flagged as updatable
  88206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88207. * @returns a new Mesh
  88208. */
  88209. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88210. /**
  88211. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88212. * @param name defines the name of the mesh to create
  88213. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88214. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88215. * @param scene defines the hosting scene
  88216. * @param updatable defines if the mesh must be flagged as updatable
  88217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88218. * @returns a new Mesh
  88219. */
  88220. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88221. /**
  88222. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88223. * @param name defines the name of the mesh to create
  88224. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88225. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88226. * @param scene defines the hosting scene
  88227. * @returns a new Mesh
  88228. */
  88229. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88230. /**
  88231. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88232. * @param name defines the name of the mesh to create
  88233. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88234. * @param diameterTop set the top cap diameter (floats, default 1)
  88235. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88236. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88237. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88238. * @param scene defines the hosting scene
  88239. * @param updatable defines if the mesh must be flagged as updatable
  88240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88241. * @returns a new Mesh
  88242. */
  88243. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88244. /**
  88245. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88246. * @param name defines the name of the mesh to create
  88247. * @param diameter sets the diameter size (float) of the torus (default 1)
  88248. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88249. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88250. * @param scene defines the hosting scene
  88251. * @param updatable defines if the mesh must be flagged as updatable
  88252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88253. * @returns a new Mesh
  88254. */
  88255. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88256. /**
  88257. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88258. * @param name defines the name of the mesh to create
  88259. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88260. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88261. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88262. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88263. * @param p the number of windings on X axis (positive integers, default 2)
  88264. * @param q the number of windings on Y axis (positive integers, default 3)
  88265. * @param scene defines the hosting scene
  88266. * @param updatable defines if the mesh must be flagged as updatable
  88267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88268. * @returns a new Mesh
  88269. */
  88270. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88271. /**
  88272. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88273. * @param name defines the name of the mesh to create
  88274. * @param points is an array successive Vector3
  88275. * @param scene defines the hosting scene
  88276. * @param updatable defines if the mesh must be flagged as updatable
  88277. * @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).
  88278. * @returns a new Mesh
  88279. */
  88280. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88281. /**
  88282. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88283. * @param name defines the name of the mesh to create
  88284. * @param points is an array successive Vector3
  88285. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88286. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88287. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88288. * @param scene defines the hosting scene
  88289. * @param updatable defines if the mesh must be flagged as updatable
  88290. * @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)
  88291. * @returns a new Mesh
  88292. */
  88293. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88294. /**
  88295. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88296. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88297. * 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.
  88298. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88299. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88300. * Remember you can only change the shape positions, not their number when updating a polygon.
  88301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88302. * @param name defines the name of the mesh to create
  88303. * @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
  88304. * @param scene defines the hosting scene
  88305. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88306. * @param updatable defines if the mesh must be flagged as updatable
  88307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88308. * @param earcutInjection can be used to inject your own earcut reference
  88309. * @returns a new Mesh
  88310. */
  88311. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88312. /**
  88313. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88315. * @param name defines the name of the mesh to create
  88316. * @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
  88317. * @param depth defines the height of extrusion
  88318. * @param scene defines the hosting scene
  88319. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88320. * @param updatable defines if the mesh must be flagged as updatable
  88321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88322. * @param earcutInjection can be used to inject your own earcut reference
  88323. * @returns a new Mesh
  88324. */
  88325. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88326. /**
  88327. * Creates an extruded shape mesh.
  88328. * 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
  88329. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88330. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88331. * @param name defines the name of the mesh to create
  88332. * @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
  88333. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88334. * @param scale is the value to scale the shape
  88335. * @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
  88336. * @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
  88337. * @param scene defines the hosting scene
  88338. * @param updatable defines if the mesh must be flagged as updatable
  88339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88340. * @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)
  88341. * @returns a new Mesh
  88342. */
  88343. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88344. /**
  88345. * Creates an custom extruded shape mesh.
  88346. * The custom extrusion is a parametric shape.
  88347. * It has no predefined shape. Its final shape will depend on the input parameters.
  88348. * Please consider using the same method from the MeshBuilder class instead
  88349. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88350. * @param name defines the name of the mesh to create
  88351. * @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
  88352. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88353. * @param scaleFunction is a custom Javascript function called on each path point
  88354. * @param rotationFunction is a custom Javascript function called on each path point
  88355. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88356. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88357. * @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
  88358. * @param scene defines the hosting scene
  88359. * @param updatable defines if the mesh must be flagged as updatable
  88360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88361. * @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)
  88362. * @returns a new Mesh
  88363. */
  88364. 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;
  88365. /**
  88366. * Creates lathe mesh.
  88367. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88368. * Please consider using the same method from the MeshBuilder class instead
  88369. * @param name defines the name of the mesh to create
  88370. * @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
  88371. * @param radius is the radius value of the lathe
  88372. * @param tessellation is the side number of the lathe.
  88373. * @param scene defines the hosting scene
  88374. * @param updatable defines if the mesh must be flagged as updatable
  88375. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88376. * @returns a new Mesh
  88377. */
  88378. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88379. /**
  88380. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88381. * @param name defines the name of the mesh to create
  88382. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88383. * @param scene defines the hosting scene
  88384. * @param updatable defines if the mesh must be flagged as updatable
  88385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88386. * @returns a new Mesh
  88387. */
  88388. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88389. /**
  88390. * Creates a ground mesh.
  88391. * Please consider using the same method from the MeshBuilder class instead
  88392. * @param name defines the name of the mesh to create
  88393. * @param width set the width of the ground
  88394. * @param height set the height of the ground
  88395. * @param subdivisions sets the number of subdivisions per side
  88396. * @param scene defines the hosting scene
  88397. * @param updatable defines if the mesh must be flagged as updatable
  88398. * @returns a new Mesh
  88399. */
  88400. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88401. /**
  88402. * Creates a tiled ground mesh.
  88403. * Please consider using the same method from the MeshBuilder class instead
  88404. * @param name defines the name of the mesh to create
  88405. * @param xmin set the ground minimum X coordinate
  88406. * @param zmin set the ground minimum Y coordinate
  88407. * @param xmax set the ground maximum X coordinate
  88408. * @param zmax set the ground maximum Z coordinate
  88409. * @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
  88410. * @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
  88411. * @param scene defines the hosting scene
  88412. * @param updatable defines if the mesh must be flagged as updatable
  88413. * @returns a new Mesh
  88414. */
  88415. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88416. w: number;
  88417. h: number;
  88418. }, precision: {
  88419. w: number;
  88420. h: number;
  88421. }, scene: Scene, updatable?: boolean): Mesh;
  88422. /**
  88423. * Creates a ground mesh from a height map.
  88424. * Please consider using the same method from the MeshBuilder class instead
  88425. * @see http://doc.babylonjs.com/babylon101/height_map
  88426. * @param name defines the name of the mesh to create
  88427. * @param url sets the URL of the height map image resource
  88428. * @param width set the ground width size
  88429. * @param height set the ground height size
  88430. * @param subdivisions sets the number of subdivision per side
  88431. * @param minHeight is the minimum altitude on the ground
  88432. * @param maxHeight is the maximum altitude on the ground
  88433. * @param scene defines the hosting scene
  88434. * @param updatable defines if the mesh must be flagged as updatable
  88435. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88436. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88437. * @returns a new Mesh
  88438. */
  88439. 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;
  88440. /**
  88441. * Creates a tube mesh.
  88442. * The tube is a parametric shape.
  88443. * It has no predefined shape. Its final shape will depend on the input parameters.
  88444. * Please consider using the same method from the MeshBuilder class instead
  88445. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88446. * @param name defines the name of the mesh to create
  88447. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88448. * @param radius sets the tube radius size
  88449. * @param tessellation is the number of sides on the tubular surface
  88450. * @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
  88451. * @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
  88452. * @param scene defines the hosting scene
  88453. * @param updatable defines if the mesh must be flagged as updatable
  88454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88455. * @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)
  88456. * @returns a new Mesh
  88457. */
  88458. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88459. (i: number, distance: number): number;
  88460. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88461. /**
  88462. * Creates a polyhedron mesh.
  88463. * Please consider using the same method from the MeshBuilder class instead.
  88464. * * 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
  88465. * * The parameter `size` (positive float, default 1) sets the polygon size
  88466. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88467. * * 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`
  88468. * * 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
  88469. * * 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)`)
  88470. * * 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
  88471. * * 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
  88472. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88473. * * If you create a double-sided mesh, you can choose what parts of 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
  88474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88475. * @param name defines the name of the mesh to create
  88476. * @param options defines the options used to create the mesh
  88477. * @param scene defines the hosting scene
  88478. * @returns a new Mesh
  88479. */
  88480. static CreatePolyhedron(name: string, options: {
  88481. type?: number;
  88482. size?: number;
  88483. sizeX?: number;
  88484. sizeY?: number;
  88485. sizeZ?: number;
  88486. custom?: any;
  88487. faceUV?: Vector4[];
  88488. faceColors?: Color4[];
  88489. updatable?: boolean;
  88490. sideOrientation?: number;
  88491. }, scene: Scene): Mesh;
  88492. /**
  88493. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88494. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88495. * * 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`)
  88496. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88497. * * 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
  88498. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88499. * * If you create a double-sided mesh, you can choose what parts of 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
  88500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88501. * @param name defines the name of the mesh
  88502. * @param options defines the options used to create the mesh
  88503. * @param scene defines the hosting scene
  88504. * @returns a new Mesh
  88505. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88506. */
  88507. static CreateIcoSphere(name: string, options: {
  88508. radius?: number;
  88509. flat?: boolean;
  88510. subdivisions?: number;
  88511. sideOrientation?: number;
  88512. updatable?: boolean;
  88513. }, scene: Scene): Mesh;
  88514. /**
  88515. * Creates a decal mesh.
  88516. * Please consider using the same method from the MeshBuilder class instead.
  88517. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88518. * @param name defines the name of the mesh
  88519. * @param sourceMesh defines the mesh receiving the decal
  88520. * @param position sets the position of the decal in world coordinates
  88521. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88522. * @param size sets the decal scaling
  88523. * @param angle sets the angle to rotate the decal
  88524. * @returns a new Mesh
  88525. */
  88526. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88527. /**
  88528. * Prepare internal position array for software CPU skinning
  88529. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88530. */
  88531. setPositionsForCPUSkinning(): Float32Array;
  88532. /**
  88533. * Prepare internal normal array for software CPU skinning
  88534. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88535. */
  88536. setNormalsForCPUSkinning(): Float32Array;
  88537. /**
  88538. * Updates the vertex buffer by applying transformation from the bones
  88539. * @param skeleton defines the skeleton to apply to current mesh
  88540. * @returns the current mesh
  88541. */
  88542. applySkeleton(skeleton: Skeleton): Mesh;
  88543. /**
  88544. * 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
  88545. * @param meshes defines the list of meshes to scan
  88546. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88547. */
  88548. static MinMax(meshes: AbstractMesh[]): {
  88549. min: Vector3;
  88550. max: Vector3;
  88551. };
  88552. /**
  88553. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88554. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88555. * @returns a vector3
  88556. */
  88557. static Center(meshesOrMinMaxVector: {
  88558. min: Vector3;
  88559. max: Vector3;
  88560. } | AbstractMesh[]): Vector3;
  88561. /**
  88562. * Merge the array of meshes into a single mesh for performance reasons.
  88563. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88564. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88565. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88566. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88567. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88568. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88569. * @returns a new mesh
  88570. */
  88571. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88572. /** @hidden */
  88573. addInstance(instance: InstancedMesh): void;
  88574. /** @hidden */
  88575. removeInstance(instance: InstancedMesh): void;
  88576. }
  88577. }
  88578. declare module BABYLON {
  88579. /**
  88580. * This is the base class of all the camera used in the application.
  88581. * @see http://doc.babylonjs.com/features/cameras
  88582. */
  88583. export class Camera extends Node {
  88584. /** @hidden */
  88585. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88586. /**
  88587. * This is the default projection mode used by the cameras.
  88588. * It helps recreating a feeling of perspective and better appreciate depth.
  88589. * This is the best way to simulate real life cameras.
  88590. */
  88591. static readonly PERSPECTIVE_CAMERA: number;
  88592. /**
  88593. * This helps creating camera with an orthographic mode.
  88594. * 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.
  88595. */
  88596. static readonly ORTHOGRAPHIC_CAMERA: number;
  88597. /**
  88598. * This is the default FOV mode for perspective cameras.
  88599. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88600. */
  88601. static readonly FOVMODE_VERTICAL_FIXED: number;
  88602. /**
  88603. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88604. */
  88605. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88606. /**
  88607. * This specifies ther is no need for a camera rig.
  88608. * Basically only one eye is rendered corresponding to the camera.
  88609. */
  88610. static readonly RIG_MODE_NONE: number;
  88611. /**
  88612. * Simulates a camera Rig with one blue eye and one red eye.
  88613. * This can be use with 3d blue and red glasses.
  88614. */
  88615. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88616. /**
  88617. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88618. */
  88619. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88620. /**
  88621. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88622. */
  88623. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88624. /**
  88625. * Defines that both eyes of the camera will be rendered over under each other.
  88626. */
  88627. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88628. /**
  88629. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88630. */
  88631. static readonly RIG_MODE_VR: number;
  88632. /**
  88633. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88634. */
  88635. static readonly RIG_MODE_WEBVR: number;
  88636. /**
  88637. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88638. */
  88639. static readonly RIG_MODE_CUSTOM: number;
  88640. /**
  88641. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88642. */
  88643. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88644. /**
  88645. * Define the input manager associated with the camera.
  88646. */
  88647. inputs: CameraInputsManager<Camera>;
  88648. /** @hidden */
  88649. _position: Vector3;
  88650. /**
  88651. * Define the current local position of the camera in the scene
  88652. */
  88653. position: Vector3;
  88654. /**
  88655. * The vector the camera should consider as up.
  88656. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88657. */
  88658. upVector: Vector3;
  88659. /**
  88660. * Define the current limit on the left side for an orthographic camera
  88661. * In scene unit
  88662. */
  88663. orthoLeft: Nullable<number>;
  88664. /**
  88665. * Define the current limit on the right side for an orthographic camera
  88666. * In scene unit
  88667. */
  88668. orthoRight: Nullable<number>;
  88669. /**
  88670. * Define the current limit on the bottom side for an orthographic camera
  88671. * In scene unit
  88672. */
  88673. orthoBottom: Nullable<number>;
  88674. /**
  88675. * Define the current limit on the top side for an orthographic camera
  88676. * In scene unit
  88677. */
  88678. orthoTop: Nullable<number>;
  88679. /**
  88680. * Field Of View is set in Radians. (default is 0.8)
  88681. */
  88682. fov: number;
  88683. /**
  88684. * Define the minimum distance the camera can see from.
  88685. * This is important to note that the depth buffer are not infinite and the closer it starts
  88686. * the more your scene might encounter depth fighting issue.
  88687. */
  88688. minZ: number;
  88689. /**
  88690. * Define the maximum distance the camera can see to.
  88691. * This is important to note that the depth buffer are not infinite and the further it end
  88692. * the more your scene might encounter depth fighting issue.
  88693. */
  88694. maxZ: number;
  88695. /**
  88696. * Define the default inertia of the camera.
  88697. * This helps giving a smooth feeling to the camera movement.
  88698. */
  88699. inertia: number;
  88700. /**
  88701. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88702. */
  88703. mode: number;
  88704. /**
  88705. * Define wether the camera is intermediate.
  88706. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88707. */
  88708. isIntermediate: boolean;
  88709. /**
  88710. * Define the viewport of the camera.
  88711. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88712. */
  88713. viewport: Viewport;
  88714. /**
  88715. * Restricts the camera to viewing objects with the same layerMask.
  88716. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88717. */
  88718. layerMask: number;
  88719. /**
  88720. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88721. */
  88722. fovMode: number;
  88723. /**
  88724. * Rig mode of the camera.
  88725. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88726. * This is normally controlled byt the camera themselves as internal use.
  88727. */
  88728. cameraRigMode: number;
  88729. /**
  88730. * Defines the distance between both "eyes" in case of a RIG
  88731. */
  88732. interaxialDistance: number;
  88733. /**
  88734. * Defines if stereoscopic rendering is done side by side or over under.
  88735. */
  88736. isStereoscopicSideBySide: boolean;
  88737. /**
  88738. * 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
  88739. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88740. * else in the scene. (Eg. security camera)
  88741. *
  88742. * 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)
  88743. */
  88744. customRenderTargets: RenderTargetTexture[];
  88745. /**
  88746. * When set, the camera will render to this render target instead of the default canvas
  88747. *
  88748. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88749. */
  88750. outputRenderTarget: Nullable<RenderTargetTexture>;
  88751. /**
  88752. * Observable triggered when the camera view matrix has changed.
  88753. */
  88754. onViewMatrixChangedObservable: Observable<Camera>;
  88755. /**
  88756. * Observable triggered when the camera Projection matrix has changed.
  88757. */
  88758. onProjectionMatrixChangedObservable: Observable<Camera>;
  88759. /**
  88760. * Observable triggered when the inputs have been processed.
  88761. */
  88762. onAfterCheckInputsObservable: Observable<Camera>;
  88763. /**
  88764. * Observable triggered when reset has been called and applied to the camera.
  88765. */
  88766. onRestoreStateObservable: Observable<Camera>;
  88767. /** @hidden */
  88768. _cameraRigParams: any;
  88769. /** @hidden */
  88770. _rigCameras: Camera[];
  88771. /** @hidden */
  88772. _rigPostProcess: Nullable<PostProcess>;
  88773. protected _webvrViewMatrix: Matrix;
  88774. /** @hidden */
  88775. _skipRendering: boolean;
  88776. /** @hidden */
  88777. _projectionMatrix: Matrix;
  88778. /** @hidden */
  88779. _postProcesses: Nullable<PostProcess>[];
  88780. /** @hidden */
  88781. _activeMeshes: SmartArray<AbstractMesh>;
  88782. protected _globalPosition: Vector3;
  88783. /** @hidden */
  88784. _computedViewMatrix: Matrix;
  88785. private _doNotComputeProjectionMatrix;
  88786. private _transformMatrix;
  88787. private _frustumPlanes;
  88788. private _refreshFrustumPlanes;
  88789. private _storedFov;
  88790. private _stateStored;
  88791. /**
  88792. * Instantiates a new camera object.
  88793. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88794. * @see http://doc.babylonjs.com/features/cameras
  88795. * @param name Defines the name of the camera in the scene
  88796. * @param position Defines the position of the camera
  88797. * @param scene Defines the scene the camera belongs too
  88798. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88799. */
  88800. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88801. /**
  88802. * Store current camera state (fov, position, etc..)
  88803. * @returns the camera
  88804. */
  88805. storeState(): Camera;
  88806. /**
  88807. * Restores the camera state values if it has been stored. You must call storeState() first
  88808. */
  88809. protected _restoreStateValues(): boolean;
  88810. /**
  88811. * Restored camera state. You must call storeState() first.
  88812. * @returns true if restored and false otherwise
  88813. */
  88814. restoreState(): boolean;
  88815. /**
  88816. * Gets the class name of the camera.
  88817. * @returns the class name
  88818. */
  88819. getClassName(): string;
  88820. /** @hidden */
  88821. readonly _isCamera: boolean;
  88822. /**
  88823. * Gets a string representation of the camera useful for debug purpose.
  88824. * @param fullDetails Defines that a more verboe level of logging is required
  88825. * @returns the string representation
  88826. */
  88827. toString(fullDetails?: boolean): string;
  88828. /**
  88829. * Gets the current world space position of the camera.
  88830. */
  88831. readonly globalPosition: Vector3;
  88832. /**
  88833. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88834. * @returns the active meshe list
  88835. */
  88836. getActiveMeshes(): SmartArray<AbstractMesh>;
  88837. /**
  88838. * Check wether a mesh is part of the current active mesh list of the camera
  88839. * @param mesh Defines the mesh to check
  88840. * @returns true if active, false otherwise
  88841. */
  88842. isActiveMesh(mesh: Mesh): boolean;
  88843. /**
  88844. * Is this camera ready to be used/rendered
  88845. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88846. * @return true if the camera is ready
  88847. */
  88848. isReady(completeCheck?: boolean): boolean;
  88849. /** @hidden */
  88850. _initCache(): void;
  88851. /** @hidden */
  88852. _updateCache(ignoreParentClass?: boolean): void;
  88853. /** @hidden */
  88854. _isSynchronized(): boolean;
  88855. /** @hidden */
  88856. _isSynchronizedViewMatrix(): boolean;
  88857. /** @hidden */
  88858. _isSynchronizedProjectionMatrix(): boolean;
  88859. /**
  88860. * Attach the input controls to a specific dom element to get the input from.
  88861. * @param element Defines the element the controls should be listened from
  88862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88863. */
  88864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88865. /**
  88866. * Detach the current controls from the specified dom element.
  88867. * @param element Defines the element to stop listening the inputs from
  88868. */
  88869. detachControl(element: HTMLElement): void;
  88870. /**
  88871. * Update the camera state according to the different inputs gathered during the frame.
  88872. */
  88873. update(): void;
  88874. /** @hidden */
  88875. _checkInputs(): void;
  88876. /** @hidden */
  88877. readonly rigCameras: Camera[];
  88878. /**
  88879. * Gets the post process used by the rig cameras
  88880. */
  88881. readonly rigPostProcess: Nullable<PostProcess>;
  88882. /**
  88883. * Internal, gets the first post proces.
  88884. * @returns the first post process to be run on this camera.
  88885. */
  88886. _getFirstPostProcess(): Nullable<PostProcess>;
  88887. private _cascadePostProcessesToRigCams;
  88888. /**
  88889. * Attach a post process to the camera.
  88890. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88891. * @param postProcess The post process to attach to the camera
  88892. * @param insertAt The position of the post process in case several of them are in use in the scene
  88893. * @returns the position the post process has been inserted at
  88894. */
  88895. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88896. /**
  88897. * Detach a post process to the camera.
  88898. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88899. * @param postProcess The post process to detach from the camera
  88900. */
  88901. detachPostProcess(postProcess: PostProcess): void;
  88902. /**
  88903. * Gets the current world matrix of the camera
  88904. */
  88905. getWorldMatrix(): Matrix;
  88906. /** @hidden */
  88907. _getViewMatrix(): Matrix;
  88908. /**
  88909. * Gets the current view matrix of the camera.
  88910. * @param force forces the camera to recompute the matrix without looking at the cached state
  88911. * @returns the view matrix
  88912. */
  88913. getViewMatrix(force?: boolean): Matrix;
  88914. /**
  88915. * Freeze the projection matrix.
  88916. * It will prevent the cache check of the camera projection compute and can speed up perf
  88917. * if no parameter of the camera are meant to change
  88918. * @param projection Defines manually a projection if necessary
  88919. */
  88920. freezeProjectionMatrix(projection?: Matrix): void;
  88921. /**
  88922. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88923. */
  88924. unfreezeProjectionMatrix(): void;
  88925. /**
  88926. * Gets the current projection matrix of the camera.
  88927. * @param force forces the camera to recompute the matrix without looking at the cached state
  88928. * @returns the projection matrix
  88929. */
  88930. getProjectionMatrix(force?: boolean): Matrix;
  88931. /**
  88932. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88933. * @returns a Matrix
  88934. */
  88935. getTransformationMatrix(): Matrix;
  88936. private _updateFrustumPlanes;
  88937. /**
  88938. * Checks if a cullable object (mesh...) is in the camera frustum
  88939. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88940. * @param target The object to check
  88941. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88942. * @returns true if the object is in frustum otherwise false
  88943. */
  88944. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88945. /**
  88946. * Checks if a cullable object (mesh...) is in the camera frustum
  88947. * Unlike isInFrustum this cheks the full bounding box
  88948. * @param target The object to check
  88949. * @returns true if the object is in frustum otherwise false
  88950. */
  88951. isCompletelyInFrustum(target: ICullable): boolean;
  88952. /**
  88953. * Gets a ray in the forward direction from the camera.
  88954. * @param length Defines the length of the ray to create
  88955. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88956. * @param origin Defines the start point of the ray which defaults to the camera position
  88957. * @returns the forward ray
  88958. */
  88959. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88960. /**
  88961. * Releases resources associated with this node.
  88962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88964. */
  88965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88966. /** @hidden */
  88967. _isLeftCamera: boolean;
  88968. /**
  88969. * Gets the left camera of a rig setup in case of Rigged Camera
  88970. */
  88971. readonly isLeftCamera: boolean;
  88972. /** @hidden */
  88973. _isRightCamera: boolean;
  88974. /**
  88975. * Gets the right camera of a rig setup in case of Rigged Camera
  88976. */
  88977. readonly isRightCamera: boolean;
  88978. /**
  88979. * Gets the left camera of a rig setup in case of Rigged Camera
  88980. */
  88981. readonly leftCamera: Nullable<FreeCamera>;
  88982. /**
  88983. * Gets the right camera of a rig setup in case of Rigged Camera
  88984. */
  88985. readonly rightCamera: Nullable<FreeCamera>;
  88986. /**
  88987. * Gets the left camera target of a rig setup in case of Rigged Camera
  88988. * @returns the target position
  88989. */
  88990. getLeftTarget(): Nullable<Vector3>;
  88991. /**
  88992. * Gets the right camera target of a rig setup in case of Rigged Camera
  88993. * @returns the target position
  88994. */
  88995. getRightTarget(): Nullable<Vector3>;
  88996. /**
  88997. * @hidden
  88998. */
  88999. setCameraRigMode(mode: number, rigParams: any): void;
  89000. /** @hidden */
  89001. static _setStereoscopicRigMode(camera: Camera): void;
  89002. /** @hidden */
  89003. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89004. /** @hidden */
  89005. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89006. /** @hidden */
  89007. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89008. /** @hidden */
  89009. _getVRProjectionMatrix(): Matrix;
  89010. protected _updateCameraRotationMatrix(): void;
  89011. protected _updateWebVRCameraRotationMatrix(): void;
  89012. /**
  89013. * This function MUST be overwritten by the different WebVR cameras available.
  89014. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89015. * @hidden
  89016. */
  89017. _getWebVRProjectionMatrix(): Matrix;
  89018. /**
  89019. * This function MUST be overwritten by the different WebVR cameras available.
  89020. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89021. * @hidden
  89022. */
  89023. _getWebVRViewMatrix(): Matrix;
  89024. /** @hidden */
  89025. setCameraRigParameter(name: string, value: any): void;
  89026. /**
  89027. * needs to be overridden by children so sub has required properties to be copied
  89028. * @hidden
  89029. */
  89030. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89031. /**
  89032. * May need to be overridden by children
  89033. * @hidden
  89034. */
  89035. _updateRigCameras(): void;
  89036. /** @hidden */
  89037. _setupInputs(): void;
  89038. /**
  89039. * Serialiaze the camera setup to a json represention
  89040. * @returns the JSON representation
  89041. */
  89042. serialize(): any;
  89043. /**
  89044. * Clones the current camera.
  89045. * @param name The cloned camera name
  89046. * @returns the cloned camera
  89047. */
  89048. clone(name: string): Camera;
  89049. /**
  89050. * Gets the direction of the camera relative to a given local axis.
  89051. * @param localAxis Defines the reference axis to provide a relative direction.
  89052. * @return the direction
  89053. */
  89054. getDirection(localAxis: Vector3): Vector3;
  89055. /**
  89056. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89057. * @param localAxis Defines the reference axis to provide a relative direction.
  89058. * @param result Defines the vector to store the result in
  89059. */
  89060. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89061. /**
  89062. * Gets a camera constructor for a given camera type
  89063. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89064. * @param name The name of the camera the result will be able to instantiate
  89065. * @param scene The scene the result will construct the camera in
  89066. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89067. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89068. * @returns a factory method to construc the camera
  89069. */
  89070. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89071. /**
  89072. * Compute the world matrix of the camera.
  89073. * @returns the camera workd matrix
  89074. */
  89075. computeWorldMatrix(): Matrix;
  89076. /**
  89077. * Parse a JSON and creates the camera from the parsed information
  89078. * @param parsedCamera The JSON to parse
  89079. * @param scene The scene to instantiate the camera in
  89080. * @returns the newly constructed camera
  89081. */
  89082. static Parse(parsedCamera: any, scene: Scene): Camera;
  89083. }
  89084. }
  89085. declare module BABYLON {
  89086. /**
  89087. * Class containing static functions to help procedurally build meshes
  89088. */
  89089. export class DiscBuilder {
  89090. /**
  89091. * Creates a plane polygonal mesh. By default, this is a disc
  89092. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89093. * * 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
  89094. * * 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
  89095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89098. * @param name defines the name of the mesh
  89099. * @param options defines the options used to create the mesh
  89100. * @param scene defines the hosting scene
  89101. * @returns the plane polygonal mesh
  89102. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89103. */
  89104. static CreateDisc(name: string, options: {
  89105. radius?: number;
  89106. tessellation?: number;
  89107. arc?: number;
  89108. updatable?: boolean;
  89109. sideOrientation?: number;
  89110. frontUVs?: Vector4;
  89111. backUVs?: Vector4;
  89112. }, scene?: Nullable<Scene>): Mesh;
  89113. }
  89114. }
  89115. declare module BABYLON {
  89116. /**
  89117. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89118. *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.
  89119. * The SPS is also a particle system. It provides some methods to manage the particles.
  89120. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89121. *
  89122. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89123. */
  89124. export class SolidParticleSystem implements IDisposable {
  89125. /**
  89126. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89127. * Example : var p = SPS.particles[i];
  89128. */
  89129. particles: SolidParticle[];
  89130. /**
  89131. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89132. */
  89133. nbParticles: number;
  89134. /**
  89135. * If the particles must ever face the camera (default false). Useful for planar particles.
  89136. */
  89137. billboard: boolean;
  89138. /**
  89139. * Recompute normals when adding a shape
  89140. */
  89141. recomputeNormals: boolean;
  89142. /**
  89143. * This a counter ofr your own usage. It's not set by any SPS functions.
  89144. */
  89145. counter: number;
  89146. /**
  89147. * The SPS name. This name is also given to the underlying mesh.
  89148. */
  89149. name: string;
  89150. /**
  89151. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89152. */
  89153. mesh: Mesh;
  89154. /**
  89155. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89156. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89157. */
  89158. vars: any;
  89159. /**
  89160. * This array is populated when the SPS is set as 'pickable'.
  89161. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89162. * Each element of this array is an object `{idx: int, faceId: int}`.
  89163. * `idx` is the picked particle index in the `SPS.particles` array
  89164. * `faceId` is the picked face index counted within this particle.
  89165. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89166. */
  89167. pickedParticles: {
  89168. idx: number;
  89169. faceId: number;
  89170. }[];
  89171. /**
  89172. * This array is populated when `enableDepthSort` is set to true.
  89173. * Each element of this array is an instance of the class DepthSortedParticle.
  89174. */
  89175. depthSortedParticles: DepthSortedParticle[];
  89176. /**
  89177. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89178. * @hidden
  89179. */
  89180. _bSphereOnly: boolean;
  89181. /**
  89182. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89183. * @hidden
  89184. */
  89185. _bSphereRadiusFactor: number;
  89186. private _scene;
  89187. private _positions;
  89188. private _indices;
  89189. private _normals;
  89190. private _colors;
  89191. private _uvs;
  89192. private _indices32;
  89193. private _positions32;
  89194. private _normals32;
  89195. private _fixedNormal32;
  89196. private _colors32;
  89197. private _uvs32;
  89198. private _index;
  89199. private _updatable;
  89200. private _pickable;
  89201. private _isVisibilityBoxLocked;
  89202. private _alwaysVisible;
  89203. private _depthSort;
  89204. private _shapeCounter;
  89205. private _copy;
  89206. private _color;
  89207. private _computeParticleColor;
  89208. private _computeParticleTexture;
  89209. private _computeParticleRotation;
  89210. private _computeParticleVertex;
  89211. private _computeBoundingBox;
  89212. private _depthSortParticles;
  89213. private _camera;
  89214. private _mustUnrotateFixedNormals;
  89215. private _particlesIntersect;
  89216. private _needs32Bits;
  89217. /**
  89218. * Creates a SPS (Solid Particle System) object.
  89219. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89220. * @param scene (Scene) is the scene in which the SPS is added.
  89221. * @param options defines the options of the sps e.g.
  89222. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89223. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89224. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89225. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89226. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89227. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89228. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89229. */
  89230. constructor(name: string, scene: Scene, options?: {
  89231. updatable?: boolean;
  89232. isPickable?: boolean;
  89233. enableDepthSort?: boolean;
  89234. particleIntersection?: boolean;
  89235. boundingSphereOnly?: boolean;
  89236. bSphereRadiusFactor?: number;
  89237. });
  89238. /**
  89239. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89240. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89241. * @returns the created mesh
  89242. */
  89243. buildMesh(): Mesh;
  89244. /**
  89245. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89246. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89247. * Thus the particles generated from `digest()` have their property `position` set yet.
  89248. * @param mesh ( Mesh ) is the mesh to be digested
  89249. * @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
  89250. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89251. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89252. * @returns the current SPS
  89253. */
  89254. digest(mesh: Mesh, options?: {
  89255. facetNb?: number;
  89256. number?: number;
  89257. delta?: number;
  89258. }): SolidParticleSystem;
  89259. private _unrotateFixedNormals;
  89260. private _resetCopy;
  89261. private _meshBuilder;
  89262. private _posToShape;
  89263. private _uvsToShapeUV;
  89264. private _addParticle;
  89265. /**
  89266. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89267. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89268. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89269. * @param nb (positive integer) the number of particles to be created from this model
  89270. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89271. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89272. * @returns the number of shapes in the system
  89273. */
  89274. addShape(mesh: Mesh, nb: number, options?: {
  89275. positionFunction?: any;
  89276. vertexFunction?: any;
  89277. }): number;
  89278. private _rebuildParticle;
  89279. /**
  89280. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89281. * @returns the SPS.
  89282. */
  89283. rebuildMesh(): SolidParticleSystem;
  89284. /**
  89285. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89286. * This method calls `updateParticle()` for each particle of the SPS.
  89287. * For an animated SPS, it is usually called within the render loop.
  89288. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89289. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89290. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89291. * @returns the SPS.
  89292. */
  89293. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89294. /**
  89295. * Disposes the SPS.
  89296. */
  89297. dispose(): void;
  89298. /**
  89299. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89300. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89301. * @returns the SPS.
  89302. */
  89303. refreshVisibleSize(): SolidParticleSystem;
  89304. /**
  89305. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89306. * @param size the size (float) of the visibility box
  89307. * note : this doesn't lock the SPS mesh bounding box.
  89308. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89309. */
  89310. setVisibilityBox(size: number): void;
  89311. /**
  89312. * Gets whether the SPS as always visible or not
  89313. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89314. */
  89315. /**
  89316. * Sets the SPS as always visible or not
  89317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89318. */
  89319. isAlwaysVisible: boolean;
  89320. /**
  89321. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89322. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89323. */
  89324. /**
  89325. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89326. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89327. */
  89328. isVisibilityBoxLocked: boolean;
  89329. /**
  89330. * Tells to `setParticles()` to compute the particle rotations or not.
  89331. * Default value : true. The SPS is faster when it's set to false.
  89332. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89333. */
  89334. /**
  89335. * Gets if `setParticles()` computes the particle rotations or not.
  89336. * Default value : true. The SPS is faster when it's set to false.
  89337. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89338. */
  89339. computeParticleRotation: boolean;
  89340. /**
  89341. * Tells to `setParticles()` to compute the particle colors or not.
  89342. * Default value : true. The SPS is faster when it's set to false.
  89343. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89344. */
  89345. /**
  89346. * Gets if `setParticles()` computes the particle colors or not.
  89347. * Default value : true. The SPS is faster when it's set to false.
  89348. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89349. */
  89350. computeParticleColor: boolean;
  89351. /**
  89352. * Gets if `setParticles()` computes the particle textures or not.
  89353. * Default value : true. The SPS is faster when it's set to false.
  89354. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89355. */
  89356. computeParticleTexture: boolean;
  89357. /**
  89358. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89359. * Default value : false. The SPS is faster when it's set to false.
  89360. * Note : the particle custom vertex positions aren't stored values.
  89361. */
  89362. /**
  89363. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89364. * Default value : false. The SPS is faster when it's set to false.
  89365. * Note : the particle custom vertex positions aren't stored values.
  89366. */
  89367. computeParticleVertex: boolean;
  89368. /**
  89369. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89370. */
  89371. /**
  89372. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89373. */
  89374. computeBoundingBox: boolean;
  89375. /**
  89376. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89377. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89378. * Default : `true`
  89379. */
  89380. /**
  89381. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89382. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89383. * Default : `true`
  89384. */
  89385. depthSortParticles: boolean;
  89386. /**
  89387. * This function does nothing. It may be overwritten to set all the particle first values.
  89388. * The SPS doesn't call this function, you may have to call it by your own.
  89389. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89390. */
  89391. initParticles(): void;
  89392. /**
  89393. * This function does nothing. It may be overwritten to recycle a particle.
  89394. * The SPS doesn't call this function, you may have to call it by your own.
  89395. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89396. * @param particle The particle to recycle
  89397. * @returns the recycled particle
  89398. */
  89399. recycleParticle(particle: SolidParticle): SolidParticle;
  89400. /**
  89401. * Updates a particle : this function should be overwritten by the user.
  89402. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89403. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89404. * @example : just set a particle position or velocity and recycle conditions
  89405. * @param particle The particle to update
  89406. * @returns the updated particle
  89407. */
  89408. updateParticle(particle: SolidParticle): SolidParticle;
  89409. /**
  89410. * Updates a vertex of a particle : it can be overwritten by the user.
  89411. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89412. * @param particle the current particle
  89413. * @param vertex the current index of the current particle
  89414. * @param pt the index of the current vertex in the particle shape
  89415. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89416. * @example : just set a vertex particle position
  89417. * @returns the updated vertex
  89418. */
  89419. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89420. /**
  89421. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89422. * This does nothing and may be overwritten by the user.
  89423. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89424. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89425. * @param update the boolean update value actually passed to setParticles()
  89426. */
  89427. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89428. /**
  89429. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89430. * This will be passed three parameters.
  89431. * This does nothing and may be overwritten by the user.
  89432. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89433. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89434. * @param update the boolean update value actually passed to setParticles()
  89435. */
  89436. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89437. }
  89438. }
  89439. declare module BABYLON {
  89440. /**
  89441. * Represents one particle of a solid particle system.
  89442. */
  89443. export class SolidParticle {
  89444. /**
  89445. * particle global index
  89446. */
  89447. idx: number;
  89448. /**
  89449. * The color of the particle
  89450. */
  89451. color: Nullable<Color4>;
  89452. /**
  89453. * The world space position of the particle.
  89454. */
  89455. position: Vector3;
  89456. /**
  89457. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89458. */
  89459. rotation: Vector3;
  89460. /**
  89461. * The world space rotation quaternion of the particle.
  89462. */
  89463. rotationQuaternion: Nullable<Quaternion>;
  89464. /**
  89465. * The scaling of the particle.
  89466. */
  89467. scaling: Vector3;
  89468. /**
  89469. * The uvs of the particle.
  89470. */
  89471. uvs: Vector4;
  89472. /**
  89473. * The current speed of the particle.
  89474. */
  89475. velocity: Vector3;
  89476. /**
  89477. * The pivot point in the particle local space.
  89478. */
  89479. pivot: Vector3;
  89480. /**
  89481. * Must the particle be translated from its pivot point in its local space ?
  89482. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89483. * Default : false
  89484. */
  89485. translateFromPivot: boolean;
  89486. /**
  89487. * Is the particle active or not ?
  89488. */
  89489. alive: boolean;
  89490. /**
  89491. * Is the particle visible or not ?
  89492. */
  89493. isVisible: boolean;
  89494. /**
  89495. * Index of this particle in the global "positions" array (Internal use)
  89496. * @hidden
  89497. */
  89498. _pos: number;
  89499. /**
  89500. * @hidden Index of this particle in the global "indices" array (Internal use)
  89501. */
  89502. _ind: number;
  89503. /**
  89504. * @hidden ModelShape of this particle (Internal use)
  89505. */
  89506. _model: ModelShape;
  89507. /**
  89508. * ModelShape id of this particle
  89509. */
  89510. shapeId: number;
  89511. /**
  89512. * Index of the particle in its shape id (Internal use)
  89513. */
  89514. idxInShape: number;
  89515. /**
  89516. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89517. */
  89518. _modelBoundingInfo: BoundingInfo;
  89519. /**
  89520. * @hidden Particle BoundingInfo object (Internal use)
  89521. */
  89522. _boundingInfo: BoundingInfo;
  89523. /**
  89524. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89525. */
  89526. _sps: SolidParticleSystem;
  89527. /**
  89528. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89529. */
  89530. _stillInvisible: boolean;
  89531. /**
  89532. * @hidden Last computed particle rotation matrix
  89533. */
  89534. _rotationMatrix: number[];
  89535. /**
  89536. * Parent particle Id, if any.
  89537. * Default null.
  89538. */
  89539. parentId: Nullable<number>;
  89540. /**
  89541. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89542. * The possible values are :
  89543. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89544. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89547. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89548. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89549. * */
  89550. cullingStrategy: number;
  89551. /**
  89552. * @hidden Internal global position in the SPS.
  89553. */
  89554. _globalPosition: Vector3;
  89555. /**
  89556. * Creates a Solid Particle object.
  89557. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89558. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89559. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89560. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89561. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89562. * @param shapeId (integer) is the model shape identifier in the SPS.
  89563. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89564. * @param sps defines the sps it is associated to
  89565. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89566. */
  89567. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89568. /**
  89569. * Legacy support, changed scale to scaling
  89570. */
  89571. /**
  89572. * Legacy support, changed scale to scaling
  89573. */
  89574. scale: Vector3;
  89575. /**
  89576. * Legacy support, changed quaternion to rotationQuaternion
  89577. */
  89578. /**
  89579. * Legacy support, changed quaternion to rotationQuaternion
  89580. */
  89581. quaternion: Nullable<Quaternion>;
  89582. /**
  89583. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89584. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89585. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89586. * @returns true if it intersects
  89587. */
  89588. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89589. /**
  89590. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89591. * A particle is in the frustum if its bounding box intersects the frustum
  89592. * @param frustumPlanes defines the frustum to test
  89593. * @returns true if the particle is in the frustum planes
  89594. */
  89595. isInFrustum(frustumPlanes: Plane[]): boolean;
  89596. /**
  89597. * get the rotation matrix of the particle
  89598. * @hidden
  89599. */
  89600. getRotationMatrix(m: Matrix): void;
  89601. }
  89602. /**
  89603. * Represents the shape of the model used by one particle of a solid particle system.
  89604. * SPS internal tool, don't use it manually.
  89605. */
  89606. export class ModelShape {
  89607. /**
  89608. * The shape id
  89609. * @hidden
  89610. */
  89611. shapeID: number;
  89612. /**
  89613. * flat array of model positions (internal use)
  89614. * @hidden
  89615. */
  89616. _shape: Vector3[];
  89617. /**
  89618. * flat array of model UVs (internal use)
  89619. * @hidden
  89620. */
  89621. _shapeUV: number[];
  89622. /**
  89623. * length of the shape in the model indices array (internal use)
  89624. * @hidden
  89625. */
  89626. _indicesLength: number;
  89627. /**
  89628. * Custom position function (internal use)
  89629. * @hidden
  89630. */
  89631. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89632. /**
  89633. * Custom vertex function (internal use)
  89634. * @hidden
  89635. */
  89636. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89637. /**
  89638. * 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.
  89639. * SPS internal tool, don't use it manually.
  89640. * @hidden
  89641. */
  89642. 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>);
  89643. }
  89644. /**
  89645. * Represents a Depth Sorted Particle in the solid particle system.
  89646. */
  89647. export class DepthSortedParticle {
  89648. /**
  89649. * Index of the particle in the "indices" array
  89650. */
  89651. ind: number;
  89652. /**
  89653. * Length of the particle shape in the "indices" array
  89654. */
  89655. indicesLength: number;
  89656. /**
  89657. * Squared distance from the particle to the camera
  89658. */
  89659. sqDistance: number;
  89660. }
  89661. }
  89662. declare module BABYLON {
  89663. /**
  89664. * @hidden
  89665. */
  89666. export class _MeshCollisionData {
  89667. _checkCollisions: boolean;
  89668. _collisionMask: number;
  89669. _collisionGroup: number;
  89670. _collider: Nullable<Collider>;
  89671. _oldPositionForCollisions: Vector3;
  89672. _diffPositionForCollisions: Vector3;
  89673. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89674. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89675. }
  89676. }
  89677. declare module BABYLON {
  89678. /** @hidden */
  89679. class _FacetDataStorage {
  89680. facetPositions: Vector3[];
  89681. facetNormals: Vector3[];
  89682. facetPartitioning: number[][];
  89683. facetNb: number;
  89684. partitioningSubdivisions: number;
  89685. partitioningBBoxRatio: number;
  89686. facetDataEnabled: boolean;
  89687. facetParameters: any;
  89688. bbSize: Vector3;
  89689. subDiv: {
  89690. max: number;
  89691. X: number;
  89692. Y: number;
  89693. Z: number;
  89694. };
  89695. facetDepthSort: boolean;
  89696. facetDepthSortEnabled: boolean;
  89697. depthSortedIndices: IndicesArray;
  89698. depthSortedFacets: {
  89699. ind: number;
  89700. sqDistance: number;
  89701. }[];
  89702. facetDepthSortFunction: (f1: {
  89703. ind: number;
  89704. sqDistance: number;
  89705. }, f2: {
  89706. ind: number;
  89707. sqDistance: number;
  89708. }) => number;
  89709. facetDepthSortFrom: Vector3;
  89710. facetDepthSortOrigin: Vector3;
  89711. invertedMatrix: Matrix;
  89712. }
  89713. /**
  89714. * @hidden
  89715. **/
  89716. class _InternalAbstractMeshDataInfo {
  89717. _hasVertexAlpha: boolean;
  89718. _useVertexColors: boolean;
  89719. _numBoneInfluencers: number;
  89720. _applyFog: boolean;
  89721. _receiveShadows: boolean;
  89722. _facetData: _FacetDataStorage;
  89723. _visibility: number;
  89724. _skeleton: Nullable<Skeleton>;
  89725. _layerMask: number;
  89726. _computeBonesUsingShaders: boolean;
  89727. _isActive: boolean;
  89728. _onlyForInstances: boolean;
  89729. _isActiveIntermediate: boolean;
  89730. _onlyForInstancesIntermediate: boolean;
  89731. }
  89732. /**
  89733. * Class used to store all common mesh properties
  89734. */
  89735. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89736. /** No occlusion */
  89737. static OCCLUSION_TYPE_NONE: number;
  89738. /** Occlusion set to optimisitic */
  89739. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89740. /** Occlusion set to strict */
  89741. static OCCLUSION_TYPE_STRICT: number;
  89742. /** Use an accurante occlusion algorithm */
  89743. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89744. /** Use a conservative occlusion algorithm */
  89745. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89746. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89747. * Test order :
  89748. * Is the bounding sphere outside the frustum ?
  89749. * If not, are the bounding box vertices outside the frustum ?
  89750. * It not, then the cullable object is in the frustum.
  89751. */
  89752. static readonly CULLINGSTRATEGY_STANDARD: number;
  89753. /** Culling strategy : Bounding Sphere Only.
  89754. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89755. * It's also less accurate than the standard because some not visible objects can still be selected.
  89756. * Test : is the bounding sphere outside the frustum ?
  89757. * If not, then the cullable object is in the frustum.
  89758. */
  89759. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89760. /** Culling strategy : Optimistic Inclusion.
  89761. * This in an inclusion test first, then the standard exclusion test.
  89762. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89763. * 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.
  89764. * Anyway, it's as accurate as the standard strategy.
  89765. * Test :
  89766. * Is the cullable object bounding sphere center in the frustum ?
  89767. * If not, apply the default culling strategy.
  89768. */
  89769. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89770. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89771. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89772. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89773. * 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.
  89774. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89775. * Test :
  89776. * Is the cullable object bounding sphere center in the frustum ?
  89777. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89778. */
  89779. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89780. /**
  89781. * No billboard
  89782. */
  89783. static readonly BILLBOARDMODE_NONE: number;
  89784. /** Billboard on X axis */
  89785. static readonly BILLBOARDMODE_X: number;
  89786. /** Billboard on Y axis */
  89787. static readonly BILLBOARDMODE_Y: number;
  89788. /** Billboard on Z axis */
  89789. static readonly BILLBOARDMODE_Z: number;
  89790. /** Billboard on all axes */
  89791. static readonly BILLBOARDMODE_ALL: number;
  89792. /** @hidden */
  89793. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89794. /**
  89795. * The culling strategy to use to check whether the mesh must be rendered or not.
  89796. * This value can be changed at any time and will be used on the next render mesh selection.
  89797. * The possible values are :
  89798. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89799. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89800. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89801. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89802. * Please read each static variable documentation to get details about the culling process.
  89803. * */
  89804. cullingStrategy: number;
  89805. /**
  89806. * Gets the number of facets in the mesh
  89807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89808. */
  89809. readonly facetNb: number;
  89810. /**
  89811. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89813. */
  89814. partitioningSubdivisions: number;
  89815. /**
  89816. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89817. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89819. */
  89820. partitioningBBoxRatio: number;
  89821. /**
  89822. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89823. * Works only for updatable meshes.
  89824. * Doesn't work with multi-materials
  89825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89826. */
  89827. mustDepthSortFacets: boolean;
  89828. /**
  89829. * The location (Vector3) where the facet depth sort must be computed from.
  89830. * By default, the active camera position.
  89831. * Used only when facet depth sort is enabled
  89832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89833. */
  89834. facetDepthSortFrom: Vector3;
  89835. /**
  89836. * gets a boolean indicating if facetData is enabled
  89837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89838. */
  89839. readonly isFacetDataEnabled: boolean;
  89840. /** @hidden */
  89841. _updateNonUniformScalingState(value: boolean): boolean;
  89842. /**
  89843. * An event triggered when this mesh collides with another one
  89844. */
  89845. onCollideObservable: Observable<AbstractMesh>;
  89846. /** Set a function to call when this mesh collides with another one */
  89847. onCollide: () => void;
  89848. /**
  89849. * An event triggered when the collision's position changes
  89850. */
  89851. onCollisionPositionChangeObservable: Observable<Vector3>;
  89852. /** Set a function to call when the collision's position changes */
  89853. onCollisionPositionChange: () => void;
  89854. /**
  89855. * An event triggered when material is changed
  89856. */
  89857. onMaterialChangedObservable: Observable<AbstractMesh>;
  89858. /**
  89859. * Gets or sets the orientation for POV movement & rotation
  89860. */
  89861. definedFacingForward: boolean;
  89862. /** @hidden */
  89863. _occlusionQuery: Nullable<WebGLQuery>;
  89864. /** @hidden */
  89865. _renderingGroup: Nullable<RenderingGroup>;
  89866. /**
  89867. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89868. */
  89869. /**
  89870. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89871. */
  89872. visibility: number;
  89873. /** Gets or sets the alpha index used to sort transparent meshes
  89874. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89875. */
  89876. alphaIndex: number;
  89877. /**
  89878. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89879. */
  89880. isVisible: boolean;
  89881. /**
  89882. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89883. */
  89884. isPickable: boolean;
  89885. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89886. showSubMeshesBoundingBox: boolean;
  89887. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89888. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89889. */
  89890. isBlocker: boolean;
  89891. /**
  89892. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89893. */
  89894. enablePointerMoveEvents: boolean;
  89895. /**
  89896. * Specifies the rendering group id for this mesh (0 by default)
  89897. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89898. */
  89899. renderingGroupId: number;
  89900. private _material;
  89901. /** Gets or sets current material */
  89902. material: Nullable<Material>;
  89903. /**
  89904. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89905. * @see http://doc.babylonjs.com/babylon101/shadows
  89906. */
  89907. receiveShadows: boolean;
  89908. /** Defines color to use when rendering outline */
  89909. outlineColor: Color3;
  89910. /** Define width to use when rendering outline */
  89911. outlineWidth: number;
  89912. /** Defines color to use when rendering overlay */
  89913. overlayColor: Color3;
  89914. /** Defines alpha to use when rendering overlay */
  89915. overlayAlpha: number;
  89916. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89917. hasVertexAlpha: boolean;
  89918. /** 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) */
  89919. useVertexColors: boolean;
  89920. /**
  89921. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89922. */
  89923. computeBonesUsingShaders: boolean;
  89924. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89925. numBoneInfluencers: number;
  89926. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89927. applyFog: boolean;
  89928. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89929. useOctreeForRenderingSelection: boolean;
  89930. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89931. useOctreeForPicking: boolean;
  89932. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89933. useOctreeForCollisions: boolean;
  89934. /**
  89935. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89936. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89937. */
  89938. layerMask: number;
  89939. /**
  89940. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89941. */
  89942. alwaysSelectAsActiveMesh: boolean;
  89943. /**
  89944. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89945. */
  89946. doNotSyncBoundingInfo: boolean;
  89947. /**
  89948. * Gets or sets the current action manager
  89949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89950. */
  89951. actionManager: Nullable<AbstractActionManager>;
  89952. private _meshCollisionData;
  89953. /**
  89954. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89955. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89956. */
  89957. ellipsoid: Vector3;
  89958. /**
  89959. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89961. */
  89962. ellipsoidOffset: Vector3;
  89963. /**
  89964. * Gets or sets a collision mask used to mask collisions (default is -1).
  89965. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89966. */
  89967. collisionMask: number;
  89968. /**
  89969. * Gets or sets the current collision group mask (-1 by default).
  89970. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89971. */
  89972. collisionGroup: number;
  89973. /**
  89974. * Defines edge width used when edgesRenderer is enabled
  89975. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89976. */
  89977. edgesWidth: number;
  89978. /**
  89979. * Defines edge color used when edgesRenderer is enabled
  89980. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89981. */
  89982. edgesColor: Color4;
  89983. /** @hidden */
  89984. _edgesRenderer: Nullable<IEdgesRenderer>;
  89985. /** @hidden */
  89986. _masterMesh: Nullable<AbstractMesh>;
  89987. /** @hidden */
  89988. _boundingInfo: Nullable<BoundingInfo>;
  89989. /** @hidden */
  89990. _renderId: number;
  89991. /**
  89992. * Gets or sets the list of subMeshes
  89993. * @see http://doc.babylonjs.com/how_to/multi_materials
  89994. */
  89995. subMeshes: SubMesh[];
  89996. /** @hidden */
  89997. _intersectionsInProgress: AbstractMesh[];
  89998. /** @hidden */
  89999. _unIndexed: boolean;
  90000. /** @hidden */
  90001. _lightSources: Light[];
  90002. /** Gets the list of lights affecting that mesh */
  90003. readonly lightSources: Light[];
  90004. /** @hidden */
  90005. readonly _positions: Nullable<Vector3[]>;
  90006. /** @hidden */
  90007. _waitingData: {
  90008. lods: Nullable<any>;
  90009. actions: Nullable<any>;
  90010. freezeWorldMatrix: Nullable<boolean>;
  90011. };
  90012. /** @hidden */
  90013. _bonesTransformMatrices: Nullable<Float32Array>;
  90014. /** @hidden */
  90015. _transformMatrixTexture: Nullable<RawTexture>;
  90016. /**
  90017. * Gets or sets a skeleton to apply skining transformations
  90018. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90019. */
  90020. skeleton: Nullable<Skeleton>;
  90021. /**
  90022. * An event triggered when the mesh is rebuilt.
  90023. */
  90024. onRebuildObservable: Observable<AbstractMesh>;
  90025. /**
  90026. * Creates a new AbstractMesh
  90027. * @param name defines the name of the mesh
  90028. * @param scene defines the hosting scene
  90029. */
  90030. constructor(name: string, scene?: Nullable<Scene>);
  90031. /**
  90032. * Returns the string "AbstractMesh"
  90033. * @returns "AbstractMesh"
  90034. */
  90035. getClassName(): string;
  90036. /**
  90037. * Gets a string representation of the current mesh
  90038. * @param fullDetails defines a boolean indicating if full details must be included
  90039. * @returns a string representation of the current mesh
  90040. */
  90041. toString(fullDetails?: boolean): string;
  90042. /**
  90043. * @hidden
  90044. */
  90045. protected _getEffectiveParent(): Nullable<Node>;
  90046. /** @hidden */
  90047. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90048. /** @hidden */
  90049. _rebuild(): void;
  90050. /** @hidden */
  90051. _resyncLightSources(): void;
  90052. /** @hidden */
  90053. _resyncLighSource(light: Light): void;
  90054. /** @hidden */
  90055. _unBindEffect(): void;
  90056. /** @hidden */
  90057. _removeLightSource(light: Light): void;
  90058. private _markSubMeshesAsDirty;
  90059. /** @hidden */
  90060. _markSubMeshesAsLightDirty(): void;
  90061. /** @hidden */
  90062. _markSubMeshesAsAttributesDirty(): void;
  90063. /** @hidden */
  90064. _markSubMeshesAsMiscDirty(): void;
  90065. /**
  90066. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90067. */
  90068. scaling: Vector3;
  90069. /**
  90070. * Returns true if the mesh is blocked. Implemented by child classes
  90071. */
  90072. readonly isBlocked: boolean;
  90073. /**
  90074. * Returns the mesh itself by default. Implemented by child classes
  90075. * @param camera defines the camera to use to pick the right LOD level
  90076. * @returns the currentAbstractMesh
  90077. */
  90078. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90079. /**
  90080. * Returns 0 by default. Implemented by child classes
  90081. * @returns an integer
  90082. */
  90083. getTotalVertices(): number;
  90084. /**
  90085. * Returns a positive integer : the total number of indices in this mesh geometry.
  90086. * @returns the numner of indices or zero if the mesh has no geometry.
  90087. */
  90088. getTotalIndices(): number;
  90089. /**
  90090. * Returns null by default. Implemented by child classes
  90091. * @returns null
  90092. */
  90093. getIndices(): Nullable<IndicesArray>;
  90094. /**
  90095. * Returns the array of the requested vertex data kind. Implemented by child classes
  90096. * @param kind defines the vertex data kind to use
  90097. * @returns null
  90098. */
  90099. getVerticesData(kind: string): Nullable<FloatArray>;
  90100. /**
  90101. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90102. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90103. * Note that a new underlying VertexBuffer object is created each call.
  90104. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90105. * @param kind defines vertex data kind:
  90106. * * VertexBuffer.PositionKind
  90107. * * VertexBuffer.UVKind
  90108. * * VertexBuffer.UV2Kind
  90109. * * VertexBuffer.UV3Kind
  90110. * * VertexBuffer.UV4Kind
  90111. * * VertexBuffer.UV5Kind
  90112. * * VertexBuffer.UV6Kind
  90113. * * VertexBuffer.ColorKind
  90114. * * VertexBuffer.MatricesIndicesKind
  90115. * * VertexBuffer.MatricesIndicesExtraKind
  90116. * * VertexBuffer.MatricesWeightsKind
  90117. * * VertexBuffer.MatricesWeightsExtraKind
  90118. * @param data defines the data source
  90119. * @param updatable defines if the data must be flagged as updatable (or static)
  90120. * @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
  90121. * @returns the current mesh
  90122. */
  90123. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90124. /**
  90125. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90126. * If the mesh has no geometry, it is simply returned as it is.
  90127. * @param kind defines vertex data kind:
  90128. * * VertexBuffer.PositionKind
  90129. * * VertexBuffer.UVKind
  90130. * * VertexBuffer.UV2Kind
  90131. * * VertexBuffer.UV3Kind
  90132. * * VertexBuffer.UV4Kind
  90133. * * VertexBuffer.UV5Kind
  90134. * * VertexBuffer.UV6Kind
  90135. * * VertexBuffer.ColorKind
  90136. * * VertexBuffer.MatricesIndicesKind
  90137. * * VertexBuffer.MatricesIndicesExtraKind
  90138. * * VertexBuffer.MatricesWeightsKind
  90139. * * VertexBuffer.MatricesWeightsExtraKind
  90140. * @param data defines the data source
  90141. * @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
  90142. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90143. * @returns the current mesh
  90144. */
  90145. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90146. /**
  90147. * Sets the mesh indices,
  90148. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90149. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90150. * @param totalVertices Defines the total number of vertices
  90151. * @returns the current mesh
  90152. */
  90153. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90154. /**
  90155. * Gets a boolean indicating if specific vertex data is present
  90156. * @param kind defines the vertex data kind to use
  90157. * @returns true is data kind is present
  90158. */
  90159. isVerticesDataPresent(kind: string): boolean;
  90160. /**
  90161. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90162. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90163. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90164. * @returns a BoundingInfo
  90165. */
  90166. getBoundingInfo(): BoundingInfo;
  90167. /**
  90168. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90169. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90170. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90171. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90172. * @returns the current mesh
  90173. */
  90174. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90175. /**
  90176. * Overwrite the current bounding info
  90177. * @param boundingInfo defines the new bounding info
  90178. * @returns the current mesh
  90179. */
  90180. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90181. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90182. readonly useBones: boolean;
  90183. /** @hidden */
  90184. _preActivate(): void;
  90185. /** @hidden */
  90186. _preActivateForIntermediateRendering(renderId: number): void;
  90187. /** @hidden */
  90188. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90189. /** @hidden */
  90190. _postActivate(): void;
  90191. /** @hidden */
  90192. _freeze(): void;
  90193. /** @hidden */
  90194. _unFreeze(): void;
  90195. /**
  90196. * Gets the current world matrix
  90197. * @returns a Matrix
  90198. */
  90199. getWorldMatrix(): Matrix;
  90200. /** @hidden */
  90201. _getWorldMatrixDeterminant(): number;
  90202. /**
  90203. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90204. */
  90205. readonly isAnInstance: boolean;
  90206. /**
  90207. * Perform relative position change from the point of view of behind the front of the mesh.
  90208. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90209. * Supports definition of mesh facing forward or backward
  90210. * @param amountRight defines the distance on the right axis
  90211. * @param amountUp defines the distance on the up axis
  90212. * @param amountForward defines the distance on the forward axis
  90213. * @returns the current mesh
  90214. */
  90215. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90216. /**
  90217. * Calculate relative position change from the point of view of behind the front of the mesh.
  90218. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90219. * Supports definition of mesh facing forward or backward
  90220. * @param amountRight defines the distance on the right axis
  90221. * @param amountUp defines the distance on the up axis
  90222. * @param amountForward defines the distance on the forward axis
  90223. * @returns the new displacement vector
  90224. */
  90225. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90226. /**
  90227. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90228. * Supports definition of mesh facing forward or backward
  90229. * @param flipBack defines the flip
  90230. * @param twirlClockwise defines the twirl
  90231. * @param tiltRight defines the tilt
  90232. * @returns the current mesh
  90233. */
  90234. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90235. /**
  90236. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90237. * Supports definition of mesh facing forward or backward.
  90238. * @param flipBack defines the flip
  90239. * @param twirlClockwise defines the twirl
  90240. * @param tiltRight defines the tilt
  90241. * @returns the new rotation vector
  90242. */
  90243. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90244. /**
  90245. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90246. * This means the mesh underlying bounding box and sphere are recomputed.
  90247. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90248. * @returns the current mesh
  90249. */
  90250. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90251. /** @hidden */
  90252. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90253. /** @hidden */
  90254. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90255. /** @hidden */
  90256. _updateBoundingInfo(): AbstractMesh;
  90257. /** @hidden */
  90258. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90259. /** @hidden */
  90260. protected _afterComputeWorldMatrix(): void;
  90261. /** @hidden */
  90262. readonly _effectiveMesh: AbstractMesh;
  90263. /**
  90264. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90265. * A mesh is in the frustum if its bounding box intersects the frustum
  90266. * @param frustumPlanes defines the frustum to test
  90267. * @returns true if the mesh is in the frustum planes
  90268. */
  90269. isInFrustum(frustumPlanes: Plane[]): boolean;
  90270. /**
  90271. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90272. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90273. * @param frustumPlanes defines the frustum to test
  90274. * @returns true if the mesh is completely in the frustum planes
  90275. */
  90276. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90277. /**
  90278. * True if the mesh intersects another mesh or a SolidParticle object
  90279. * @param mesh defines a target mesh or SolidParticle to test
  90280. * @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)
  90281. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90282. * @returns true if there is an intersection
  90283. */
  90284. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90285. /**
  90286. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90287. * @param point defines the point to test
  90288. * @returns true if there is an intersection
  90289. */
  90290. intersectsPoint(point: Vector3): boolean;
  90291. /**
  90292. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90294. */
  90295. checkCollisions: boolean;
  90296. /**
  90297. * Gets Collider object used to compute collisions (not physics)
  90298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90299. */
  90300. readonly collider: Nullable<Collider>;
  90301. /**
  90302. * Move the mesh using collision engine
  90303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90304. * @param displacement defines the requested displacement vector
  90305. * @returns the current mesh
  90306. */
  90307. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90308. private _onCollisionPositionChange;
  90309. /** @hidden */
  90310. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90311. /** @hidden */
  90312. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90313. /** @hidden */
  90314. _checkCollision(collider: Collider): AbstractMesh;
  90315. /** @hidden */
  90316. _generatePointsArray(): boolean;
  90317. /**
  90318. * Checks if the passed Ray intersects with the mesh
  90319. * @param ray defines the ray to use
  90320. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90321. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90322. * @returns the picking info
  90323. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90324. */
  90325. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90326. /**
  90327. * Clones the current mesh
  90328. * @param name defines the mesh name
  90329. * @param newParent defines the new mesh parent
  90330. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90331. * @returns the new mesh
  90332. */
  90333. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90334. /**
  90335. * Disposes all the submeshes of the current meshnp
  90336. * @returns the current mesh
  90337. */
  90338. releaseSubMeshes(): AbstractMesh;
  90339. /**
  90340. * Releases resources associated with this abstract mesh.
  90341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90343. */
  90344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90345. /**
  90346. * Adds the passed mesh as a child to the current mesh
  90347. * @param mesh defines the child mesh
  90348. * @returns the current mesh
  90349. */
  90350. addChild(mesh: AbstractMesh): AbstractMesh;
  90351. /**
  90352. * Removes the passed mesh from the current mesh children list
  90353. * @param mesh defines the child mesh
  90354. * @returns the current mesh
  90355. */
  90356. removeChild(mesh: AbstractMesh): AbstractMesh;
  90357. /** @hidden */
  90358. private _initFacetData;
  90359. /**
  90360. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90361. * This method can be called within the render loop.
  90362. * 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
  90363. * @returns the current mesh
  90364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90365. */
  90366. updateFacetData(): AbstractMesh;
  90367. /**
  90368. * Returns the facetLocalNormals array.
  90369. * The normals are expressed in the mesh local spac
  90370. * @returns an array of Vector3
  90371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90372. */
  90373. getFacetLocalNormals(): Vector3[];
  90374. /**
  90375. * Returns the facetLocalPositions array.
  90376. * The facet positions are expressed in the mesh local space
  90377. * @returns an array of Vector3
  90378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90379. */
  90380. getFacetLocalPositions(): Vector3[];
  90381. /**
  90382. * Returns the facetLocalPartioning array
  90383. * @returns an array of array of numbers
  90384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90385. */
  90386. getFacetLocalPartitioning(): number[][];
  90387. /**
  90388. * Returns the i-th facet position in the world system.
  90389. * This method allocates a new Vector3 per call
  90390. * @param i defines the facet index
  90391. * @returns a new Vector3
  90392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90393. */
  90394. getFacetPosition(i: number): Vector3;
  90395. /**
  90396. * Sets the reference Vector3 with the i-th facet position in the world system
  90397. * @param i defines the facet index
  90398. * @param ref defines the target vector
  90399. * @returns the current mesh
  90400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90401. */
  90402. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90403. /**
  90404. * Returns the i-th facet normal in the world system.
  90405. * This method allocates a new Vector3 per call
  90406. * @param i defines the facet index
  90407. * @returns a new Vector3
  90408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90409. */
  90410. getFacetNormal(i: number): Vector3;
  90411. /**
  90412. * Sets the reference Vector3 with the i-th facet normal in the world system
  90413. * @param i defines the facet index
  90414. * @param ref defines the target vector
  90415. * @returns the current mesh
  90416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90417. */
  90418. getFacetNormalToRef(i: number, ref: Vector3): this;
  90419. /**
  90420. * 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)
  90421. * @param x defines x coordinate
  90422. * @param y defines y coordinate
  90423. * @param z defines z coordinate
  90424. * @returns the array of facet indexes
  90425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90426. */
  90427. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90428. /**
  90429. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90430. * @param projected sets as the (x,y,z) world projection on the facet
  90431. * @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
  90432. * @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
  90433. * @param x defines x coordinate
  90434. * @param y defines y coordinate
  90435. * @param z defines z coordinate
  90436. * @returns the face index if found (or null instead)
  90437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90438. */
  90439. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90440. /**
  90441. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90442. * @param projected sets as the (x,y,z) local projection on the facet
  90443. * @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
  90444. * @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
  90445. * @param x defines x coordinate
  90446. * @param y defines y coordinate
  90447. * @param z defines z coordinate
  90448. * @returns the face index if found (or null instead)
  90449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90450. */
  90451. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90452. /**
  90453. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90454. * @returns the parameters
  90455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90456. */
  90457. getFacetDataParameters(): any;
  90458. /**
  90459. * Disables the feature FacetData and frees the related memory
  90460. * @returns the current mesh
  90461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90462. */
  90463. disableFacetData(): AbstractMesh;
  90464. /**
  90465. * Updates the AbstractMesh indices array
  90466. * @param indices defines the data source
  90467. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90468. * @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)
  90469. * @returns the current mesh
  90470. */
  90471. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90472. /**
  90473. * Creates new normals data for the mesh
  90474. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90475. * @returns the current mesh
  90476. */
  90477. createNormals(updatable: boolean): AbstractMesh;
  90478. /**
  90479. * Align the mesh with a normal
  90480. * @param normal defines the normal to use
  90481. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90482. * @returns the current mesh
  90483. */
  90484. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90485. /** @hidden */
  90486. _checkOcclusionQuery(): boolean;
  90487. /**
  90488. * Disables the mesh edge rendering mode
  90489. * @returns the currentAbstractMesh
  90490. */
  90491. disableEdgesRendering(): AbstractMesh;
  90492. /**
  90493. * Enables the edge rendering mode on the mesh.
  90494. * This mode makes the mesh edges visible
  90495. * @param epsilon defines the maximal distance between two angles to detect a face
  90496. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90497. * @returns the currentAbstractMesh
  90498. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90499. */
  90500. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90501. }
  90502. }
  90503. declare module BABYLON {
  90504. /**
  90505. * Interface used to define ActionEvent
  90506. */
  90507. export interface IActionEvent {
  90508. /** The mesh or sprite that triggered the action */
  90509. source: any;
  90510. /** The X mouse cursor position at the time of the event */
  90511. pointerX: number;
  90512. /** The Y mouse cursor position at the time of the event */
  90513. pointerY: number;
  90514. /** The mesh that is currently pointed at (can be null) */
  90515. meshUnderPointer: Nullable<AbstractMesh>;
  90516. /** the original (browser) event that triggered the ActionEvent */
  90517. sourceEvent?: any;
  90518. /** additional data for the event */
  90519. additionalData?: any;
  90520. }
  90521. /**
  90522. * ActionEvent is the event being sent when an action is triggered.
  90523. */
  90524. export class ActionEvent implements IActionEvent {
  90525. /** The mesh or sprite that triggered the action */
  90526. source: any;
  90527. /** The X mouse cursor position at the time of the event */
  90528. pointerX: number;
  90529. /** The Y mouse cursor position at the time of the event */
  90530. pointerY: number;
  90531. /** The mesh that is currently pointed at (can be null) */
  90532. meshUnderPointer: Nullable<AbstractMesh>;
  90533. /** the original (browser) event that triggered the ActionEvent */
  90534. sourceEvent?: any;
  90535. /** additional data for the event */
  90536. additionalData?: any;
  90537. /**
  90538. * Creates a new ActionEvent
  90539. * @param source The mesh or sprite that triggered the action
  90540. * @param pointerX The X mouse cursor position at the time of the event
  90541. * @param pointerY The Y mouse cursor position at the time of the event
  90542. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90543. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90544. * @param additionalData additional data for the event
  90545. */
  90546. constructor(
  90547. /** The mesh or sprite that triggered the action */
  90548. source: any,
  90549. /** The X mouse cursor position at the time of the event */
  90550. pointerX: number,
  90551. /** The Y mouse cursor position at the time of the event */
  90552. pointerY: number,
  90553. /** The mesh that is currently pointed at (can be null) */
  90554. meshUnderPointer: Nullable<AbstractMesh>,
  90555. /** the original (browser) event that triggered the ActionEvent */
  90556. sourceEvent?: any,
  90557. /** additional data for the event */
  90558. additionalData?: any);
  90559. /**
  90560. * Helper function to auto-create an ActionEvent from a source mesh.
  90561. * @param source The source mesh that triggered the event
  90562. * @param evt The original (browser) event
  90563. * @param additionalData additional data for the event
  90564. * @returns the new ActionEvent
  90565. */
  90566. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90567. /**
  90568. * Helper function to auto-create an ActionEvent from a source sprite
  90569. * @param source The source sprite that triggered the event
  90570. * @param scene Scene associated with the sprite
  90571. * @param evt The original (browser) event
  90572. * @param additionalData additional data for the event
  90573. * @returns the new ActionEvent
  90574. */
  90575. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90576. /**
  90577. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90578. * @param scene the scene where the event occurred
  90579. * @param evt The original (browser) event
  90580. * @returns the new ActionEvent
  90581. */
  90582. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90583. /**
  90584. * Helper function to auto-create an ActionEvent from a primitive
  90585. * @param prim defines the target primitive
  90586. * @param pointerPos defines the pointer position
  90587. * @param evt The original (browser) event
  90588. * @param additionalData additional data for the event
  90589. * @returns the new ActionEvent
  90590. */
  90591. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90592. }
  90593. }
  90594. declare module BABYLON {
  90595. /**
  90596. * Abstract class used to decouple action Manager from scene and meshes.
  90597. * Do not instantiate.
  90598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90599. */
  90600. export abstract class AbstractActionManager implements IDisposable {
  90601. /** Gets the list of active triggers */
  90602. static Triggers: {
  90603. [key: string]: number;
  90604. };
  90605. /** Gets the cursor to use when hovering items */
  90606. hoverCursor: string;
  90607. /** Gets the list of actions */
  90608. actions: IAction[];
  90609. /**
  90610. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90611. */
  90612. isRecursive: boolean;
  90613. /**
  90614. * Releases all associated resources
  90615. */
  90616. abstract dispose(): void;
  90617. /**
  90618. * Does this action manager has pointer triggers
  90619. */
  90620. abstract readonly hasPointerTriggers: boolean;
  90621. /**
  90622. * Does this action manager has pick triggers
  90623. */
  90624. abstract readonly hasPickTriggers: boolean;
  90625. /**
  90626. * Process a specific trigger
  90627. * @param trigger defines the trigger to process
  90628. * @param evt defines the event details to be processed
  90629. */
  90630. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90631. /**
  90632. * Does this action manager handles actions of any of the given triggers
  90633. * @param triggers defines the triggers to be tested
  90634. * @return a boolean indicating whether one (or more) of the triggers is handled
  90635. */
  90636. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90637. /**
  90638. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90639. * speed.
  90640. * @param triggerA defines the trigger to be tested
  90641. * @param triggerB defines the trigger to be tested
  90642. * @return a boolean indicating whether one (or more) of the triggers is handled
  90643. */
  90644. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90645. /**
  90646. * Does this action manager handles actions of a given trigger
  90647. * @param trigger defines the trigger to be tested
  90648. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90649. * @return whether the trigger is handled
  90650. */
  90651. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90652. /**
  90653. * Serialize this manager to a JSON object
  90654. * @param name defines the property name to store this manager
  90655. * @returns a JSON representation of this manager
  90656. */
  90657. abstract serialize(name: string): any;
  90658. /**
  90659. * Registers an action to this action manager
  90660. * @param action defines the action to be registered
  90661. * @return the action amended (prepared) after registration
  90662. */
  90663. abstract registerAction(action: IAction): Nullable<IAction>;
  90664. /**
  90665. * Unregisters an action to this action manager
  90666. * @param action defines the action to be unregistered
  90667. * @return a boolean indicating whether the action has been unregistered
  90668. */
  90669. abstract unregisterAction(action: IAction): Boolean;
  90670. /**
  90671. * Does exist one action manager with at least one trigger
  90672. **/
  90673. static readonly HasTriggers: boolean;
  90674. /**
  90675. * Does exist one action manager with at least one pick trigger
  90676. **/
  90677. static readonly HasPickTriggers: boolean;
  90678. /**
  90679. * Does exist one action manager that handles actions of a given trigger
  90680. * @param trigger defines the trigger to be tested
  90681. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90682. **/
  90683. static HasSpecificTrigger(trigger: number): boolean;
  90684. }
  90685. }
  90686. declare module BABYLON {
  90687. /**
  90688. * Defines how a node can be built from a string name.
  90689. */
  90690. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90691. /**
  90692. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90693. */
  90694. export class Node implements IBehaviorAware<Node> {
  90695. /** @hidden */
  90696. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90697. private static _NodeConstructors;
  90698. /**
  90699. * Add a new node constructor
  90700. * @param type defines the type name of the node to construct
  90701. * @param constructorFunc defines the constructor function
  90702. */
  90703. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90704. /**
  90705. * Returns a node constructor based on type name
  90706. * @param type defines the type name
  90707. * @param name defines the new node name
  90708. * @param scene defines the hosting scene
  90709. * @param options defines optional options to transmit to constructors
  90710. * @returns the new constructor or null
  90711. */
  90712. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90713. /**
  90714. * Gets or sets the name of the node
  90715. */
  90716. name: string;
  90717. /**
  90718. * Gets or sets the id of the node
  90719. */
  90720. id: string;
  90721. /**
  90722. * Gets or sets the unique id of the node
  90723. */
  90724. uniqueId: number;
  90725. /**
  90726. * Gets or sets a string used to store user defined state for the node
  90727. */
  90728. state: string;
  90729. /**
  90730. * Gets or sets an object used to store user defined information for the node
  90731. */
  90732. metadata: any;
  90733. /**
  90734. * For internal use only. Please do not use.
  90735. */
  90736. reservedDataStore: any;
  90737. /**
  90738. * List of inspectable custom properties (used by the Inspector)
  90739. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90740. */
  90741. inspectableCustomProperties: IInspectable[];
  90742. /**
  90743. * Gets or sets a boolean used to define if the node must be serialized
  90744. */
  90745. doNotSerialize: boolean;
  90746. /** @hidden */
  90747. _isDisposed: boolean;
  90748. /**
  90749. * Gets a list of Animations associated with the node
  90750. */
  90751. animations: Animation[];
  90752. protected _ranges: {
  90753. [name: string]: Nullable<AnimationRange>;
  90754. };
  90755. /**
  90756. * Callback raised when the node is ready to be used
  90757. */
  90758. onReady: Nullable<(node: Node) => void>;
  90759. private _isEnabled;
  90760. private _isParentEnabled;
  90761. private _isReady;
  90762. /** @hidden */
  90763. _currentRenderId: number;
  90764. private _parentUpdateId;
  90765. /** @hidden */
  90766. _childUpdateId: number;
  90767. /** @hidden */
  90768. _waitingParentId: Nullable<string>;
  90769. /** @hidden */
  90770. _scene: Scene;
  90771. /** @hidden */
  90772. _cache: any;
  90773. private _parentNode;
  90774. private _children;
  90775. /** @hidden */
  90776. _worldMatrix: Matrix;
  90777. /** @hidden */
  90778. _worldMatrixDeterminant: number;
  90779. /** @hidden */
  90780. _worldMatrixDeterminantIsDirty: boolean;
  90781. /** @hidden */
  90782. private _sceneRootNodesIndex;
  90783. /**
  90784. * Gets a boolean indicating if the node has been disposed
  90785. * @returns true if the node was disposed
  90786. */
  90787. isDisposed(): boolean;
  90788. /**
  90789. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90790. * @see https://doc.babylonjs.com/how_to/parenting
  90791. */
  90792. parent: Nullable<Node>;
  90793. private addToSceneRootNodes;
  90794. private removeFromSceneRootNodes;
  90795. private _animationPropertiesOverride;
  90796. /**
  90797. * Gets or sets the animation properties override
  90798. */
  90799. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90800. /**
  90801. * Gets a string idenfifying the name of the class
  90802. * @returns "Node" string
  90803. */
  90804. getClassName(): string;
  90805. /** @hidden */
  90806. readonly _isNode: boolean;
  90807. /**
  90808. * An event triggered when the mesh is disposed
  90809. */
  90810. onDisposeObservable: Observable<Node>;
  90811. private _onDisposeObserver;
  90812. /**
  90813. * Sets a callback that will be raised when the node will be disposed
  90814. */
  90815. onDispose: () => void;
  90816. /**
  90817. * Creates a new Node
  90818. * @param name the name and id to be given to this node
  90819. * @param scene the scene this node will be added to
  90820. * @param addToRootNodes the node will be added to scene.rootNodes
  90821. */
  90822. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90823. /**
  90824. * Gets the scene of the node
  90825. * @returns a scene
  90826. */
  90827. getScene(): Scene;
  90828. /**
  90829. * Gets the engine of the node
  90830. * @returns a Engine
  90831. */
  90832. getEngine(): Engine;
  90833. private _behaviors;
  90834. /**
  90835. * Attach a behavior to the node
  90836. * @see http://doc.babylonjs.com/features/behaviour
  90837. * @param behavior defines the behavior to attach
  90838. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90839. * @returns the current Node
  90840. */
  90841. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90842. /**
  90843. * Remove an attached behavior
  90844. * @see http://doc.babylonjs.com/features/behaviour
  90845. * @param behavior defines the behavior to attach
  90846. * @returns the current Node
  90847. */
  90848. removeBehavior(behavior: Behavior<Node>): Node;
  90849. /**
  90850. * Gets the list of attached behaviors
  90851. * @see http://doc.babylonjs.com/features/behaviour
  90852. */
  90853. readonly behaviors: Behavior<Node>[];
  90854. /**
  90855. * Gets an attached behavior by name
  90856. * @param name defines the name of the behavior to look for
  90857. * @see http://doc.babylonjs.com/features/behaviour
  90858. * @returns null if behavior was not found else the requested behavior
  90859. */
  90860. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90861. /**
  90862. * Returns the latest update of the World matrix
  90863. * @returns a Matrix
  90864. */
  90865. getWorldMatrix(): Matrix;
  90866. /** @hidden */
  90867. _getWorldMatrixDeterminant(): number;
  90868. /**
  90869. * Returns directly the latest state of the mesh World matrix.
  90870. * A Matrix is returned.
  90871. */
  90872. readonly worldMatrixFromCache: Matrix;
  90873. /** @hidden */
  90874. _initCache(): void;
  90875. /** @hidden */
  90876. updateCache(force?: boolean): void;
  90877. /** @hidden */
  90878. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90879. /** @hidden */
  90880. _updateCache(ignoreParentClass?: boolean): void;
  90881. /** @hidden */
  90882. _isSynchronized(): boolean;
  90883. /** @hidden */
  90884. _markSyncedWithParent(): void;
  90885. /** @hidden */
  90886. isSynchronizedWithParent(): boolean;
  90887. /** @hidden */
  90888. isSynchronized(): boolean;
  90889. /**
  90890. * Is this node ready to be used/rendered
  90891. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90892. * @return true if the node is ready
  90893. */
  90894. isReady(completeCheck?: boolean): boolean;
  90895. /**
  90896. * Is this node enabled?
  90897. * 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
  90898. * @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
  90899. * @return whether this node (and its parent) is enabled
  90900. */
  90901. isEnabled(checkAncestors?: boolean): boolean;
  90902. /** @hidden */
  90903. protected _syncParentEnabledState(): void;
  90904. /**
  90905. * Set the enabled state of this node
  90906. * @param value defines the new enabled state
  90907. */
  90908. setEnabled(value: boolean): void;
  90909. /**
  90910. * Is this node a descendant of the given node?
  90911. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90912. * @param ancestor defines the parent node to inspect
  90913. * @returns a boolean indicating if this node is a descendant of the given node
  90914. */
  90915. isDescendantOf(ancestor: Node): boolean;
  90916. /** @hidden */
  90917. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90918. /**
  90919. * Will return all nodes that have this node as ascendant
  90920. * @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
  90921. * @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
  90922. * @return all children nodes of all types
  90923. */
  90924. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90925. /**
  90926. * Get all child-meshes of this node
  90927. * @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)
  90928. * @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
  90929. * @returns an array of AbstractMesh
  90930. */
  90931. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90932. /**
  90933. * Get all direct children of this node
  90934. * @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
  90935. * @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)
  90936. * @returns an array of Node
  90937. */
  90938. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90939. /** @hidden */
  90940. _setReady(state: boolean): void;
  90941. /**
  90942. * Get an animation by name
  90943. * @param name defines the name of the animation to look for
  90944. * @returns null if not found else the requested animation
  90945. */
  90946. getAnimationByName(name: string): Nullable<Animation>;
  90947. /**
  90948. * Creates an animation range for this node
  90949. * @param name defines the name of the range
  90950. * @param from defines the starting key
  90951. * @param to defines the end key
  90952. */
  90953. createAnimationRange(name: string, from: number, to: number): void;
  90954. /**
  90955. * Delete a specific animation range
  90956. * @param name defines the name of the range to delete
  90957. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90958. */
  90959. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90960. /**
  90961. * Get an animation range by name
  90962. * @param name defines the name of the animation range to look for
  90963. * @returns null if not found else the requested animation range
  90964. */
  90965. getAnimationRange(name: string): Nullable<AnimationRange>;
  90966. /**
  90967. * Gets the list of all animation ranges defined on this node
  90968. * @returns an array
  90969. */
  90970. getAnimationRanges(): Nullable<AnimationRange>[];
  90971. /**
  90972. * Will start the animation sequence
  90973. * @param name defines the range frames for animation sequence
  90974. * @param loop defines if the animation should loop (false by default)
  90975. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90976. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90977. * @returns the object created for this animation. If range does not exist, it will return null
  90978. */
  90979. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90980. /**
  90981. * Serialize animation ranges into a JSON compatible object
  90982. * @returns serialization object
  90983. */
  90984. serializeAnimationRanges(): any;
  90985. /**
  90986. * Computes the world matrix of the node
  90987. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90988. * @returns the world matrix
  90989. */
  90990. computeWorldMatrix(force?: boolean): Matrix;
  90991. /**
  90992. * Releases resources associated with this node.
  90993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90995. */
  90996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90997. /**
  90998. * Parse animation range data from a serialization object and store them into a given node
  90999. * @param node defines where to store the animation ranges
  91000. * @param parsedNode defines the serialization object to read data from
  91001. * @param scene defines the hosting scene
  91002. */
  91003. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91004. /**
  91005. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91006. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91007. * @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
  91008. * @returns the new bounding vectors
  91009. */
  91010. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91011. min: Vector3;
  91012. max: Vector3;
  91013. };
  91014. }
  91015. }
  91016. declare module BABYLON {
  91017. /**
  91018. * @hidden
  91019. */
  91020. export class _IAnimationState {
  91021. key: number;
  91022. repeatCount: number;
  91023. workValue?: any;
  91024. loopMode?: number;
  91025. offsetValue?: any;
  91026. highLimitValue?: any;
  91027. }
  91028. /**
  91029. * Class used to store any kind of animation
  91030. */
  91031. export class Animation {
  91032. /**Name of the animation */
  91033. name: string;
  91034. /**Property to animate */
  91035. targetProperty: string;
  91036. /**The frames per second of the animation */
  91037. framePerSecond: number;
  91038. /**The data type of the animation */
  91039. dataType: number;
  91040. /**The loop mode of the animation */
  91041. loopMode?: number | undefined;
  91042. /**Specifies if blending should be enabled */
  91043. enableBlending?: boolean | undefined;
  91044. /**
  91045. * Use matrix interpolation instead of using direct key value when animating matrices
  91046. */
  91047. static AllowMatricesInterpolation: boolean;
  91048. /**
  91049. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91050. */
  91051. static AllowMatrixDecomposeForInterpolation: boolean;
  91052. /**
  91053. * Stores the key frames of the animation
  91054. */
  91055. private _keys;
  91056. /**
  91057. * Stores the easing function of the animation
  91058. */
  91059. private _easingFunction;
  91060. /**
  91061. * @hidden Internal use only
  91062. */
  91063. _runtimeAnimations: RuntimeAnimation[];
  91064. /**
  91065. * The set of event that will be linked to this animation
  91066. */
  91067. private _events;
  91068. /**
  91069. * Stores an array of target property paths
  91070. */
  91071. targetPropertyPath: string[];
  91072. /**
  91073. * Stores the blending speed of the animation
  91074. */
  91075. blendingSpeed: number;
  91076. /**
  91077. * Stores the animation ranges for the animation
  91078. */
  91079. private _ranges;
  91080. /**
  91081. * @hidden Internal use
  91082. */
  91083. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91084. /**
  91085. * Sets up an animation
  91086. * @param property The property to animate
  91087. * @param animationType The animation type to apply
  91088. * @param framePerSecond The frames per second of the animation
  91089. * @param easingFunction The easing function used in the animation
  91090. * @returns The created animation
  91091. */
  91092. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91093. /**
  91094. * Create and start an animation on a node
  91095. * @param name defines the name of the global animation that will be run on all nodes
  91096. * @param node defines the root node where the animation will take place
  91097. * @param targetProperty defines property to animate
  91098. * @param framePerSecond defines the number of frame per second yo use
  91099. * @param totalFrame defines the number of frames in total
  91100. * @param from defines the initial value
  91101. * @param to defines the final value
  91102. * @param loopMode defines which loop mode you want to use (off by default)
  91103. * @param easingFunction defines the easing function to use (linear by default)
  91104. * @param onAnimationEnd defines the callback to call when animation end
  91105. * @returns the animatable created for this animation
  91106. */
  91107. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91108. /**
  91109. * Create and start an animation on a node and its descendants
  91110. * @param name defines the name of the global animation that will be run on all nodes
  91111. * @param node defines the root node where the animation will take place
  91112. * @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
  91113. * @param targetProperty defines property to animate
  91114. * @param framePerSecond defines the number of frame per second to use
  91115. * @param totalFrame defines the number of frames in total
  91116. * @param from defines the initial value
  91117. * @param to defines the final value
  91118. * @param loopMode defines which loop mode you want to use (off by default)
  91119. * @param easingFunction defines the easing function to use (linear by default)
  91120. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91121. * @returns the list of animatables created for all nodes
  91122. * @example https://www.babylonjs-playground.com/#MH0VLI
  91123. */
  91124. 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[]>;
  91125. /**
  91126. * Creates a new animation, merges it with the existing animations and starts it
  91127. * @param name Name of the animation
  91128. * @param node Node which contains the scene that begins the animations
  91129. * @param targetProperty Specifies which property to animate
  91130. * @param framePerSecond The frames per second of the animation
  91131. * @param totalFrame The total number of frames
  91132. * @param from The frame at the beginning of the animation
  91133. * @param to The frame at the end of the animation
  91134. * @param loopMode Specifies the loop mode of the animation
  91135. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91136. * @param onAnimationEnd Callback to run once the animation is complete
  91137. * @returns Nullable animation
  91138. */
  91139. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91140. /**
  91141. * Transition property of an host to the target Value
  91142. * @param property The property to transition
  91143. * @param targetValue The target Value of the property
  91144. * @param host The object where the property to animate belongs
  91145. * @param scene Scene used to run the animation
  91146. * @param frameRate Framerate (in frame/s) to use
  91147. * @param transition The transition type we want to use
  91148. * @param duration The duration of the animation, in milliseconds
  91149. * @param onAnimationEnd Callback trigger at the end of the animation
  91150. * @returns Nullable animation
  91151. */
  91152. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91153. /**
  91154. * Return the array of runtime animations currently using this animation
  91155. */
  91156. readonly runtimeAnimations: RuntimeAnimation[];
  91157. /**
  91158. * Specifies if any of the runtime animations are currently running
  91159. */
  91160. readonly hasRunningRuntimeAnimations: boolean;
  91161. /**
  91162. * Initializes the animation
  91163. * @param name Name of the animation
  91164. * @param targetProperty Property to animate
  91165. * @param framePerSecond The frames per second of the animation
  91166. * @param dataType The data type of the animation
  91167. * @param loopMode The loop mode of the animation
  91168. * @param enableBlending Specifies if blending should be enabled
  91169. */
  91170. constructor(
  91171. /**Name of the animation */
  91172. name: string,
  91173. /**Property to animate */
  91174. targetProperty: string,
  91175. /**The frames per second of the animation */
  91176. framePerSecond: number,
  91177. /**The data type of the animation */
  91178. dataType: number,
  91179. /**The loop mode of the animation */
  91180. loopMode?: number | undefined,
  91181. /**Specifies if blending should be enabled */
  91182. enableBlending?: boolean | undefined);
  91183. /**
  91184. * Converts the animation to a string
  91185. * @param fullDetails support for multiple levels of logging within scene loading
  91186. * @returns String form of the animation
  91187. */
  91188. toString(fullDetails?: boolean): string;
  91189. /**
  91190. * Add an event to this animation
  91191. * @param event Event to add
  91192. */
  91193. addEvent(event: AnimationEvent): void;
  91194. /**
  91195. * Remove all events found at the given frame
  91196. * @param frame The frame to remove events from
  91197. */
  91198. removeEvents(frame: number): void;
  91199. /**
  91200. * Retrieves all the events from the animation
  91201. * @returns Events from the animation
  91202. */
  91203. getEvents(): AnimationEvent[];
  91204. /**
  91205. * Creates an animation range
  91206. * @param name Name of the animation range
  91207. * @param from Starting frame of the animation range
  91208. * @param to Ending frame of the animation
  91209. */
  91210. createRange(name: string, from: number, to: number): void;
  91211. /**
  91212. * Deletes an animation range by name
  91213. * @param name Name of the animation range to delete
  91214. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91215. */
  91216. deleteRange(name: string, deleteFrames?: boolean): void;
  91217. /**
  91218. * Gets the animation range by name, or null if not defined
  91219. * @param name Name of the animation range
  91220. * @returns Nullable animation range
  91221. */
  91222. getRange(name: string): Nullable<AnimationRange>;
  91223. /**
  91224. * Gets the key frames from the animation
  91225. * @returns The key frames of the animation
  91226. */
  91227. getKeys(): Array<IAnimationKey>;
  91228. /**
  91229. * Gets the highest frame rate of the animation
  91230. * @returns Highest frame rate of the animation
  91231. */
  91232. getHighestFrame(): number;
  91233. /**
  91234. * Gets the easing function of the animation
  91235. * @returns Easing function of the animation
  91236. */
  91237. getEasingFunction(): IEasingFunction;
  91238. /**
  91239. * Sets the easing function of the animation
  91240. * @param easingFunction A custom mathematical formula for animation
  91241. */
  91242. setEasingFunction(easingFunction: EasingFunction): void;
  91243. /**
  91244. * Interpolates a scalar linearly
  91245. * @param startValue Start value of the animation curve
  91246. * @param endValue End value of the animation curve
  91247. * @param gradient Scalar amount to interpolate
  91248. * @returns Interpolated scalar value
  91249. */
  91250. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91251. /**
  91252. * Interpolates a scalar cubically
  91253. * @param startValue Start value of the animation curve
  91254. * @param outTangent End tangent of the animation
  91255. * @param endValue End value of the animation curve
  91256. * @param inTangent Start tangent of the animation curve
  91257. * @param gradient Scalar amount to interpolate
  91258. * @returns Interpolated scalar value
  91259. */
  91260. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91261. /**
  91262. * Interpolates a quaternion using a spherical linear interpolation
  91263. * @param startValue Start value of the animation curve
  91264. * @param endValue End value of the animation curve
  91265. * @param gradient Scalar amount to interpolate
  91266. * @returns Interpolated quaternion value
  91267. */
  91268. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91269. /**
  91270. * Interpolates a quaternion cubically
  91271. * @param startValue Start value of the animation curve
  91272. * @param outTangent End tangent of the animation curve
  91273. * @param endValue End value of the animation curve
  91274. * @param inTangent Start tangent of the animation curve
  91275. * @param gradient Scalar amount to interpolate
  91276. * @returns Interpolated quaternion value
  91277. */
  91278. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91279. /**
  91280. * Interpolates a Vector3 linearl
  91281. * @param startValue Start value of the animation curve
  91282. * @param endValue End value of the animation curve
  91283. * @param gradient Scalar amount to interpolate
  91284. * @returns Interpolated scalar value
  91285. */
  91286. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91287. /**
  91288. * Interpolates a Vector3 cubically
  91289. * @param startValue Start value of the animation curve
  91290. * @param outTangent End tangent of the animation
  91291. * @param endValue End value of the animation curve
  91292. * @param inTangent Start tangent of the animation curve
  91293. * @param gradient Scalar amount to interpolate
  91294. * @returns InterpolatedVector3 value
  91295. */
  91296. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91297. /**
  91298. * Interpolates a Vector2 linearly
  91299. * @param startValue Start value of the animation curve
  91300. * @param endValue End value of the animation curve
  91301. * @param gradient Scalar amount to interpolate
  91302. * @returns Interpolated Vector2 value
  91303. */
  91304. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91305. /**
  91306. * Interpolates a Vector2 cubically
  91307. * @param startValue Start value of the animation curve
  91308. * @param outTangent End tangent of the animation
  91309. * @param endValue End value of the animation curve
  91310. * @param inTangent Start tangent of the animation curve
  91311. * @param gradient Scalar amount to interpolate
  91312. * @returns Interpolated Vector2 value
  91313. */
  91314. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91315. /**
  91316. * Interpolates a size linearly
  91317. * @param startValue Start value of the animation curve
  91318. * @param endValue End value of the animation curve
  91319. * @param gradient Scalar amount to interpolate
  91320. * @returns Interpolated Size value
  91321. */
  91322. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91323. /**
  91324. * Interpolates a Color3 linearly
  91325. * @param startValue Start value of the animation curve
  91326. * @param endValue End value of the animation curve
  91327. * @param gradient Scalar amount to interpolate
  91328. * @returns Interpolated Color3 value
  91329. */
  91330. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91331. /**
  91332. * @hidden Internal use only
  91333. */
  91334. _getKeyValue(value: any): any;
  91335. /**
  91336. * @hidden Internal use only
  91337. */
  91338. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91339. /**
  91340. * Defines the function to use to interpolate matrices
  91341. * @param startValue defines the start matrix
  91342. * @param endValue defines the end matrix
  91343. * @param gradient defines the gradient between both matrices
  91344. * @param result defines an optional target matrix where to store the interpolation
  91345. * @returns the interpolated matrix
  91346. */
  91347. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91348. /**
  91349. * Makes a copy of the animation
  91350. * @returns Cloned animation
  91351. */
  91352. clone(): Animation;
  91353. /**
  91354. * Sets the key frames of the animation
  91355. * @param values The animation key frames to set
  91356. */
  91357. setKeys(values: Array<IAnimationKey>): void;
  91358. /**
  91359. * Serializes the animation to an object
  91360. * @returns Serialized object
  91361. */
  91362. serialize(): any;
  91363. /**
  91364. * Float animation type
  91365. */
  91366. private static _ANIMATIONTYPE_FLOAT;
  91367. /**
  91368. * Vector3 animation type
  91369. */
  91370. private static _ANIMATIONTYPE_VECTOR3;
  91371. /**
  91372. * Quaternion animation type
  91373. */
  91374. private static _ANIMATIONTYPE_QUATERNION;
  91375. /**
  91376. * Matrix animation type
  91377. */
  91378. private static _ANIMATIONTYPE_MATRIX;
  91379. /**
  91380. * Color3 animation type
  91381. */
  91382. private static _ANIMATIONTYPE_COLOR3;
  91383. /**
  91384. * Vector2 animation type
  91385. */
  91386. private static _ANIMATIONTYPE_VECTOR2;
  91387. /**
  91388. * Size animation type
  91389. */
  91390. private static _ANIMATIONTYPE_SIZE;
  91391. /**
  91392. * Relative Loop Mode
  91393. */
  91394. private static _ANIMATIONLOOPMODE_RELATIVE;
  91395. /**
  91396. * Cycle Loop Mode
  91397. */
  91398. private static _ANIMATIONLOOPMODE_CYCLE;
  91399. /**
  91400. * Constant Loop Mode
  91401. */
  91402. private static _ANIMATIONLOOPMODE_CONSTANT;
  91403. /**
  91404. * Get the float animation type
  91405. */
  91406. static readonly ANIMATIONTYPE_FLOAT: number;
  91407. /**
  91408. * Get the Vector3 animation type
  91409. */
  91410. static readonly ANIMATIONTYPE_VECTOR3: number;
  91411. /**
  91412. * Get the Vector2 animation type
  91413. */
  91414. static readonly ANIMATIONTYPE_VECTOR2: number;
  91415. /**
  91416. * Get the Size animation type
  91417. */
  91418. static readonly ANIMATIONTYPE_SIZE: number;
  91419. /**
  91420. * Get the Quaternion animation type
  91421. */
  91422. static readonly ANIMATIONTYPE_QUATERNION: number;
  91423. /**
  91424. * Get the Matrix animation type
  91425. */
  91426. static readonly ANIMATIONTYPE_MATRIX: number;
  91427. /**
  91428. * Get the Color3 animation type
  91429. */
  91430. static readonly ANIMATIONTYPE_COLOR3: number;
  91431. /**
  91432. * Get the Relative Loop Mode
  91433. */
  91434. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91435. /**
  91436. * Get the Cycle Loop Mode
  91437. */
  91438. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91439. /**
  91440. * Get the Constant Loop Mode
  91441. */
  91442. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91443. /** @hidden */
  91444. static _UniversalLerp(left: any, right: any, amount: number): any;
  91445. /**
  91446. * Parses an animation object and creates an animation
  91447. * @param parsedAnimation Parsed animation object
  91448. * @returns Animation object
  91449. */
  91450. static Parse(parsedAnimation: any): Animation;
  91451. /**
  91452. * Appends the serialized animations from the source animations
  91453. * @param source Source containing the animations
  91454. * @param destination Target to store the animations
  91455. */
  91456. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91457. }
  91458. }
  91459. declare module BABYLON {
  91460. /**
  91461. * Interface containing an array of animations
  91462. */
  91463. export interface IAnimatable {
  91464. /**
  91465. * Array of animations
  91466. */
  91467. animations: Nullable<Array<Animation>>;
  91468. }
  91469. }
  91470. declare module BABYLON {
  91471. /**
  91472. * This represents all the required information to add a fresnel effect on a material:
  91473. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91474. */
  91475. export class FresnelParameters {
  91476. private _isEnabled;
  91477. /**
  91478. * Define if the fresnel effect is enable or not.
  91479. */
  91480. isEnabled: boolean;
  91481. /**
  91482. * Define the color used on edges (grazing angle)
  91483. */
  91484. leftColor: Color3;
  91485. /**
  91486. * Define the color used on center
  91487. */
  91488. rightColor: Color3;
  91489. /**
  91490. * Define bias applied to computed fresnel term
  91491. */
  91492. bias: number;
  91493. /**
  91494. * Defined the power exponent applied to fresnel term
  91495. */
  91496. power: number;
  91497. /**
  91498. * Clones the current fresnel and its valuues
  91499. * @returns a clone fresnel configuration
  91500. */
  91501. clone(): FresnelParameters;
  91502. /**
  91503. * Serializes the current fresnel parameters to a JSON representation.
  91504. * @return the JSON serialization
  91505. */
  91506. serialize(): any;
  91507. /**
  91508. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91509. * @param parsedFresnelParameters Define the JSON representation
  91510. * @returns the parsed parameters
  91511. */
  91512. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91513. }
  91514. }
  91515. declare module BABYLON {
  91516. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91517. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91518. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91519. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91520. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91521. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91522. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91523. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91524. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91525. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91526. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91527. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91528. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91529. /**
  91530. * Decorator used to define property that can be serialized as reference to a camera
  91531. * @param sourceName defines the name of the property to decorate
  91532. */
  91533. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91534. /**
  91535. * Class used to help serialization objects
  91536. */
  91537. export class SerializationHelper {
  91538. /** @hidden */
  91539. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91540. /** @hidden */
  91541. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91542. /** @hidden */
  91543. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91544. /** @hidden */
  91545. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91546. /**
  91547. * Appends the serialized animations from the source animations
  91548. * @param source Source containing the animations
  91549. * @param destination Target to store the animations
  91550. */
  91551. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91552. /**
  91553. * Static function used to serialized a specific entity
  91554. * @param entity defines the entity to serialize
  91555. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91556. * @returns a JSON compatible object representing the serialization of the entity
  91557. */
  91558. static Serialize<T>(entity: T, serializationObject?: any): any;
  91559. /**
  91560. * Creates a new entity from a serialization data object
  91561. * @param creationFunction defines a function used to instanciated the new entity
  91562. * @param source defines the source serialization data
  91563. * @param scene defines the hosting scene
  91564. * @param rootUrl defines the root url for resources
  91565. * @returns a new entity
  91566. */
  91567. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91568. /**
  91569. * Clones an object
  91570. * @param creationFunction defines the function used to instanciate the new object
  91571. * @param source defines the source object
  91572. * @returns the cloned object
  91573. */
  91574. static Clone<T>(creationFunction: () => T, source: T): T;
  91575. /**
  91576. * Instanciates a new object based on a source one (some data will be shared between both object)
  91577. * @param creationFunction defines the function used to instanciate the new object
  91578. * @param source defines the source object
  91579. * @returns the new object
  91580. */
  91581. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91582. }
  91583. }
  91584. declare module BABYLON {
  91585. /**
  91586. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91587. */
  91588. export interface CubeMapInfo {
  91589. /**
  91590. * The pixel array for the front face.
  91591. * This is stored in format, left to right, up to down format.
  91592. */
  91593. front: Nullable<ArrayBufferView>;
  91594. /**
  91595. * The pixel array for the back face.
  91596. * This is stored in format, left to right, up to down format.
  91597. */
  91598. back: Nullable<ArrayBufferView>;
  91599. /**
  91600. * The pixel array for the left face.
  91601. * This is stored in format, left to right, up to down format.
  91602. */
  91603. left: Nullable<ArrayBufferView>;
  91604. /**
  91605. * The pixel array for the right face.
  91606. * This is stored in format, left to right, up to down format.
  91607. */
  91608. right: Nullable<ArrayBufferView>;
  91609. /**
  91610. * The pixel array for the up face.
  91611. * This is stored in format, left to right, up to down format.
  91612. */
  91613. up: Nullable<ArrayBufferView>;
  91614. /**
  91615. * The pixel array for the down face.
  91616. * This is stored in format, left to right, up to down format.
  91617. */
  91618. down: Nullable<ArrayBufferView>;
  91619. /**
  91620. * The size of the cubemap stored.
  91621. *
  91622. * Each faces will be size * size pixels.
  91623. */
  91624. size: number;
  91625. /**
  91626. * The format of the texture.
  91627. *
  91628. * RGBA, RGB.
  91629. */
  91630. format: number;
  91631. /**
  91632. * The type of the texture data.
  91633. *
  91634. * UNSIGNED_INT, FLOAT.
  91635. */
  91636. type: number;
  91637. /**
  91638. * Specifies whether the texture is in gamma space.
  91639. */
  91640. gammaSpace: boolean;
  91641. }
  91642. /**
  91643. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91644. */
  91645. export class PanoramaToCubeMapTools {
  91646. private static FACE_FRONT;
  91647. private static FACE_BACK;
  91648. private static FACE_RIGHT;
  91649. private static FACE_LEFT;
  91650. private static FACE_DOWN;
  91651. private static FACE_UP;
  91652. /**
  91653. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91654. *
  91655. * @param float32Array The source data.
  91656. * @param inputWidth The width of the input panorama.
  91657. * @param inputHeight The height of the input panorama.
  91658. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91659. * @return The cubemap data
  91660. */
  91661. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91662. private static CreateCubemapTexture;
  91663. private static CalcProjectionSpherical;
  91664. }
  91665. }
  91666. declare module BABYLON {
  91667. /**
  91668. * Helper class dealing with the extraction of spherical polynomial dataArray
  91669. * from a cube map.
  91670. */
  91671. export class CubeMapToSphericalPolynomialTools {
  91672. private static FileFaces;
  91673. /**
  91674. * Converts a texture to the according Spherical Polynomial data.
  91675. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91676. *
  91677. * @param texture The texture to extract the information from.
  91678. * @return The Spherical Polynomial data.
  91679. */
  91680. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91681. /**
  91682. * Converts a cubemap to the according Spherical Polynomial data.
  91683. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91684. *
  91685. * @param cubeInfo The Cube map to extract the information from.
  91686. * @return The Spherical Polynomial data.
  91687. */
  91688. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91689. }
  91690. }
  91691. declare module BABYLON {
  91692. /**
  91693. * Class used to manipulate GUIDs
  91694. */
  91695. export class GUID {
  91696. /**
  91697. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91698. * Be aware Math.random() could cause collisions, but:
  91699. * "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"
  91700. * @returns a pseudo random id
  91701. */
  91702. static RandomId(): string;
  91703. }
  91704. }
  91705. declare module BABYLON {
  91706. /**
  91707. * Base class of all the textures in babylon.
  91708. * It groups all the common properties the materials, post process, lights... might need
  91709. * in order to make a correct use of the texture.
  91710. */
  91711. export class BaseTexture implements IAnimatable {
  91712. /**
  91713. * Default anisotropic filtering level for the application.
  91714. * It is set to 4 as a good tradeoff between perf and quality.
  91715. */
  91716. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91717. /**
  91718. * Gets or sets the unique id of the texture
  91719. */
  91720. uniqueId: number;
  91721. /**
  91722. * Define the name of the texture.
  91723. */
  91724. name: string;
  91725. /**
  91726. * Gets or sets an object used to store user defined information.
  91727. */
  91728. metadata: any;
  91729. /**
  91730. * For internal use only. Please do not use.
  91731. */
  91732. reservedDataStore: any;
  91733. private _hasAlpha;
  91734. /**
  91735. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91736. */
  91737. hasAlpha: boolean;
  91738. /**
  91739. * Defines if the alpha value should be determined via the rgb values.
  91740. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91741. */
  91742. getAlphaFromRGB: boolean;
  91743. /**
  91744. * Intensity or strength of the texture.
  91745. * It is commonly used by materials to fine tune the intensity of the texture
  91746. */
  91747. level: number;
  91748. /**
  91749. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91750. * This is part of the texture as textures usually maps to one uv set.
  91751. */
  91752. coordinatesIndex: number;
  91753. private _coordinatesMode;
  91754. /**
  91755. * How a texture is mapped.
  91756. *
  91757. * | Value | Type | Description |
  91758. * | ----- | ----------------------------------- | ----------- |
  91759. * | 0 | EXPLICIT_MODE | |
  91760. * | 1 | SPHERICAL_MODE | |
  91761. * | 2 | PLANAR_MODE | |
  91762. * | 3 | CUBIC_MODE | |
  91763. * | 4 | PROJECTION_MODE | |
  91764. * | 5 | SKYBOX_MODE | |
  91765. * | 6 | INVCUBIC_MODE | |
  91766. * | 7 | EQUIRECTANGULAR_MODE | |
  91767. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91768. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91769. */
  91770. coordinatesMode: number;
  91771. /**
  91772. * | Value | Type | Description |
  91773. * | ----- | ------------------ | ----------- |
  91774. * | 0 | CLAMP_ADDRESSMODE | |
  91775. * | 1 | WRAP_ADDRESSMODE | |
  91776. * | 2 | MIRROR_ADDRESSMODE | |
  91777. */
  91778. wrapU: number;
  91779. /**
  91780. * | Value | Type | Description |
  91781. * | ----- | ------------------ | ----------- |
  91782. * | 0 | CLAMP_ADDRESSMODE | |
  91783. * | 1 | WRAP_ADDRESSMODE | |
  91784. * | 2 | MIRROR_ADDRESSMODE | |
  91785. */
  91786. wrapV: number;
  91787. /**
  91788. * | Value | Type | Description |
  91789. * | ----- | ------------------ | ----------- |
  91790. * | 0 | CLAMP_ADDRESSMODE | |
  91791. * | 1 | WRAP_ADDRESSMODE | |
  91792. * | 2 | MIRROR_ADDRESSMODE | |
  91793. */
  91794. wrapR: number;
  91795. /**
  91796. * With compliant hardware and browser (supporting anisotropic filtering)
  91797. * this defines the level of anisotropic filtering in the texture.
  91798. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91799. */
  91800. anisotropicFilteringLevel: number;
  91801. /**
  91802. * Define if the texture is a cube texture or if false a 2d texture.
  91803. */
  91804. isCube: boolean;
  91805. /**
  91806. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91807. */
  91808. is3D: boolean;
  91809. /**
  91810. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91811. * HDR texture are usually stored in linear space.
  91812. * This only impacts the PBR and Background materials
  91813. */
  91814. gammaSpace: boolean;
  91815. /**
  91816. * Gets whether or not the texture contains RGBD data.
  91817. */
  91818. readonly isRGBD: boolean;
  91819. /**
  91820. * Is Z inverted in the texture (useful in a cube texture).
  91821. */
  91822. invertZ: boolean;
  91823. /**
  91824. * Are mip maps generated for this texture or not.
  91825. */
  91826. readonly noMipmap: boolean;
  91827. /**
  91828. * @hidden
  91829. */
  91830. lodLevelInAlpha: boolean;
  91831. /**
  91832. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91833. */
  91834. lodGenerationOffset: number;
  91835. /**
  91836. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91837. */
  91838. lodGenerationScale: number;
  91839. /**
  91840. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91841. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91842. * average roughness values.
  91843. */
  91844. linearSpecularLOD: boolean;
  91845. /**
  91846. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91847. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91848. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91849. */
  91850. irradianceTexture: Nullable<BaseTexture>;
  91851. /**
  91852. * Define if the texture is a render target.
  91853. */
  91854. isRenderTarget: boolean;
  91855. /**
  91856. * Define the unique id of the texture in the scene.
  91857. */
  91858. readonly uid: string;
  91859. /**
  91860. * Return a string representation of the texture.
  91861. * @returns the texture as a string
  91862. */
  91863. toString(): string;
  91864. /**
  91865. * Get the class name of the texture.
  91866. * @returns "BaseTexture"
  91867. */
  91868. getClassName(): string;
  91869. /**
  91870. * Define the list of animation attached to the texture.
  91871. */
  91872. animations: Animation[];
  91873. /**
  91874. * An event triggered when the texture is disposed.
  91875. */
  91876. onDisposeObservable: Observable<BaseTexture>;
  91877. private _onDisposeObserver;
  91878. /**
  91879. * Callback triggered when the texture has been disposed.
  91880. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91881. */
  91882. onDispose: () => void;
  91883. /**
  91884. * Define the current state of the loading sequence when in delayed load mode.
  91885. */
  91886. delayLoadState: number;
  91887. private _scene;
  91888. /** @hidden */
  91889. _texture: Nullable<InternalTexture>;
  91890. private _uid;
  91891. /**
  91892. * Define if the texture is preventinga material to render or not.
  91893. * If not and the texture is not ready, the engine will use a default black texture instead.
  91894. */
  91895. readonly isBlocking: boolean;
  91896. /**
  91897. * Instantiates a new BaseTexture.
  91898. * Base class of all the textures in babylon.
  91899. * It groups all the common properties the materials, post process, lights... might need
  91900. * in order to make a correct use of the texture.
  91901. * @param scene Define the scene the texture blongs to
  91902. */
  91903. constructor(scene: Nullable<Scene>);
  91904. /**
  91905. * Get the scene the texture belongs to.
  91906. * @returns the scene or null if undefined
  91907. */
  91908. getScene(): Nullable<Scene>;
  91909. /**
  91910. * Get the texture transform matrix used to offset tile the texture for istance.
  91911. * @returns the transformation matrix
  91912. */
  91913. getTextureMatrix(): Matrix;
  91914. /**
  91915. * Get the texture reflection matrix used to rotate/transform the reflection.
  91916. * @returns the reflection matrix
  91917. */
  91918. getReflectionTextureMatrix(): Matrix;
  91919. /**
  91920. * Get the underlying lower level texture from Babylon.
  91921. * @returns the insternal texture
  91922. */
  91923. getInternalTexture(): Nullable<InternalTexture>;
  91924. /**
  91925. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91926. * @returns true if ready or not blocking
  91927. */
  91928. isReadyOrNotBlocking(): boolean;
  91929. /**
  91930. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91931. * @returns true if fully ready
  91932. */
  91933. isReady(): boolean;
  91934. private _cachedSize;
  91935. /**
  91936. * Get the size of the texture.
  91937. * @returns the texture size.
  91938. */
  91939. getSize(): ISize;
  91940. /**
  91941. * Get the base size of the texture.
  91942. * It can be different from the size if the texture has been resized for POT for instance
  91943. * @returns the base size
  91944. */
  91945. getBaseSize(): ISize;
  91946. /**
  91947. * Update the sampling mode of the texture.
  91948. * Default is Trilinear mode.
  91949. *
  91950. * | Value | Type | Description |
  91951. * | ----- | ------------------ | ----------- |
  91952. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91953. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91954. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91955. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91956. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91957. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91958. * | 7 | NEAREST_LINEAR | |
  91959. * | 8 | NEAREST_NEAREST | |
  91960. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91961. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91962. * | 11 | LINEAR_LINEAR | |
  91963. * | 12 | LINEAR_NEAREST | |
  91964. *
  91965. * > _mag_: magnification filter (close to the viewer)
  91966. * > _min_: minification filter (far from the viewer)
  91967. * > _mip_: filter used between mip map levels
  91968. *@param samplingMode Define the new sampling mode of the texture
  91969. */
  91970. updateSamplingMode(samplingMode: number): void;
  91971. /**
  91972. * Scales the texture if is `canRescale()`
  91973. * @param ratio the resize factor we want to use to rescale
  91974. */
  91975. scale(ratio: number): void;
  91976. /**
  91977. * Get if the texture can rescale.
  91978. */
  91979. readonly canRescale: boolean;
  91980. /** @hidden */
  91981. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91982. /** @hidden */
  91983. _rebuild(): void;
  91984. /**
  91985. * Triggers the load sequence in delayed load mode.
  91986. */
  91987. delayLoad(): void;
  91988. /**
  91989. * Clones the texture.
  91990. * @returns the cloned texture
  91991. */
  91992. clone(): Nullable<BaseTexture>;
  91993. /**
  91994. * Get the texture underlying type (INT, FLOAT...)
  91995. */
  91996. readonly textureType: number;
  91997. /**
  91998. * Get the texture underlying format (RGB, RGBA...)
  91999. */
  92000. readonly textureFormat: number;
  92001. /**
  92002. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92003. * This will returns an RGBA array buffer containing either in values (0-255) or
  92004. * float values (0-1) depending of the underlying buffer type.
  92005. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92006. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92007. * @param buffer defines a user defined buffer to fill with data (can be null)
  92008. * @returns The Array buffer containing the pixels data.
  92009. */
  92010. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92011. /**
  92012. * Release and destroy the underlying lower level texture aka internalTexture.
  92013. */
  92014. releaseInternalTexture(): void;
  92015. /**
  92016. * Get the polynomial representation of the texture data.
  92017. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92018. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92019. */
  92020. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92021. /** @hidden */
  92022. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92023. /** @hidden */
  92024. readonly _lodTextureMid: Nullable<BaseTexture>;
  92025. /** @hidden */
  92026. readonly _lodTextureLow: Nullable<BaseTexture>;
  92027. /**
  92028. * Dispose the texture and release its associated resources.
  92029. */
  92030. dispose(): void;
  92031. /**
  92032. * Serialize the texture into a JSON representation that can be parsed later on.
  92033. * @returns the JSON representation of the texture
  92034. */
  92035. serialize(): any;
  92036. /**
  92037. * Helper function to be called back once a list of texture contains only ready textures.
  92038. * @param textures Define the list of textures to wait for
  92039. * @param callback Define the callback triggered once the entire list will be ready
  92040. */
  92041. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92042. }
  92043. }
  92044. declare module BABYLON {
  92045. /**
  92046. * Class used to store data associated with WebGL texture data for the engine
  92047. * This class should not be used directly
  92048. */
  92049. export class InternalTexture {
  92050. /** @hidden */
  92051. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92052. /**
  92053. * The source of the texture data is unknown
  92054. */
  92055. static DATASOURCE_UNKNOWN: number;
  92056. /**
  92057. * Texture data comes from an URL
  92058. */
  92059. static DATASOURCE_URL: number;
  92060. /**
  92061. * Texture data is only used for temporary storage
  92062. */
  92063. static DATASOURCE_TEMP: number;
  92064. /**
  92065. * Texture data comes from raw data (ArrayBuffer)
  92066. */
  92067. static DATASOURCE_RAW: number;
  92068. /**
  92069. * Texture content is dynamic (video or dynamic texture)
  92070. */
  92071. static DATASOURCE_DYNAMIC: number;
  92072. /**
  92073. * Texture content is generated by rendering to it
  92074. */
  92075. static DATASOURCE_RENDERTARGET: number;
  92076. /**
  92077. * Texture content is part of a multi render target process
  92078. */
  92079. static DATASOURCE_MULTIRENDERTARGET: number;
  92080. /**
  92081. * Texture data comes from a cube data file
  92082. */
  92083. static DATASOURCE_CUBE: number;
  92084. /**
  92085. * Texture data comes from a raw cube data
  92086. */
  92087. static DATASOURCE_CUBERAW: number;
  92088. /**
  92089. * Texture data come from a prefiltered cube data file
  92090. */
  92091. static DATASOURCE_CUBEPREFILTERED: number;
  92092. /**
  92093. * Texture content is raw 3D data
  92094. */
  92095. static DATASOURCE_RAW3D: number;
  92096. /**
  92097. * Texture content is a depth texture
  92098. */
  92099. static DATASOURCE_DEPTHTEXTURE: number;
  92100. /**
  92101. * Texture data comes from a raw cube data encoded with RGBD
  92102. */
  92103. static DATASOURCE_CUBERAW_RGBD: number;
  92104. /**
  92105. * Defines if the texture is ready
  92106. */
  92107. isReady: boolean;
  92108. /**
  92109. * Defines if the texture is a cube texture
  92110. */
  92111. isCube: boolean;
  92112. /**
  92113. * Defines if the texture contains 3D data
  92114. */
  92115. is3D: boolean;
  92116. /**
  92117. * Defines if the texture contains multiview data
  92118. */
  92119. isMultiview: boolean;
  92120. /**
  92121. * Gets the URL used to load this texture
  92122. */
  92123. url: string;
  92124. /**
  92125. * Gets the sampling mode of the texture
  92126. */
  92127. samplingMode: number;
  92128. /**
  92129. * Gets a boolean indicating if the texture needs mipmaps generation
  92130. */
  92131. generateMipMaps: boolean;
  92132. /**
  92133. * Gets the number of samples used by the texture (WebGL2+ only)
  92134. */
  92135. samples: number;
  92136. /**
  92137. * Gets the type of the texture (int, float...)
  92138. */
  92139. type: number;
  92140. /**
  92141. * Gets the format of the texture (RGB, RGBA...)
  92142. */
  92143. format: number;
  92144. /**
  92145. * Observable called when the texture is loaded
  92146. */
  92147. onLoadedObservable: Observable<InternalTexture>;
  92148. /**
  92149. * Gets the width of the texture
  92150. */
  92151. width: number;
  92152. /**
  92153. * Gets the height of the texture
  92154. */
  92155. height: number;
  92156. /**
  92157. * Gets the depth of the texture
  92158. */
  92159. depth: number;
  92160. /**
  92161. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92162. */
  92163. baseWidth: number;
  92164. /**
  92165. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92166. */
  92167. baseHeight: number;
  92168. /**
  92169. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92170. */
  92171. baseDepth: number;
  92172. /**
  92173. * Gets a boolean indicating if the texture is inverted on Y axis
  92174. */
  92175. invertY: boolean;
  92176. /** @hidden */
  92177. _invertVScale: boolean;
  92178. /** @hidden */
  92179. _associatedChannel: number;
  92180. /** @hidden */
  92181. _dataSource: number;
  92182. /** @hidden */
  92183. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92184. /** @hidden */
  92185. _bufferView: Nullable<ArrayBufferView>;
  92186. /** @hidden */
  92187. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92188. /** @hidden */
  92189. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92190. /** @hidden */
  92191. _size: number;
  92192. /** @hidden */
  92193. _extension: string;
  92194. /** @hidden */
  92195. _files: Nullable<string[]>;
  92196. /** @hidden */
  92197. _workingCanvas: Nullable<HTMLCanvasElement>;
  92198. /** @hidden */
  92199. _workingContext: Nullable<CanvasRenderingContext2D>;
  92200. /** @hidden */
  92201. _framebuffer: Nullable<WebGLFramebuffer>;
  92202. /** @hidden */
  92203. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92204. /** @hidden */
  92205. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92206. /** @hidden */
  92207. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92208. /** @hidden */
  92209. _attachments: Nullable<number[]>;
  92210. /** @hidden */
  92211. _cachedCoordinatesMode: Nullable<number>;
  92212. /** @hidden */
  92213. _cachedWrapU: Nullable<number>;
  92214. /** @hidden */
  92215. _cachedWrapV: Nullable<number>;
  92216. /** @hidden */
  92217. _cachedWrapR: Nullable<number>;
  92218. /** @hidden */
  92219. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92220. /** @hidden */
  92221. _isDisabled: boolean;
  92222. /** @hidden */
  92223. _compression: Nullable<string>;
  92224. /** @hidden */
  92225. _generateStencilBuffer: boolean;
  92226. /** @hidden */
  92227. _generateDepthBuffer: boolean;
  92228. /** @hidden */
  92229. _comparisonFunction: number;
  92230. /** @hidden */
  92231. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92232. /** @hidden */
  92233. _lodGenerationScale: number;
  92234. /** @hidden */
  92235. _lodGenerationOffset: number;
  92236. /** @hidden */
  92237. _colorTextureArray: Nullable<WebGLTexture>;
  92238. /** @hidden */
  92239. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92240. /** @hidden */
  92241. _lodTextureHigh: Nullable<BaseTexture>;
  92242. /** @hidden */
  92243. _lodTextureMid: Nullable<BaseTexture>;
  92244. /** @hidden */
  92245. _lodTextureLow: Nullable<BaseTexture>;
  92246. /** @hidden */
  92247. _isRGBD: boolean;
  92248. /** @hidden */
  92249. _linearSpecularLOD: boolean;
  92250. /** @hidden */
  92251. _irradianceTexture: Nullable<BaseTexture>;
  92252. /** @hidden */
  92253. _webGLTexture: Nullable<WebGLTexture>;
  92254. /** @hidden */
  92255. _references: number;
  92256. private _engine;
  92257. /**
  92258. * Gets the Engine the texture belongs to.
  92259. * @returns The babylon engine
  92260. */
  92261. getEngine(): Engine;
  92262. /**
  92263. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92264. */
  92265. readonly dataSource: number;
  92266. /**
  92267. * Creates a new InternalTexture
  92268. * @param engine defines the engine to use
  92269. * @param dataSource defines the type of data that will be used
  92270. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92271. */
  92272. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92273. /**
  92274. * Increments the number of references (ie. the number of Texture that point to it)
  92275. */
  92276. incrementReferences(): void;
  92277. /**
  92278. * Change the size of the texture (not the size of the content)
  92279. * @param width defines the new width
  92280. * @param height defines the new height
  92281. * @param depth defines the new depth (1 by default)
  92282. */
  92283. updateSize(width: int, height: int, depth?: int): void;
  92284. /** @hidden */
  92285. _rebuild(): void;
  92286. /** @hidden */
  92287. _swapAndDie(target: InternalTexture): void;
  92288. /**
  92289. * Dispose the current allocated resources
  92290. */
  92291. dispose(): void;
  92292. }
  92293. }
  92294. declare module BABYLON {
  92295. /**
  92296. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92297. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92298. */
  92299. export class EffectFallbacks {
  92300. private _defines;
  92301. private _currentRank;
  92302. private _maxRank;
  92303. private _mesh;
  92304. /**
  92305. * Removes the fallback from the bound mesh.
  92306. */
  92307. unBindMesh(): void;
  92308. /**
  92309. * Adds a fallback on the specified property.
  92310. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92311. * @param define The name of the define in the shader
  92312. */
  92313. addFallback(rank: number, define: string): void;
  92314. /**
  92315. * Sets the mesh to use CPU skinning when needing to fallback.
  92316. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92317. * @param mesh The mesh to use the fallbacks.
  92318. */
  92319. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92320. /**
  92321. * Checks to see if more fallbacks are still availible.
  92322. */
  92323. readonly isMoreFallbacks: boolean;
  92324. /**
  92325. * Removes the defines that should be removed when falling back.
  92326. * @param currentDefines defines the current define statements for the shader.
  92327. * @param effect defines the current effect we try to compile
  92328. * @returns The resulting defines with defines of the current rank removed.
  92329. */
  92330. reduce(currentDefines: string, effect: Effect): string;
  92331. }
  92332. /**
  92333. * Options to be used when creating an effect.
  92334. */
  92335. export class EffectCreationOptions {
  92336. /**
  92337. * Atrributes that will be used in the shader.
  92338. */
  92339. attributes: string[];
  92340. /**
  92341. * Uniform varible names that will be set in the shader.
  92342. */
  92343. uniformsNames: string[];
  92344. /**
  92345. * Uniform buffer varible names that will be set in the shader.
  92346. */
  92347. uniformBuffersNames: string[];
  92348. /**
  92349. * Sampler texture variable names that will be set in the shader.
  92350. */
  92351. samplers: string[];
  92352. /**
  92353. * Define statements that will be set in the shader.
  92354. */
  92355. defines: any;
  92356. /**
  92357. * Possible fallbacks for this effect to improve performance when needed.
  92358. */
  92359. fallbacks: Nullable<EffectFallbacks>;
  92360. /**
  92361. * Callback that will be called when the shader is compiled.
  92362. */
  92363. onCompiled: Nullable<(effect: Effect) => void>;
  92364. /**
  92365. * Callback that will be called if an error occurs during shader compilation.
  92366. */
  92367. onError: Nullable<(effect: Effect, errors: string) => void>;
  92368. /**
  92369. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92370. */
  92371. indexParameters: any;
  92372. /**
  92373. * Max number of lights that can be used in the shader.
  92374. */
  92375. maxSimultaneousLights: number;
  92376. /**
  92377. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92378. */
  92379. transformFeedbackVaryings: Nullable<string[]>;
  92380. }
  92381. /**
  92382. * Effect containing vertex and fragment shader that can be executed on an object.
  92383. */
  92384. export class Effect implements IDisposable {
  92385. /**
  92386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92387. */
  92388. static ShadersRepository: string;
  92389. /**
  92390. * Name of the effect.
  92391. */
  92392. name: any;
  92393. /**
  92394. * String container all the define statements that should be set on the shader.
  92395. */
  92396. defines: string;
  92397. /**
  92398. * Callback that will be called when the shader is compiled.
  92399. */
  92400. onCompiled: Nullable<(effect: Effect) => void>;
  92401. /**
  92402. * Callback that will be called if an error occurs during shader compilation.
  92403. */
  92404. onError: Nullable<(effect: Effect, errors: string) => void>;
  92405. /**
  92406. * Callback that will be called when effect is bound.
  92407. */
  92408. onBind: Nullable<(effect: Effect) => void>;
  92409. /**
  92410. * Unique ID of the effect.
  92411. */
  92412. uniqueId: number;
  92413. /**
  92414. * Observable that will be called when the shader is compiled.
  92415. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92416. */
  92417. onCompileObservable: Observable<Effect>;
  92418. /**
  92419. * Observable that will be called if an error occurs during shader compilation.
  92420. */
  92421. onErrorObservable: Observable<Effect>;
  92422. /** @hidden */
  92423. _onBindObservable: Nullable<Observable<Effect>>;
  92424. /**
  92425. * Observable that will be called when effect is bound.
  92426. */
  92427. readonly onBindObservable: Observable<Effect>;
  92428. /** @hidden */
  92429. _bonesComputationForcedToCPU: boolean;
  92430. private static _uniqueIdSeed;
  92431. private _engine;
  92432. private _uniformBuffersNames;
  92433. private _uniformsNames;
  92434. private _samplerList;
  92435. private _samplers;
  92436. private _isReady;
  92437. private _compilationError;
  92438. private _attributesNames;
  92439. private _attributes;
  92440. private _uniforms;
  92441. /**
  92442. * Key for the effect.
  92443. * @hidden
  92444. */
  92445. _key: string;
  92446. private _indexParameters;
  92447. private _fallbacks;
  92448. private _vertexSourceCode;
  92449. private _fragmentSourceCode;
  92450. private _vertexSourceCodeOverride;
  92451. private _fragmentSourceCodeOverride;
  92452. private _transformFeedbackVaryings;
  92453. /**
  92454. * Compiled shader to webGL program.
  92455. * @hidden
  92456. */
  92457. _pipelineContext: Nullable<IPipelineContext>;
  92458. private _valueCache;
  92459. private static _baseCache;
  92460. /**
  92461. * Instantiates an effect.
  92462. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92463. * @param baseName Name of the effect.
  92464. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92465. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92466. * @param samplers List of sampler variables that will be passed to the shader.
  92467. * @param engine Engine to be used to render the effect
  92468. * @param defines Define statements to be added to the shader.
  92469. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92470. * @param onCompiled Callback that will be called when the shader is compiled.
  92471. * @param onError Callback that will be called if an error occurs during shader compilation.
  92472. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92473. */
  92474. 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);
  92475. private _useFinalCode;
  92476. /**
  92477. * Unique key for this effect
  92478. */
  92479. readonly key: string;
  92480. /**
  92481. * If the effect has been compiled and prepared.
  92482. * @returns if the effect is compiled and prepared.
  92483. */
  92484. isReady(): boolean;
  92485. /**
  92486. * The engine the effect was initialized with.
  92487. * @returns the engine.
  92488. */
  92489. getEngine(): Engine;
  92490. /**
  92491. * The pipeline context for this effect
  92492. * @returns the associated pipeline context
  92493. */
  92494. getPipelineContext(): Nullable<IPipelineContext>;
  92495. /**
  92496. * The set of names of attribute variables for the shader.
  92497. * @returns An array of attribute names.
  92498. */
  92499. getAttributesNames(): string[];
  92500. /**
  92501. * Returns the attribute at the given index.
  92502. * @param index The index of the attribute.
  92503. * @returns The location of the attribute.
  92504. */
  92505. getAttributeLocation(index: number): number;
  92506. /**
  92507. * Returns the attribute based on the name of the variable.
  92508. * @param name of the attribute to look up.
  92509. * @returns the attribute location.
  92510. */
  92511. getAttributeLocationByName(name: string): number;
  92512. /**
  92513. * The number of attributes.
  92514. * @returns the numnber of attributes.
  92515. */
  92516. getAttributesCount(): number;
  92517. /**
  92518. * Gets the index of a uniform variable.
  92519. * @param uniformName of the uniform to look up.
  92520. * @returns the index.
  92521. */
  92522. getUniformIndex(uniformName: string): number;
  92523. /**
  92524. * Returns the attribute based on the name of the variable.
  92525. * @param uniformName of the uniform to look up.
  92526. * @returns the location of the uniform.
  92527. */
  92528. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92529. /**
  92530. * Returns an array of sampler variable names
  92531. * @returns The array of sampler variable neames.
  92532. */
  92533. getSamplers(): string[];
  92534. /**
  92535. * The error from the last compilation.
  92536. * @returns the error string.
  92537. */
  92538. getCompilationError(): string;
  92539. /**
  92540. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92541. * @param func The callback to be used.
  92542. */
  92543. executeWhenCompiled(func: (effect: Effect) => void): void;
  92544. private _checkIsReady;
  92545. /** @hidden */
  92546. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92547. /** @hidden */
  92548. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92549. /** @hidden */
  92550. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92551. /**
  92552. * Recompiles the webGL program
  92553. * @param vertexSourceCode The source code for the vertex shader.
  92554. * @param fragmentSourceCode The source code for the fragment shader.
  92555. * @param onCompiled Callback called when completed.
  92556. * @param onError Callback called on error.
  92557. * @hidden
  92558. */
  92559. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92560. /**
  92561. * Prepares the effect
  92562. * @hidden
  92563. */
  92564. _prepareEffect(): void;
  92565. /**
  92566. * Checks if the effect is supported. (Must be called after compilation)
  92567. */
  92568. readonly isSupported: boolean;
  92569. /**
  92570. * Binds a texture to the engine to be used as output of the shader.
  92571. * @param channel Name of the output variable.
  92572. * @param texture Texture to bind.
  92573. * @hidden
  92574. */
  92575. _bindTexture(channel: string, texture: InternalTexture): void;
  92576. /**
  92577. * Sets a texture on the engine to be used in the shader.
  92578. * @param channel Name of the sampler variable.
  92579. * @param texture Texture to set.
  92580. */
  92581. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92582. /**
  92583. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92584. * @param channel Name of the sampler variable.
  92585. * @param texture Texture to set.
  92586. */
  92587. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92588. /**
  92589. * Sets an array of textures on the engine to be used in the shader.
  92590. * @param channel Name of the variable.
  92591. * @param textures Textures to set.
  92592. */
  92593. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92594. /**
  92595. * 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)
  92596. * @param channel Name of the sampler variable.
  92597. * @param postProcess Post process to get the input texture from.
  92598. */
  92599. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92600. /**
  92601. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92602. * 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)
  92603. * @param channel Name of the sampler variable.
  92604. * @param postProcess Post process to get the output texture from.
  92605. */
  92606. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92607. /** @hidden */
  92608. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92609. /** @hidden */
  92610. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92611. /** @hidden */
  92612. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92613. /** @hidden */
  92614. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92615. /**
  92616. * Binds a buffer to a uniform.
  92617. * @param buffer Buffer to bind.
  92618. * @param name Name of the uniform variable to bind to.
  92619. */
  92620. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92621. /**
  92622. * Binds block to a uniform.
  92623. * @param blockName Name of the block to bind.
  92624. * @param index Index to bind.
  92625. */
  92626. bindUniformBlock(blockName: string, index: number): void;
  92627. /**
  92628. * Sets an interger value on a uniform variable.
  92629. * @param uniformName Name of the variable.
  92630. * @param value Value to be set.
  92631. * @returns this effect.
  92632. */
  92633. setInt(uniformName: string, value: number): Effect;
  92634. /**
  92635. * Sets an int array on a uniform variable.
  92636. * @param uniformName Name of the variable.
  92637. * @param array array to be set.
  92638. * @returns this effect.
  92639. */
  92640. setIntArray(uniformName: string, array: Int32Array): Effect;
  92641. /**
  92642. * 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)
  92643. * @param uniformName Name of the variable.
  92644. * @param array array to be set.
  92645. * @returns this effect.
  92646. */
  92647. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92648. /**
  92649. * 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)
  92650. * @param uniformName Name of the variable.
  92651. * @param array array to be set.
  92652. * @returns this effect.
  92653. */
  92654. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92655. /**
  92656. * 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)
  92657. * @param uniformName Name of the variable.
  92658. * @param array array to be set.
  92659. * @returns this effect.
  92660. */
  92661. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92662. /**
  92663. * Sets an float array on a uniform variable.
  92664. * @param uniformName Name of the variable.
  92665. * @param array array to be set.
  92666. * @returns this effect.
  92667. */
  92668. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92669. /**
  92670. * 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)
  92671. * @param uniformName Name of the variable.
  92672. * @param array array to be set.
  92673. * @returns this effect.
  92674. */
  92675. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92676. /**
  92677. * 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)
  92678. * @param uniformName Name of the variable.
  92679. * @param array array to be set.
  92680. * @returns this effect.
  92681. */
  92682. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92683. /**
  92684. * 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)
  92685. * @param uniformName Name of the variable.
  92686. * @param array array to be set.
  92687. * @returns this effect.
  92688. */
  92689. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92690. /**
  92691. * Sets an array on a uniform variable.
  92692. * @param uniformName Name of the variable.
  92693. * @param array array to be set.
  92694. * @returns this effect.
  92695. */
  92696. setArray(uniformName: string, array: number[]): Effect;
  92697. /**
  92698. * 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)
  92699. * @param uniformName Name of the variable.
  92700. * @param array array to be set.
  92701. * @returns this effect.
  92702. */
  92703. setArray2(uniformName: string, array: number[]): Effect;
  92704. /**
  92705. * 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)
  92706. * @param uniformName Name of the variable.
  92707. * @param array array to be set.
  92708. * @returns this effect.
  92709. */
  92710. setArray3(uniformName: string, array: number[]): Effect;
  92711. /**
  92712. * 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)
  92713. * @param uniformName Name of the variable.
  92714. * @param array array to be set.
  92715. * @returns this effect.
  92716. */
  92717. setArray4(uniformName: string, array: number[]): Effect;
  92718. /**
  92719. * Sets matrices on a uniform variable.
  92720. * @param uniformName Name of the variable.
  92721. * @param matrices matrices to be set.
  92722. * @returns this effect.
  92723. */
  92724. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92725. /**
  92726. * Sets matrix on a uniform variable.
  92727. * @param uniformName Name of the variable.
  92728. * @param matrix matrix to be set.
  92729. * @returns this effect.
  92730. */
  92731. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92732. /**
  92733. * 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)
  92734. * @param uniformName Name of the variable.
  92735. * @param matrix matrix to be set.
  92736. * @returns this effect.
  92737. */
  92738. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92739. /**
  92740. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92741. * @param uniformName Name of the variable.
  92742. * @param matrix matrix to be set.
  92743. * @returns this effect.
  92744. */
  92745. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92746. /**
  92747. * Sets a float on a uniform variable.
  92748. * @param uniformName Name of the variable.
  92749. * @param value value to be set.
  92750. * @returns this effect.
  92751. */
  92752. setFloat(uniformName: string, value: number): Effect;
  92753. /**
  92754. * Sets a boolean on a uniform variable.
  92755. * @param uniformName Name of the variable.
  92756. * @param bool value to be set.
  92757. * @returns this effect.
  92758. */
  92759. setBool(uniformName: string, bool: boolean): Effect;
  92760. /**
  92761. * Sets a Vector2 on a uniform variable.
  92762. * @param uniformName Name of the variable.
  92763. * @param vector2 vector2 to be set.
  92764. * @returns this effect.
  92765. */
  92766. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92767. /**
  92768. * Sets a float2 on a uniform variable.
  92769. * @param uniformName Name of the variable.
  92770. * @param x First float in float2.
  92771. * @param y Second float in float2.
  92772. * @returns this effect.
  92773. */
  92774. setFloat2(uniformName: string, x: number, y: number): Effect;
  92775. /**
  92776. * Sets a Vector3 on a uniform variable.
  92777. * @param uniformName Name of the variable.
  92778. * @param vector3 Value to be set.
  92779. * @returns this effect.
  92780. */
  92781. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92782. /**
  92783. * Sets a float3 on a uniform variable.
  92784. * @param uniformName Name of the variable.
  92785. * @param x First float in float3.
  92786. * @param y Second float in float3.
  92787. * @param z Third float in float3.
  92788. * @returns this effect.
  92789. */
  92790. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92791. /**
  92792. * Sets a Vector4 on a uniform variable.
  92793. * @param uniformName Name of the variable.
  92794. * @param vector4 Value to be set.
  92795. * @returns this effect.
  92796. */
  92797. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92798. /**
  92799. * Sets a float4 on a uniform variable.
  92800. * @param uniformName Name of the variable.
  92801. * @param x First float in float4.
  92802. * @param y Second float in float4.
  92803. * @param z Third float in float4.
  92804. * @param w Fourth float in float4.
  92805. * @returns this effect.
  92806. */
  92807. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92808. /**
  92809. * Sets a Color3 on a uniform variable.
  92810. * @param uniformName Name of the variable.
  92811. * @param color3 Value to be set.
  92812. * @returns this effect.
  92813. */
  92814. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92815. /**
  92816. * Sets a Color4 on a uniform variable.
  92817. * @param uniformName Name of the variable.
  92818. * @param color3 Value to be set.
  92819. * @param alpha Alpha value to be set.
  92820. * @returns this effect.
  92821. */
  92822. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92823. /**
  92824. * Sets a Color4 on a uniform variable
  92825. * @param uniformName defines the name of the variable
  92826. * @param color4 defines the value to be set
  92827. * @returns this effect.
  92828. */
  92829. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92830. /** Release all associated resources */
  92831. dispose(): void;
  92832. /**
  92833. * This function will add a new shader to the shader store
  92834. * @param name the name of the shader
  92835. * @param pixelShader optional pixel shader content
  92836. * @param vertexShader optional vertex shader content
  92837. */
  92838. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92839. /**
  92840. * Store of each shader (The can be looked up using effect.key)
  92841. */
  92842. static ShadersStore: {
  92843. [key: string]: string;
  92844. };
  92845. /**
  92846. * Store of each included file for a shader (The can be looked up using effect.key)
  92847. */
  92848. static IncludesShadersStore: {
  92849. [key: string]: string;
  92850. };
  92851. /**
  92852. * Resets the cache of effects.
  92853. */
  92854. static ResetCache(): void;
  92855. }
  92856. }
  92857. declare module BABYLON {
  92858. /**
  92859. * Uniform buffer objects.
  92860. *
  92861. * Handles blocks of uniform on the GPU.
  92862. *
  92863. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92864. *
  92865. * For more information, please refer to :
  92866. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92867. */
  92868. export class UniformBuffer {
  92869. private _engine;
  92870. private _buffer;
  92871. private _data;
  92872. private _bufferData;
  92873. private _dynamic?;
  92874. private _uniformLocations;
  92875. private _uniformSizes;
  92876. private _uniformLocationPointer;
  92877. private _needSync;
  92878. private _noUBO;
  92879. private _currentEffect;
  92880. private static _MAX_UNIFORM_SIZE;
  92881. private static _tempBuffer;
  92882. /**
  92883. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92884. * This is dynamic to allow compat with webgl 1 and 2.
  92885. * You will need to pass the name of the uniform as well as the value.
  92886. */
  92887. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92888. /**
  92889. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92890. * This is dynamic to allow compat with webgl 1 and 2.
  92891. * You will need to pass the name of the uniform as well as the value.
  92892. */
  92893. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92894. /**
  92895. * Lambda to Update a single float in a uniform buffer.
  92896. * This is dynamic to allow compat with webgl 1 and 2.
  92897. * You will need to pass the name of the uniform as well as the value.
  92898. */
  92899. updateFloat: (name: string, x: number) => void;
  92900. /**
  92901. * Lambda to Update a vec2 of float in a uniform buffer.
  92902. * This is dynamic to allow compat with webgl 1 and 2.
  92903. * You will need to pass the name of the uniform as well as the value.
  92904. */
  92905. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92906. /**
  92907. * Lambda to Update a vec3 of float in a uniform buffer.
  92908. * This is dynamic to allow compat with webgl 1 and 2.
  92909. * You will need to pass the name of the uniform as well as the value.
  92910. */
  92911. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92912. /**
  92913. * Lambda to Update a vec4 of float in a uniform buffer.
  92914. * This is dynamic to allow compat with webgl 1 and 2.
  92915. * You will need to pass the name of the uniform as well as the value.
  92916. */
  92917. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92918. /**
  92919. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92920. * This is dynamic to allow compat with webgl 1 and 2.
  92921. * You will need to pass the name of the uniform as well as the value.
  92922. */
  92923. updateMatrix: (name: string, mat: Matrix) => void;
  92924. /**
  92925. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92926. * This is dynamic to allow compat with webgl 1 and 2.
  92927. * You will need to pass the name of the uniform as well as the value.
  92928. */
  92929. updateVector3: (name: string, vector: Vector3) => void;
  92930. /**
  92931. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92932. * This is dynamic to allow compat with webgl 1 and 2.
  92933. * You will need to pass the name of the uniform as well as the value.
  92934. */
  92935. updateVector4: (name: string, vector: Vector4) => void;
  92936. /**
  92937. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92938. * This is dynamic to allow compat with webgl 1 and 2.
  92939. * You will need to pass the name of the uniform as well as the value.
  92940. */
  92941. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92942. /**
  92943. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92944. * This is dynamic to allow compat with webgl 1 and 2.
  92945. * You will need to pass the name of the uniform as well as the value.
  92946. */
  92947. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92948. /**
  92949. * Instantiates a new Uniform buffer objects.
  92950. *
  92951. * Handles blocks of uniform on the GPU.
  92952. *
  92953. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92954. *
  92955. * For more information, please refer to :
  92956. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92957. * @param engine Define the engine the buffer is associated with
  92958. * @param data Define the data contained in the buffer
  92959. * @param dynamic Define if the buffer is updatable
  92960. */
  92961. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92962. /**
  92963. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92964. * or just falling back on setUniformXXX calls.
  92965. */
  92966. readonly useUbo: boolean;
  92967. /**
  92968. * Indicates if the WebGL underlying uniform buffer is in sync
  92969. * with the javascript cache data.
  92970. */
  92971. readonly isSync: boolean;
  92972. /**
  92973. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92974. * Also, a dynamic UniformBuffer will disable cache verification and always
  92975. * update the underlying WebGL uniform buffer to the GPU.
  92976. * @returns if Dynamic, otherwise false
  92977. */
  92978. isDynamic(): boolean;
  92979. /**
  92980. * The data cache on JS side.
  92981. * @returns the underlying data as a float array
  92982. */
  92983. getData(): Float32Array;
  92984. /**
  92985. * The underlying WebGL Uniform buffer.
  92986. * @returns the webgl buffer
  92987. */
  92988. getBuffer(): Nullable<DataBuffer>;
  92989. /**
  92990. * std140 layout specifies how to align data within an UBO structure.
  92991. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92992. * for specs.
  92993. */
  92994. private _fillAlignment;
  92995. /**
  92996. * Adds an uniform in the buffer.
  92997. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92998. * for the layout to be correct !
  92999. * @param name Name of the uniform, as used in the uniform block in the shader.
  93000. * @param size Data size, or data directly.
  93001. */
  93002. addUniform(name: string, size: number | number[]): void;
  93003. /**
  93004. * Adds a Matrix 4x4 to the uniform buffer.
  93005. * @param name Name of the uniform, as used in the uniform block in the shader.
  93006. * @param mat A 4x4 matrix.
  93007. */
  93008. addMatrix(name: string, mat: Matrix): void;
  93009. /**
  93010. * Adds a vec2 to the uniform buffer.
  93011. * @param name Name of the uniform, as used in the uniform block in the shader.
  93012. * @param x Define the x component value of the vec2
  93013. * @param y Define the y component value of the vec2
  93014. */
  93015. addFloat2(name: string, x: number, y: number): void;
  93016. /**
  93017. * Adds a vec3 to the uniform buffer.
  93018. * @param name Name of the uniform, as used in the uniform block in the shader.
  93019. * @param x Define the x component value of the vec3
  93020. * @param y Define the y component value of the vec3
  93021. * @param z Define the z component value of the vec3
  93022. */
  93023. addFloat3(name: string, x: number, y: number, z: number): void;
  93024. /**
  93025. * Adds a vec3 to the uniform buffer.
  93026. * @param name Name of the uniform, as used in the uniform block in the shader.
  93027. * @param color Define the vec3 from a Color
  93028. */
  93029. addColor3(name: string, color: Color3): void;
  93030. /**
  93031. * Adds a vec4 to the uniform buffer.
  93032. * @param name Name of the uniform, as used in the uniform block in the shader.
  93033. * @param color Define the rgb components from a Color
  93034. * @param alpha Define the a component of the vec4
  93035. */
  93036. addColor4(name: string, color: Color3, alpha: number): void;
  93037. /**
  93038. * Adds a vec3 to the uniform buffer.
  93039. * @param name Name of the uniform, as used in the uniform block in the shader.
  93040. * @param vector Define the vec3 components from a Vector
  93041. */
  93042. addVector3(name: string, vector: Vector3): void;
  93043. /**
  93044. * Adds a Matrix 3x3 to the uniform buffer.
  93045. * @param name Name of the uniform, as used in the uniform block in the shader.
  93046. */
  93047. addMatrix3x3(name: string): void;
  93048. /**
  93049. * Adds a Matrix 2x2 to the uniform buffer.
  93050. * @param name Name of the uniform, as used in the uniform block in the shader.
  93051. */
  93052. addMatrix2x2(name: string): void;
  93053. /**
  93054. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93055. */
  93056. create(): void;
  93057. /** @hidden */
  93058. _rebuild(): void;
  93059. /**
  93060. * Updates the WebGL Uniform Buffer on the GPU.
  93061. * If the `dynamic` flag is set to true, no cache comparison is done.
  93062. * Otherwise, the buffer will be updated only if the cache differs.
  93063. */
  93064. update(): void;
  93065. /**
  93066. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93067. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93068. * @param data Define the flattened data
  93069. * @param size Define the size of the data.
  93070. */
  93071. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93072. private _updateMatrix3x3ForUniform;
  93073. private _updateMatrix3x3ForEffect;
  93074. private _updateMatrix2x2ForEffect;
  93075. private _updateMatrix2x2ForUniform;
  93076. private _updateFloatForEffect;
  93077. private _updateFloatForUniform;
  93078. private _updateFloat2ForEffect;
  93079. private _updateFloat2ForUniform;
  93080. private _updateFloat3ForEffect;
  93081. private _updateFloat3ForUniform;
  93082. private _updateFloat4ForEffect;
  93083. private _updateFloat4ForUniform;
  93084. private _updateMatrixForEffect;
  93085. private _updateMatrixForUniform;
  93086. private _updateVector3ForEffect;
  93087. private _updateVector3ForUniform;
  93088. private _updateVector4ForEffect;
  93089. private _updateVector4ForUniform;
  93090. private _updateColor3ForEffect;
  93091. private _updateColor3ForUniform;
  93092. private _updateColor4ForEffect;
  93093. private _updateColor4ForUniform;
  93094. /**
  93095. * Sets a sampler uniform on the effect.
  93096. * @param name Define the name of the sampler.
  93097. * @param texture Define the texture to set in the sampler
  93098. */
  93099. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93100. /**
  93101. * Directly updates the value of the uniform in the cache AND on the GPU.
  93102. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93103. * @param data Define the flattened data
  93104. */
  93105. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93106. /**
  93107. * Binds this uniform buffer to an effect.
  93108. * @param effect Define the effect to bind the buffer to
  93109. * @param name Name of the uniform block in the shader.
  93110. */
  93111. bindToEffect(effect: Effect, name: string): void;
  93112. /**
  93113. * Disposes the uniform buffer.
  93114. */
  93115. dispose(): void;
  93116. }
  93117. }
  93118. declare module BABYLON {
  93119. /**
  93120. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93122. */
  93123. export class Analyser {
  93124. /**
  93125. * Gets or sets the smoothing
  93126. * @ignorenaming
  93127. */
  93128. SMOOTHING: number;
  93129. /**
  93130. * Gets or sets the FFT table size
  93131. * @ignorenaming
  93132. */
  93133. FFT_SIZE: number;
  93134. /**
  93135. * Gets or sets the bar graph amplitude
  93136. * @ignorenaming
  93137. */
  93138. BARGRAPHAMPLITUDE: number;
  93139. /**
  93140. * Gets or sets the position of the debug canvas
  93141. * @ignorenaming
  93142. */
  93143. DEBUGCANVASPOS: {
  93144. x: number;
  93145. y: number;
  93146. };
  93147. /**
  93148. * Gets or sets the debug canvas size
  93149. * @ignorenaming
  93150. */
  93151. DEBUGCANVASSIZE: {
  93152. width: number;
  93153. height: number;
  93154. };
  93155. private _byteFreqs;
  93156. private _byteTime;
  93157. private _floatFreqs;
  93158. private _webAudioAnalyser;
  93159. private _debugCanvas;
  93160. private _debugCanvasContext;
  93161. private _scene;
  93162. private _registerFunc;
  93163. private _audioEngine;
  93164. /**
  93165. * Creates a new analyser
  93166. * @param scene defines hosting scene
  93167. */
  93168. constructor(scene: Scene);
  93169. /**
  93170. * Get the number of data values you will have to play with for the visualization
  93171. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93172. * @returns a number
  93173. */
  93174. getFrequencyBinCount(): number;
  93175. /**
  93176. * Gets the current frequency data as a byte array
  93177. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93178. * @returns a Uint8Array
  93179. */
  93180. getByteFrequencyData(): Uint8Array;
  93181. /**
  93182. * Gets the current waveform as a byte array
  93183. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93184. * @returns a Uint8Array
  93185. */
  93186. getByteTimeDomainData(): Uint8Array;
  93187. /**
  93188. * Gets the current frequency data as a float array
  93189. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93190. * @returns a Float32Array
  93191. */
  93192. getFloatFrequencyData(): Float32Array;
  93193. /**
  93194. * Renders the debug canvas
  93195. */
  93196. drawDebugCanvas(): void;
  93197. /**
  93198. * Stops rendering the debug canvas and removes it
  93199. */
  93200. stopDebugCanvas(): void;
  93201. /**
  93202. * Connects two audio nodes
  93203. * @param inputAudioNode defines first node to connect
  93204. * @param outputAudioNode defines second node to connect
  93205. */
  93206. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93207. /**
  93208. * Releases all associated resources
  93209. */
  93210. dispose(): void;
  93211. }
  93212. }
  93213. declare module BABYLON {
  93214. /**
  93215. * This represents an audio engine and it is responsible
  93216. * to play, synchronize and analyse sounds throughout the application.
  93217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93218. */
  93219. export interface IAudioEngine extends IDisposable {
  93220. /**
  93221. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93222. */
  93223. readonly canUseWebAudio: boolean;
  93224. /**
  93225. * Gets the current AudioContext if available.
  93226. */
  93227. readonly audioContext: Nullable<AudioContext>;
  93228. /**
  93229. * The master gain node defines the global audio volume of your audio engine.
  93230. */
  93231. readonly masterGain: GainNode;
  93232. /**
  93233. * Gets whether or not mp3 are supported by your browser.
  93234. */
  93235. readonly isMP3supported: boolean;
  93236. /**
  93237. * Gets whether or not ogg are supported by your browser.
  93238. */
  93239. readonly isOGGsupported: boolean;
  93240. /**
  93241. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93242. * @ignoreNaming
  93243. */
  93244. WarnedWebAudioUnsupported: boolean;
  93245. /**
  93246. * Defines if the audio engine relies on a custom unlocked button.
  93247. * In this case, the embedded button will not be displayed.
  93248. */
  93249. useCustomUnlockedButton: boolean;
  93250. /**
  93251. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93252. */
  93253. readonly unlocked: boolean;
  93254. /**
  93255. * Event raised when audio has been unlocked on the browser.
  93256. */
  93257. onAudioUnlockedObservable: Observable<AudioEngine>;
  93258. /**
  93259. * Event raised when audio has been locked on the browser.
  93260. */
  93261. onAudioLockedObservable: Observable<AudioEngine>;
  93262. /**
  93263. * Flags the audio engine in Locked state.
  93264. * This happens due to new browser policies preventing audio to autoplay.
  93265. */
  93266. lock(): void;
  93267. /**
  93268. * Unlocks the audio engine once a user action has been done on the dom.
  93269. * This is helpful to resume play once browser policies have been satisfied.
  93270. */
  93271. unlock(): void;
  93272. }
  93273. /**
  93274. * This represents the default audio engine used in babylon.
  93275. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93277. */
  93278. export class AudioEngine implements IAudioEngine {
  93279. private _audioContext;
  93280. private _audioContextInitialized;
  93281. private _muteButton;
  93282. private _hostElement;
  93283. /**
  93284. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93285. */
  93286. canUseWebAudio: boolean;
  93287. /**
  93288. * The master gain node defines the global audio volume of your audio engine.
  93289. */
  93290. masterGain: GainNode;
  93291. /**
  93292. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93293. * @ignoreNaming
  93294. */
  93295. WarnedWebAudioUnsupported: boolean;
  93296. /**
  93297. * Gets whether or not mp3 are supported by your browser.
  93298. */
  93299. isMP3supported: boolean;
  93300. /**
  93301. * Gets whether or not ogg are supported by your browser.
  93302. */
  93303. isOGGsupported: boolean;
  93304. /**
  93305. * Gets whether audio has been unlocked on the device.
  93306. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93307. * a user interaction has happened.
  93308. */
  93309. unlocked: boolean;
  93310. /**
  93311. * Defines if the audio engine relies on a custom unlocked button.
  93312. * In this case, the embedded button will not be displayed.
  93313. */
  93314. useCustomUnlockedButton: boolean;
  93315. /**
  93316. * Event raised when audio has been unlocked on the browser.
  93317. */
  93318. onAudioUnlockedObservable: Observable<AudioEngine>;
  93319. /**
  93320. * Event raised when audio has been locked on the browser.
  93321. */
  93322. onAudioLockedObservable: Observable<AudioEngine>;
  93323. /**
  93324. * Gets the current AudioContext if available.
  93325. */
  93326. readonly audioContext: Nullable<AudioContext>;
  93327. private _connectedAnalyser;
  93328. /**
  93329. * Instantiates a new audio engine.
  93330. *
  93331. * There should be only one per page as some browsers restrict the number
  93332. * of audio contexts you can create.
  93333. * @param hostElement defines the host element where to display the mute icon if necessary
  93334. */
  93335. constructor(hostElement?: Nullable<HTMLElement>);
  93336. /**
  93337. * Flags the audio engine in Locked state.
  93338. * This happens due to new browser policies preventing audio to autoplay.
  93339. */
  93340. lock(): void;
  93341. /**
  93342. * Unlocks the audio engine once a user action has been done on the dom.
  93343. * This is helpful to resume play once browser policies have been satisfied.
  93344. */
  93345. unlock(): void;
  93346. private _resumeAudioContext;
  93347. private _initializeAudioContext;
  93348. private _tryToRun;
  93349. private _triggerRunningState;
  93350. private _triggerSuspendedState;
  93351. private _displayMuteButton;
  93352. private _moveButtonToTopLeft;
  93353. private _onResize;
  93354. private _hideMuteButton;
  93355. /**
  93356. * Destroy and release the resources associated with the audio ccontext.
  93357. */
  93358. dispose(): void;
  93359. /**
  93360. * Gets the global volume sets on the master gain.
  93361. * @returns the global volume if set or -1 otherwise
  93362. */
  93363. getGlobalVolume(): number;
  93364. /**
  93365. * Sets the global volume of your experience (sets on the master gain).
  93366. * @param newVolume Defines the new global volume of the application
  93367. */
  93368. setGlobalVolume(newVolume: number): void;
  93369. /**
  93370. * Connect the audio engine to an audio analyser allowing some amazing
  93371. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93373. * @param analyser The analyser to connect to the engine
  93374. */
  93375. connectToAnalyser(analyser: Analyser): void;
  93376. }
  93377. }
  93378. declare module BABYLON {
  93379. /**
  93380. * Interface used to present a loading screen while loading a scene
  93381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93382. */
  93383. export interface ILoadingScreen {
  93384. /**
  93385. * Function called to display the loading screen
  93386. */
  93387. displayLoadingUI: () => void;
  93388. /**
  93389. * Function called to hide the loading screen
  93390. */
  93391. hideLoadingUI: () => void;
  93392. /**
  93393. * Gets or sets the color to use for the background
  93394. */
  93395. loadingUIBackgroundColor: string;
  93396. /**
  93397. * Gets or sets the text to display while loading
  93398. */
  93399. loadingUIText: string;
  93400. }
  93401. /**
  93402. * Class used for the default loading screen
  93403. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93404. */
  93405. export class DefaultLoadingScreen implements ILoadingScreen {
  93406. private _renderingCanvas;
  93407. private _loadingText;
  93408. private _loadingDivBackgroundColor;
  93409. private _loadingDiv;
  93410. private _loadingTextDiv;
  93411. /** Gets or sets the logo url to use for the default loading screen */
  93412. static DefaultLogoUrl: string;
  93413. /** Gets or sets the spinner url to use for the default loading screen */
  93414. static DefaultSpinnerUrl: string;
  93415. /**
  93416. * Creates a new default loading screen
  93417. * @param _renderingCanvas defines the canvas used to render the scene
  93418. * @param _loadingText defines the default text to display
  93419. * @param _loadingDivBackgroundColor defines the default background color
  93420. */
  93421. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93422. /**
  93423. * Function called to display the loading screen
  93424. */
  93425. displayLoadingUI(): void;
  93426. /**
  93427. * Function called to hide the loading screen
  93428. */
  93429. hideLoadingUI(): void;
  93430. /**
  93431. * Gets or sets the text to display while loading
  93432. */
  93433. loadingUIText: string;
  93434. /**
  93435. * Gets or sets the color to use for the background
  93436. */
  93437. loadingUIBackgroundColor: string;
  93438. private _resizeLoadingUI;
  93439. }
  93440. }
  93441. declare module BABYLON {
  93442. /** @hidden */
  93443. export class WebGLPipelineContext implements IPipelineContext {
  93444. engine: Engine;
  93445. program: Nullable<WebGLProgram>;
  93446. context?: WebGLRenderingContext;
  93447. vertexShader?: WebGLShader;
  93448. fragmentShader?: WebGLShader;
  93449. isParallelCompiled: boolean;
  93450. onCompiled?: () => void;
  93451. transformFeedback?: WebGLTransformFeedback | null;
  93452. readonly isAsync: boolean;
  93453. readonly isReady: boolean;
  93454. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93455. }
  93456. }
  93457. declare module BABYLON {
  93458. /** @hidden */
  93459. export class WebGLDataBuffer extends DataBuffer {
  93460. private _buffer;
  93461. constructor(resource: WebGLBuffer);
  93462. readonly underlyingResource: any;
  93463. }
  93464. }
  93465. declare module BABYLON {
  93466. /** @hidden */
  93467. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93468. attributeProcessor(attribute: string): string;
  93469. varyingProcessor(varying: string, isFragment: boolean): string;
  93470. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93471. }
  93472. }
  93473. declare module BABYLON {
  93474. /**
  93475. * This class is used to track a performance counter which is number based.
  93476. * The user has access to many properties which give statistics of different nature.
  93477. *
  93478. * The implementer can track two kinds of Performance Counter: time and count.
  93479. * 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.
  93480. * 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.
  93481. */
  93482. export class PerfCounter {
  93483. /**
  93484. * Gets or sets a global boolean to turn on and off all the counters
  93485. */
  93486. static Enabled: boolean;
  93487. /**
  93488. * Returns the smallest value ever
  93489. */
  93490. readonly min: number;
  93491. /**
  93492. * Returns the biggest value ever
  93493. */
  93494. readonly max: number;
  93495. /**
  93496. * Returns the average value since the performance counter is running
  93497. */
  93498. readonly average: number;
  93499. /**
  93500. * Returns the average value of the last second the counter was monitored
  93501. */
  93502. readonly lastSecAverage: number;
  93503. /**
  93504. * Returns the current value
  93505. */
  93506. readonly current: number;
  93507. /**
  93508. * Gets the accumulated total
  93509. */
  93510. readonly total: number;
  93511. /**
  93512. * Gets the total value count
  93513. */
  93514. readonly count: number;
  93515. /**
  93516. * Creates a new counter
  93517. */
  93518. constructor();
  93519. /**
  93520. * Call this method to start monitoring a new frame.
  93521. * 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.
  93522. */
  93523. fetchNewFrame(): void;
  93524. /**
  93525. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93526. * @param newCount the count value to add to the monitored count
  93527. * @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.
  93528. */
  93529. addCount(newCount: number, fetchResult: boolean): void;
  93530. /**
  93531. * Start monitoring this performance counter
  93532. */
  93533. beginMonitoring(): void;
  93534. /**
  93535. * Compute the time lapsed since the previous beginMonitoring() call.
  93536. * @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
  93537. */
  93538. endMonitoring(newFrame?: boolean): void;
  93539. private _fetchResult;
  93540. private _startMonitoringTime;
  93541. private _min;
  93542. private _max;
  93543. private _average;
  93544. private _current;
  93545. private _totalValueCount;
  93546. private _totalAccumulated;
  93547. private _lastSecAverage;
  93548. private _lastSecAccumulated;
  93549. private _lastSecTime;
  93550. private _lastSecValueCount;
  93551. }
  93552. }
  93553. declare module BABYLON {
  93554. /**
  93555. * Interface for any object that can request an animation frame
  93556. */
  93557. export interface ICustomAnimationFrameRequester {
  93558. /**
  93559. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93560. */
  93561. renderFunction?: Function;
  93562. /**
  93563. * Called to request the next frame to render to
  93564. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93565. */
  93566. requestAnimationFrame: Function;
  93567. /**
  93568. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93569. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93570. */
  93571. requestID?: number;
  93572. }
  93573. }
  93574. declare module BABYLON {
  93575. /**
  93576. * Settings for finer control over video usage
  93577. */
  93578. export interface VideoTextureSettings {
  93579. /**
  93580. * Applies `autoplay` to video, if specified
  93581. */
  93582. autoPlay?: boolean;
  93583. /**
  93584. * Applies `loop` to video, if specified
  93585. */
  93586. loop?: boolean;
  93587. /**
  93588. * Automatically updates internal texture from video at every frame in the render loop
  93589. */
  93590. autoUpdateTexture: boolean;
  93591. /**
  93592. * Image src displayed during the video loading or until the user interacts with the video.
  93593. */
  93594. poster?: string;
  93595. }
  93596. /**
  93597. * If you want to display a video in your scene, this is the special texture for that.
  93598. * This special texture works similar to other textures, with the exception of a few parameters.
  93599. * @see https://doc.babylonjs.com/how_to/video_texture
  93600. */
  93601. export class VideoTexture extends Texture {
  93602. /**
  93603. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93604. */
  93605. readonly autoUpdateTexture: boolean;
  93606. /**
  93607. * The video instance used by the texture internally
  93608. */
  93609. readonly video: HTMLVideoElement;
  93610. private _onUserActionRequestedObservable;
  93611. /**
  93612. * Event triggerd when a dom action is required by the user to play the video.
  93613. * This happens due to recent changes in browser policies preventing video to auto start.
  93614. */
  93615. readonly onUserActionRequestedObservable: Observable<Texture>;
  93616. private _generateMipMaps;
  93617. private _engine;
  93618. private _stillImageCaptured;
  93619. private _displayingPosterTexture;
  93620. private _settings;
  93621. private _createInternalTextureOnEvent;
  93622. /**
  93623. * Creates a video texture.
  93624. * If you want to display a video in your scene, this is the special texture for that.
  93625. * This special texture works similar to other textures, with the exception of a few parameters.
  93626. * @see https://doc.babylonjs.com/how_to/video_texture
  93627. * @param name optional name, will detect from video source, if not defined
  93628. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93629. * @param scene is obviously the current scene.
  93630. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93631. * @param invertY is false by default but can be used to invert video on Y axis
  93632. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93633. * @param settings allows finer control over video usage
  93634. */
  93635. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93636. private _getName;
  93637. private _getVideo;
  93638. private _createInternalTexture;
  93639. private reset;
  93640. /**
  93641. * @hidden Internal method to initiate `update`.
  93642. */
  93643. _rebuild(): void;
  93644. /**
  93645. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93646. */
  93647. update(): void;
  93648. /**
  93649. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93650. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93651. */
  93652. updateTexture(isVisible: boolean): void;
  93653. protected _updateInternalTexture: () => void;
  93654. /**
  93655. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93656. * @param url New url.
  93657. */
  93658. updateURL(url: string): void;
  93659. /**
  93660. * Dispose the texture and release its associated resources.
  93661. */
  93662. dispose(): void;
  93663. /**
  93664. * Creates a video texture straight from a stream.
  93665. * @param scene Define the scene the texture should be created in
  93666. * @param stream Define the stream the texture should be created from
  93667. * @returns The created video texture as a promise
  93668. */
  93669. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93670. /**
  93671. * Creates a video texture straight from your WebCam video feed.
  93672. * @param scene Define the scene the texture should be created in
  93673. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93674. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93675. * @returns The created video texture as a promise
  93676. */
  93677. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93678. minWidth: number;
  93679. maxWidth: number;
  93680. minHeight: number;
  93681. maxHeight: number;
  93682. deviceId: string;
  93683. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93684. /**
  93685. * Creates a video texture straight from your WebCam video feed.
  93686. * @param scene Define the scene the texture should be created in
  93687. * @param onReady Define a callback to triggered once the texture will be ready
  93688. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93689. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93690. */
  93691. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93692. minWidth: number;
  93693. maxWidth: number;
  93694. minHeight: number;
  93695. maxHeight: number;
  93696. deviceId: string;
  93697. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93698. }
  93699. }
  93700. declare module BABYLON {
  93701. /**
  93702. * Defines the interface used by objects containing a viewport (like a camera)
  93703. */
  93704. interface IViewportOwnerLike {
  93705. /**
  93706. * Gets or sets the viewport
  93707. */
  93708. viewport: IViewportLike;
  93709. }
  93710. /**
  93711. * Interface for attribute information associated with buffer instanciation
  93712. */
  93713. export class InstancingAttributeInfo {
  93714. /**
  93715. * Index/offset of the attribute in the vertex shader
  93716. */
  93717. index: number;
  93718. /**
  93719. * size of the attribute, 1, 2, 3 or 4
  93720. */
  93721. attributeSize: number;
  93722. /**
  93723. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93724. * default is FLOAT
  93725. */
  93726. attribyteType: number;
  93727. /**
  93728. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93729. */
  93730. normalized: boolean;
  93731. /**
  93732. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93733. */
  93734. offset: number;
  93735. /**
  93736. * Name of the GLSL attribute, for debugging purpose only
  93737. */
  93738. attributeName: string;
  93739. }
  93740. /**
  93741. * Define options used to create a depth texture
  93742. */
  93743. export class DepthTextureCreationOptions {
  93744. /** Specifies whether or not a stencil should be allocated in the texture */
  93745. generateStencil?: boolean;
  93746. /** Specifies whether or not bilinear filtering is enable on the texture */
  93747. bilinearFiltering?: boolean;
  93748. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93749. comparisonFunction?: number;
  93750. /** Specifies if the created texture is a cube texture */
  93751. isCube?: boolean;
  93752. }
  93753. /**
  93754. * Class used to describe the capabilities of the engine relatively to the current browser
  93755. */
  93756. export class EngineCapabilities {
  93757. /** Maximum textures units per fragment shader */
  93758. maxTexturesImageUnits: number;
  93759. /** Maximum texture units per vertex shader */
  93760. maxVertexTextureImageUnits: number;
  93761. /** Maximum textures units in the entire pipeline */
  93762. maxCombinedTexturesImageUnits: number;
  93763. /** Maximum texture size */
  93764. maxTextureSize: number;
  93765. /** Maximum cube texture size */
  93766. maxCubemapTextureSize: number;
  93767. /** Maximum render texture size */
  93768. maxRenderTextureSize: number;
  93769. /** Maximum number of vertex attributes */
  93770. maxVertexAttribs: number;
  93771. /** Maximum number of varyings */
  93772. maxVaryingVectors: number;
  93773. /** Maximum number of uniforms per vertex shader */
  93774. maxVertexUniformVectors: number;
  93775. /** Maximum number of uniforms per fragment shader */
  93776. maxFragmentUniformVectors: number;
  93777. /** Defines if standard derivates (dx/dy) are supported */
  93778. standardDerivatives: boolean;
  93779. /** Defines if s3tc texture compression is supported */
  93780. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93781. /** Defines if pvrtc texture compression is supported */
  93782. pvrtc: any;
  93783. /** Defines if etc1 texture compression is supported */
  93784. etc1: any;
  93785. /** Defines if etc2 texture compression is supported */
  93786. etc2: any;
  93787. /** Defines if astc texture compression is supported */
  93788. astc: any;
  93789. /** Defines if float textures are supported */
  93790. textureFloat: boolean;
  93791. /** Defines if vertex array objects are supported */
  93792. vertexArrayObject: boolean;
  93793. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93794. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93795. /** Gets the maximum level of anisotropy supported */
  93796. maxAnisotropy: number;
  93797. /** Defines if instancing is supported */
  93798. instancedArrays: boolean;
  93799. /** Defines if 32 bits indices are supported */
  93800. uintIndices: boolean;
  93801. /** Defines if high precision shaders are supported */
  93802. highPrecisionShaderSupported: boolean;
  93803. /** Defines if depth reading in the fragment shader is supported */
  93804. fragmentDepthSupported: boolean;
  93805. /** Defines if float texture linear filtering is supported*/
  93806. textureFloatLinearFiltering: boolean;
  93807. /** Defines if rendering to float textures is supported */
  93808. textureFloatRender: boolean;
  93809. /** Defines if half float textures are supported*/
  93810. textureHalfFloat: boolean;
  93811. /** Defines if half float texture linear filtering is supported*/
  93812. textureHalfFloatLinearFiltering: boolean;
  93813. /** Defines if rendering to half float textures is supported */
  93814. textureHalfFloatRender: boolean;
  93815. /** Defines if textureLOD shader command is supported */
  93816. textureLOD: boolean;
  93817. /** Defines if draw buffers extension is supported */
  93818. drawBuffersExtension: boolean;
  93819. /** Defines if depth textures are supported */
  93820. depthTextureExtension: boolean;
  93821. /** Defines if float color buffer are supported */
  93822. colorBufferFloat: boolean;
  93823. /** Gets disjoint timer query extension (null if not supported) */
  93824. timerQuery: EXT_disjoint_timer_query;
  93825. /** Defines if timestamp can be used with timer query */
  93826. canUseTimestampForTimerQuery: boolean;
  93827. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93828. multiview: any;
  93829. /** Function used to let the system compiles shaders in background */
  93830. parallelShaderCompile: {
  93831. COMPLETION_STATUS_KHR: number;
  93832. };
  93833. /** Max number of texture samples for MSAA */
  93834. maxMSAASamples: number;
  93835. }
  93836. /** Interface defining initialization parameters for Engine class */
  93837. export interface EngineOptions extends WebGLContextAttributes {
  93838. /**
  93839. * Defines if the engine should no exceed a specified device ratio
  93840. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93841. */
  93842. limitDeviceRatio?: number;
  93843. /**
  93844. * Defines if webvr should be enabled automatically
  93845. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93846. */
  93847. autoEnableWebVR?: boolean;
  93848. /**
  93849. * Defines if webgl2 should be turned off even if supported
  93850. * @see http://doc.babylonjs.com/features/webgl2
  93851. */
  93852. disableWebGL2Support?: boolean;
  93853. /**
  93854. * Defines if webaudio should be initialized as well
  93855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93856. */
  93857. audioEngine?: boolean;
  93858. /**
  93859. * Defines if animations should run using a deterministic lock step
  93860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93861. */
  93862. deterministicLockstep?: boolean;
  93863. /** Defines the maximum steps to use with deterministic lock step mode */
  93864. lockstepMaxSteps?: number;
  93865. /**
  93866. * Defines that engine should ignore context lost events
  93867. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93868. */
  93869. doNotHandleContextLost?: boolean;
  93870. /**
  93871. * Defines that engine should ignore modifying touch action attribute and style
  93872. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93873. */
  93874. doNotHandleTouchAction?: boolean;
  93875. /**
  93876. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93877. */
  93878. useHighPrecisionFloats?: boolean;
  93879. }
  93880. /**
  93881. * Defines the interface used by display changed events
  93882. */
  93883. export interface IDisplayChangedEventArgs {
  93884. /** Gets the vrDisplay object (if any) */
  93885. vrDisplay: Nullable<any>;
  93886. /** Gets a boolean indicating if webVR is supported */
  93887. vrSupported: boolean;
  93888. }
  93889. /**
  93890. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93891. */
  93892. export class Engine {
  93893. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93894. static ExceptionList: ({
  93895. key: string;
  93896. capture: string;
  93897. captureConstraint: number;
  93898. targets: string[];
  93899. } | {
  93900. key: string;
  93901. capture: null;
  93902. captureConstraint: null;
  93903. targets: string[];
  93904. })[];
  93905. /** Gets the list of created engines */
  93906. static readonly Instances: Engine[];
  93907. /**
  93908. * Gets the latest created engine
  93909. */
  93910. static readonly LastCreatedEngine: Nullable<Engine>;
  93911. /**
  93912. * Gets the latest created scene
  93913. */
  93914. static readonly LastCreatedScene: Nullable<Scene>;
  93915. /**
  93916. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93917. * @param flag defines which part of the materials must be marked as dirty
  93918. * @param predicate defines a predicate used to filter which materials should be affected
  93919. */
  93920. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93921. /** @hidden */
  93922. static _TextureLoaders: IInternalTextureLoader[];
  93923. /** Defines that alpha blending is disabled */
  93924. static readonly ALPHA_DISABLE: number;
  93925. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93926. static readonly ALPHA_ADD: number;
  93927. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93928. static readonly ALPHA_COMBINE: number;
  93929. /** Defines that alpha blending to DEST - SRC * DEST */
  93930. static readonly ALPHA_SUBTRACT: number;
  93931. /** Defines that alpha blending to SRC * DEST */
  93932. static readonly ALPHA_MULTIPLY: number;
  93933. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93934. static readonly ALPHA_MAXIMIZED: number;
  93935. /** Defines that alpha blending to SRC + DEST */
  93936. static readonly ALPHA_ONEONE: number;
  93937. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93938. static readonly ALPHA_PREMULTIPLIED: number;
  93939. /**
  93940. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93941. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93942. */
  93943. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93944. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93945. static readonly ALPHA_INTERPOLATE: number;
  93946. /**
  93947. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93948. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93949. */
  93950. static readonly ALPHA_SCREENMODE: number;
  93951. /** Defines that the ressource is not delayed*/
  93952. static readonly DELAYLOADSTATE_NONE: number;
  93953. /** Defines that the ressource was successfully delay loaded */
  93954. static readonly DELAYLOADSTATE_LOADED: number;
  93955. /** Defines that the ressource is currently delay loading */
  93956. static readonly DELAYLOADSTATE_LOADING: number;
  93957. /** Defines that the ressource is delayed and has not started loading */
  93958. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93959. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93960. static readonly NEVER: number;
  93961. /** 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 */
  93962. static readonly ALWAYS: number;
  93963. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93964. static readonly LESS: number;
  93965. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93966. static readonly EQUAL: number;
  93967. /** 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 */
  93968. static readonly LEQUAL: number;
  93969. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93970. static readonly GREATER: number;
  93971. /** 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 */
  93972. static readonly GEQUAL: number;
  93973. /** 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 */
  93974. static readonly NOTEQUAL: number;
  93975. /** Passed to stencilOperation to specify that stencil value must be kept */
  93976. static readonly KEEP: number;
  93977. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93978. static readonly REPLACE: number;
  93979. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93980. static readonly INCR: number;
  93981. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93982. static readonly DECR: number;
  93983. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93984. static readonly INVERT: number;
  93985. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93986. static readonly INCR_WRAP: number;
  93987. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93988. static readonly DECR_WRAP: number;
  93989. /** Texture is not repeating outside of 0..1 UVs */
  93990. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93991. /** Texture is repeating outside of 0..1 UVs */
  93992. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93993. /** Texture is repeating and mirrored */
  93994. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93995. /** ALPHA */
  93996. static readonly TEXTUREFORMAT_ALPHA: number;
  93997. /** LUMINANCE */
  93998. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93999. /** LUMINANCE_ALPHA */
  94000. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94001. /** RGB */
  94002. static readonly TEXTUREFORMAT_RGB: number;
  94003. /** RGBA */
  94004. static readonly TEXTUREFORMAT_RGBA: number;
  94005. /** RED */
  94006. static readonly TEXTUREFORMAT_RED: number;
  94007. /** RED (2nd reference) */
  94008. static readonly TEXTUREFORMAT_R: number;
  94009. /** RG */
  94010. static readonly TEXTUREFORMAT_RG: number;
  94011. /** RED_INTEGER */
  94012. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94013. /** RED_INTEGER (2nd reference) */
  94014. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94015. /** RG_INTEGER */
  94016. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94017. /** RGB_INTEGER */
  94018. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94019. /** RGBA_INTEGER */
  94020. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94021. /** UNSIGNED_BYTE */
  94022. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94023. /** UNSIGNED_BYTE (2nd reference) */
  94024. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94025. /** FLOAT */
  94026. static readonly TEXTURETYPE_FLOAT: number;
  94027. /** HALF_FLOAT */
  94028. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94029. /** BYTE */
  94030. static readonly TEXTURETYPE_BYTE: number;
  94031. /** SHORT */
  94032. static readonly TEXTURETYPE_SHORT: number;
  94033. /** UNSIGNED_SHORT */
  94034. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94035. /** INT */
  94036. static readonly TEXTURETYPE_INT: number;
  94037. /** UNSIGNED_INT */
  94038. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94039. /** UNSIGNED_SHORT_4_4_4_4 */
  94040. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94041. /** UNSIGNED_SHORT_5_5_5_1 */
  94042. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94043. /** UNSIGNED_SHORT_5_6_5 */
  94044. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94045. /** UNSIGNED_INT_2_10_10_10_REV */
  94046. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94047. /** UNSIGNED_INT_24_8 */
  94048. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94049. /** UNSIGNED_INT_10F_11F_11F_REV */
  94050. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94051. /** UNSIGNED_INT_5_9_9_9_REV */
  94052. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94053. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94054. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94055. /** nearest is mag = nearest and min = nearest and mip = linear */
  94056. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94057. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94058. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94059. /** Trilinear is mag = linear and min = linear and mip = linear */
  94060. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94061. /** nearest is mag = nearest and min = nearest and mip = linear */
  94062. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94063. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94064. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94065. /** Trilinear is mag = linear and min = linear and mip = linear */
  94066. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94067. /** mag = nearest and min = nearest and mip = nearest */
  94068. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94069. /** mag = nearest and min = linear and mip = nearest */
  94070. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94071. /** mag = nearest and min = linear and mip = linear */
  94072. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94073. /** mag = nearest and min = linear and mip = none */
  94074. static readonly TEXTURE_NEAREST_LINEAR: number;
  94075. /** mag = nearest and min = nearest and mip = none */
  94076. static readonly TEXTURE_NEAREST_NEAREST: number;
  94077. /** mag = linear and min = nearest and mip = nearest */
  94078. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94079. /** mag = linear and min = nearest and mip = linear */
  94080. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94081. /** mag = linear and min = linear and mip = none */
  94082. static readonly TEXTURE_LINEAR_LINEAR: number;
  94083. /** mag = linear and min = nearest and mip = none */
  94084. static readonly TEXTURE_LINEAR_NEAREST: number;
  94085. /** Explicit coordinates mode */
  94086. static readonly TEXTURE_EXPLICIT_MODE: number;
  94087. /** Spherical coordinates mode */
  94088. static readonly TEXTURE_SPHERICAL_MODE: number;
  94089. /** Planar coordinates mode */
  94090. static readonly TEXTURE_PLANAR_MODE: number;
  94091. /** Cubic coordinates mode */
  94092. static readonly TEXTURE_CUBIC_MODE: number;
  94093. /** Projection coordinates mode */
  94094. static readonly TEXTURE_PROJECTION_MODE: number;
  94095. /** Skybox coordinates mode */
  94096. static readonly TEXTURE_SKYBOX_MODE: number;
  94097. /** Inverse Cubic coordinates mode */
  94098. static readonly TEXTURE_INVCUBIC_MODE: number;
  94099. /** Equirectangular coordinates mode */
  94100. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94101. /** Equirectangular Fixed coordinates mode */
  94102. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94103. /** Equirectangular Fixed Mirrored coordinates mode */
  94104. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94105. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94106. static readonly SCALEMODE_FLOOR: number;
  94107. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94108. static readonly SCALEMODE_NEAREST: number;
  94109. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94110. static readonly SCALEMODE_CEILING: number;
  94111. /**
  94112. * Returns the current npm package of the sdk
  94113. */
  94114. static readonly NpmPackage: string;
  94115. /**
  94116. * Returns the current version of the framework
  94117. */
  94118. static readonly Version: string;
  94119. /**
  94120. * Returns a string describing the current engine
  94121. */
  94122. readonly description: string;
  94123. /**
  94124. * Gets or sets the epsilon value used by collision engine
  94125. */
  94126. static CollisionsEpsilon: number;
  94127. /**
  94128. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94129. */
  94130. static ShadersRepository: string;
  94131. /**
  94132. * Method called to create the default loading screen.
  94133. * This can be overriden in your own app.
  94134. * @param canvas The rendering canvas element
  94135. * @returns The loading screen
  94136. */
  94137. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94138. /**
  94139. * Method called to create the default rescale post process on each engine.
  94140. */
  94141. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94142. /** @hidden */
  94143. _shaderProcessor: IShaderProcessor;
  94144. /**
  94145. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94146. */
  94147. forcePOTTextures: boolean;
  94148. /**
  94149. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94150. */
  94151. isFullscreen: boolean;
  94152. /**
  94153. * Gets a boolean indicating if the pointer is currently locked
  94154. */
  94155. isPointerLock: boolean;
  94156. /**
  94157. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94158. */
  94159. cullBackFaces: boolean;
  94160. /**
  94161. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94162. */
  94163. renderEvenInBackground: boolean;
  94164. /**
  94165. * Gets or sets a boolean indicating that cache can be kept between frames
  94166. */
  94167. preventCacheWipeBetweenFrames: boolean;
  94168. /**
  94169. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94170. **/
  94171. enableOfflineSupport: boolean;
  94172. /**
  94173. * 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)
  94174. **/
  94175. disableManifestCheck: boolean;
  94176. /**
  94177. * Gets the list of created scenes
  94178. */
  94179. scenes: Scene[];
  94180. /**
  94181. * Event raised when a new scene is created
  94182. */
  94183. onNewSceneAddedObservable: Observable<Scene>;
  94184. /**
  94185. * Gets the list of created postprocesses
  94186. */
  94187. postProcesses: PostProcess[];
  94188. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94189. validateShaderPrograms: boolean;
  94190. /**
  94191. * Observable event triggered each time the rendering canvas is resized
  94192. */
  94193. onResizeObservable: Observable<Engine>;
  94194. /**
  94195. * Observable event triggered each time the canvas loses focus
  94196. */
  94197. onCanvasBlurObservable: Observable<Engine>;
  94198. /**
  94199. * Observable event triggered each time the canvas gains focus
  94200. */
  94201. onCanvasFocusObservable: Observable<Engine>;
  94202. /**
  94203. * Observable event triggered each time the canvas receives pointerout event
  94204. */
  94205. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94206. /**
  94207. * Observable event triggered before each texture is initialized
  94208. */
  94209. onBeforeTextureInitObservable: Observable<Texture>;
  94210. /**
  94211. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94212. */
  94213. disableUniformBuffers: boolean;
  94214. /** @hidden */
  94215. _uniformBuffers: UniformBuffer[];
  94216. /**
  94217. * Gets a boolean indicating that the engine supports uniform buffers
  94218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94219. */
  94220. readonly supportsUniformBuffers: boolean;
  94221. /**
  94222. * Observable raised when the engine begins a new frame
  94223. */
  94224. onBeginFrameObservable: Observable<Engine>;
  94225. /**
  94226. * If set, will be used to request the next animation frame for the render loop
  94227. */
  94228. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94229. /**
  94230. * Observable raised when the engine ends the current frame
  94231. */
  94232. onEndFrameObservable: Observable<Engine>;
  94233. /**
  94234. * Observable raised when the engine is about to compile a shader
  94235. */
  94236. onBeforeShaderCompilationObservable: Observable<Engine>;
  94237. /**
  94238. * Observable raised when the engine has jsut compiled a shader
  94239. */
  94240. onAfterShaderCompilationObservable: Observable<Engine>;
  94241. /** @hidden */
  94242. _gl: WebGLRenderingContext;
  94243. private _renderingCanvas;
  94244. private _windowIsBackground;
  94245. private _webGLVersion;
  94246. protected _highPrecisionShadersAllowed: boolean;
  94247. /** @hidden */
  94248. readonly _shouldUseHighPrecisionShader: boolean;
  94249. /**
  94250. * Gets a boolean indicating that only power of 2 textures are supported
  94251. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94252. */
  94253. readonly needPOTTextures: boolean;
  94254. /** @hidden */
  94255. _badOS: boolean;
  94256. /** @hidden */
  94257. _badDesktopOS: boolean;
  94258. /**
  94259. * Gets the audio engine
  94260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94261. * @ignorenaming
  94262. */
  94263. static audioEngine: IAudioEngine;
  94264. /**
  94265. * Default AudioEngine factory responsible of creating the Audio Engine.
  94266. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94267. */
  94268. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94269. /**
  94270. * Default offline support factory responsible of creating a tool used to store data locally.
  94271. * By default, this will create a Database object if the workload has been embedded.
  94272. */
  94273. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94274. private _onFocus;
  94275. private _onBlur;
  94276. private _onCanvasPointerOut;
  94277. private _onCanvasBlur;
  94278. private _onCanvasFocus;
  94279. private _onFullscreenChange;
  94280. private _onPointerLockChange;
  94281. private _hardwareScalingLevel;
  94282. /** @hidden */
  94283. _caps: EngineCapabilities;
  94284. private _pointerLockRequested;
  94285. private _isStencilEnable;
  94286. private _colorWrite;
  94287. private _loadingScreen;
  94288. /** @hidden */
  94289. _drawCalls: PerfCounter;
  94290. private _glVersion;
  94291. private _glRenderer;
  94292. private _glVendor;
  94293. private _videoTextureSupported;
  94294. private _renderingQueueLaunched;
  94295. private _activeRenderLoops;
  94296. private _deterministicLockstep;
  94297. private _lockstepMaxSteps;
  94298. /**
  94299. * Observable signaled when a context lost event is raised
  94300. */
  94301. onContextLostObservable: Observable<Engine>;
  94302. /**
  94303. * Observable signaled when a context restored event is raised
  94304. */
  94305. onContextRestoredObservable: Observable<Engine>;
  94306. private _onContextLost;
  94307. private _onContextRestored;
  94308. private _contextWasLost;
  94309. /** @hidden */
  94310. _doNotHandleContextLost: boolean;
  94311. /**
  94312. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94314. */
  94315. doNotHandleContextLost: boolean;
  94316. private _performanceMonitor;
  94317. private _fps;
  94318. private _deltaTime;
  94319. /**
  94320. * Turn this value on if you want to pause FPS computation when in background
  94321. */
  94322. disablePerformanceMonitorInBackground: boolean;
  94323. /**
  94324. * Gets the performance monitor attached to this engine
  94325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94326. */
  94327. readonly performanceMonitor: PerformanceMonitor;
  94328. /**
  94329. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94330. */
  94331. disableVertexArrayObjects: boolean;
  94332. /** @hidden */
  94333. protected _depthCullingState: _DepthCullingState;
  94334. /** @hidden */
  94335. protected _stencilState: _StencilState;
  94336. /** @hidden */
  94337. protected _alphaState: _AlphaState;
  94338. /** @hidden */
  94339. protected _alphaMode: number;
  94340. /** @hidden */
  94341. _internalTexturesCache: InternalTexture[];
  94342. /** @hidden */
  94343. protected _activeChannel: number;
  94344. private _currentTextureChannel;
  94345. /** @hidden */
  94346. protected _boundTexturesCache: {
  94347. [key: string]: Nullable<InternalTexture>;
  94348. };
  94349. /** @hidden */
  94350. protected _currentEffect: Nullable<Effect>;
  94351. /** @hidden */
  94352. protected _currentProgram: Nullable<WebGLProgram>;
  94353. private _compiledEffects;
  94354. private _vertexAttribArraysEnabled;
  94355. /** @hidden */
  94356. protected _cachedViewport: Nullable<IViewportLike>;
  94357. private _cachedVertexArrayObject;
  94358. /** @hidden */
  94359. protected _cachedVertexBuffers: any;
  94360. /** @hidden */
  94361. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94362. /** @hidden */
  94363. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94364. /** @hidden */
  94365. _currentRenderTarget: Nullable<InternalTexture>;
  94366. private _uintIndicesCurrentlySet;
  94367. private _currentBoundBuffer;
  94368. /** @hidden */
  94369. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94370. private _currentBufferPointers;
  94371. private _currentInstanceLocations;
  94372. private _currentInstanceBuffers;
  94373. private _textureUnits;
  94374. /** @hidden */
  94375. _workingCanvas: Nullable<HTMLCanvasElement>;
  94376. /** @hidden */
  94377. _workingContext: Nullable<CanvasRenderingContext2D>;
  94378. private _rescalePostProcess;
  94379. private _dummyFramebuffer;
  94380. private _externalData;
  94381. /** @hidden */
  94382. _bindedRenderFunction: any;
  94383. private _vaoRecordInProgress;
  94384. private _mustWipeVertexAttributes;
  94385. private _emptyTexture;
  94386. private _emptyCubeTexture;
  94387. private _emptyTexture3D;
  94388. /** @hidden */
  94389. _frameHandler: number;
  94390. private _nextFreeTextureSlots;
  94391. private _maxSimultaneousTextures;
  94392. private _activeRequests;
  94393. private _texturesSupported;
  94394. /** @hidden */
  94395. _textureFormatInUse: Nullable<string>;
  94396. /**
  94397. * Gets the list of texture formats supported
  94398. */
  94399. readonly texturesSupported: Array<string>;
  94400. /**
  94401. * Gets the list of texture formats in use
  94402. */
  94403. readonly textureFormatInUse: Nullable<string>;
  94404. /**
  94405. * Gets the current viewport
  94406. */
  94407. readonly currentViewport: Nullable<IViewportLike>;
  94408. /**
  94409. * Gets the default empty texture
  94410. */
  94411. readonly emptyTexture: InternalTexture;
  94412. /**
  94413. * Gets the default empty 3D texture
  94414. */
  94415. readonly emptyTexture3D: InternalTexture;
  94416. /**
  94417. * Gets the default empty cube texture
  94418. */
  94419. readonly emptyCubeTexture: InternalTexture;
  94420. /**
  94421. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94422. */
  94423. readonly premultipliedAlpha: boolean;
  94424. /**
  94425. * Creates a new engine
  94426. * @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
  94427. * @param antialias defines enable antialiasing (default: false)
  94428. * @param options defines further options to be sent to the getContext() function
  94429. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94430. */
  94431. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94432. /**
  94433. * Initializes a webVR display and starts listening to display change events
  94434. * The onVRDisplayChangedObservable will be notified upon these changes
  94435. * @returns The onVRDisplayChangedObservable
  94436. */
  94437. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94438. /** @hidden */
  94439. _prepareVRComponent(): void;
  94440. /** @hidden */
  94441. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94442. /** @hidden */
  94443. _submitVRFrame(): void;
  94444. /**
  94445. * Call this function to leave webVR mode
  94446. * Will do nothing if webVR is not supported or if there is no webVR device
  94447. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94448. */
  94449. disableVR(): void;
  94450. /**
  94451. * Gets a boolean indicating that the system is in VR mode and is presenting
  94452. * @returns true if VR mode is engaged
  94453. */
  94454. isVRPresenting(): boolean;
  94455. /** @hidden */
  94456. _requestVRFrame(): void;
  94457. private _disableTouchAction;
  94458. private _rebuildInternalTextures;
  94459. private _rebuildEffects;
  94460. /**
  94461. * Gets a boolean indicating if all created effects are ready
  94462. * @returns true if all effects are ready
  94463. */
  94464. areAllEffectsReady(): boolean;
  94465. private _rebuildBuffers;
  94466. private _initGLContext;
  94467. /**
  94468. * Gets version of the current webGL context
  94469. */
  94470. readonly webGLVersion: number;
  94471. /**
  94472. * Gets a string idenfifying the name of the class
  94473. * @returns "Engine" string
  94474. */
  94475. getClassName(): string;
  94476. /**
  94477. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94478. */
  94479. readonly isStencilEnable: boolean;
  94480. /** @hidden */
  94481. _prepareWorkingCanvas(): void;
  94482. /**
  94483. * Reset the texture cache to empty state
  94484. */
  94485. resetTextureCache(): void;
  94486. /**
  94487. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94489. * @returns true if engine is in deterministic lock step mode
  94490. */
  94491. isDeterministicLockStep(): boolean;
  94492. /**
  94493. * Gets the max steps when engine is running in deterministic lock step
  94494. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94495. * @returns the max steps
  94496. */
  94497. getLockstepMaxSteps(): number;
  94498. /**
  94499. * Gets an object containing information about the current webGL context
  94500. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94501. */
  94502. getGlInfo(): {
  94503. vendor: string;
  94504. renderer: string;
  94505. version: string;
  94506. };
  94507. /**
  94508. * Gets current aspect ratio
  94509. * @param viewportOwner defines the camera to use to get the aspect ratio
  94510. * @param useScreen defines if screen size must be used (or the current render target if any)
  94511. * @returns a number defining the aspect ratio
  94512. */
  94513. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94514. /**
  94515. * Gets current screen aspect ratio
  94516. * @returns a number defining the aspect ratio
  94517. */
  94518. getScreenAspectRatio(): number;
  94519. /**
  94520. * Gets the current render width
  94521. * @param useScreen defines if screen size must be used (or the current render target if any)
  94522. * @returns a number defining the current render width
  94523. */
  94524. getRenderWidth(useScreen?: boolean): number;
  94525. /**
  94526. * Gets the current render height
  94527. * @param useScreen defines if screen size must be used (or the current render target if any)
  94528. * @returns a number defining the current render height
  94529. */
  94530. getRenderHeight(useScreen?: boolean): number;
  94531. /**
  94532. * Gets the HTML canvas attached with the current webGL context
  94533. * @returns a HTML canvas
  94534. */
  94535. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94536. /**
  94537. * Gets host window
  94538. * @returns the host window object
  94539. */
  94540. getHostWindow(): Window;
  94541. /**
  94542. * Gets host document
  94543. * @returns the host document object
  94544. */
  94545. getHostDocument(): Document;
  94546. /**
  94547. * Gets the client rect of the HTML canvas attached with the current webGL context
  94548. * @returns a client rectanglee
  94549. */
  94550. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94551. /**
  94552. * Defines the hardware scaling level.
  94553. * By default the hardware scaling level is computed from the window device ratio.
  94554. * 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.
  94555. * @param level defines the level to use
  94556. */
  94557. setHardwareScalingLevel(level: number): void;
  94558. /**
  94559. * Gets the current hardware scaling level.
  94560. * By default the hardware scaling level is computed from the window device ratio.
  94561. * 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.
  94562. * @returns a number indicating the current hardware scaling level
  94563. */
  94564. getHardwareScalingLevel(): number;
  94565. /**
  94566. * Gets the list of loaded textures
  94567. * @returns an array containing all loaded textures
  94568. */
  94569. getLoadedTexturesCache(): InternalTexture[];
  94570. /**
  94571. * Gets the object containing all engine capabilities
  94572. * @returns the EngineCapabilities object
  94573. */
  94574. getCaps(): EngineCapabilities;
  94575. /**
  94576. * Gets the current depth function
  94577. * @returns a number defining the depth function
  94578. */
  94579. getDepthFunction(): Nullable<number>;
  94580. /**
  94581. * Sets the current depth function
  94582. * @param depthFunc defines the function to use
  94583. */
  94584. setDepthFunction(depthFunc: number): void;
  94585. /**
  94586. * Sets the current depth function to GREATER
  94587. */
  94588. setDepthFunctionToGreater(): void;
  94589. /**
  94590. * Sets the current depth function to GEQUAL
  94591. */
  94592. setDepthFunctionToGreaterOrEqual(): void;
  94593. /**
  94594. * Sets the current depth function to LESS
  94595. */
  94596. setDepthFunctionToLess(): void;
  94597. private _cachedStencilBuffer;
  94598. private _cachedStencilFunction;
  94599. private _cachedStencilMask;
  94600. private _cachedStencilOperationPass;
  94601. private _cachedStencilOperationFail;
  94602. private _cachedStencilOperationDepthFail;
  94603. private _cachedStencilReference;
  94604. /**
  94605. * Caches the the state of the stencil buffer
  94606. */
  94607. cacheStencilState(): void;
  94608. /**
  94609. * Restores the state of the stencil buffer
  94610. */
  94611. restoreStencilState(): void;
  94612. /**
  94613. * Sets the current depth function to LEQUAL
  94614. */
  94615. setDepthFunctionToLessOrEqual(): void;
  94616. /**
  94617. * Gets a boolean indicating if stencil buffer is enabled
  94618. * @returns the current stencil buffer state
  94619. */
  94620. getStencilBuffer(): boolean;
  94621. /**
  94622. * Enable or disable the stencil buffer
  94623. * @param enable defines if the stencil buffer must be enabled or disabled
  94624. */
  94625. setStencilBuffer(enable: boolean): void;
  94626. /**
  94627. * Gets the current stencil mask
  94628. * @returns a number defining the new stencil mask to use
  94629. */
  94630. getStencilMask(): number;
  94631. /**
  94632. * Sets the current stencil mask
  94633. * @param mask defines the new stencil mask to use
  94634. */
  94635. setStencilMask(mask: number): void;
  94636. /**
  94637. * Gets the current stencil function
  94638. * @returns a number defining the stencil function to use
  94639. */
  94640. getStencilFunction(): number;
  94641. /**
  94642. * Gets the current stencil reference value
  94643. * @returns a number defining the stencil reference value to use
  94644. */
  94645. getStencilFunctionReference(): number;
  94646. /**
  94647. * Gets the current stencil mask
  94648. * @returns a number defining the stencil mask to use
  94649. */
  94650. getStencilFunctionMask(): number;
  94651. /**
  94652. * Sets the current stencil function
  94653. * @param stencilFunc defines the new stencil function to use
  94654. */
  94655. setStencilFunction(stencilFunc: number): void;
  94656. /**
  94657. * Sets the current stencil reference
  94658. * @param reference defines the new stencil reference to use
  94659. */
  94660. setStencilFunctionReference(reference: number): void;
  94661. /**
  94662. * Sets the current stencil mask
  94663. * @param mask defines the new stencil mask to use
  94664. */
  94665. setStencilFunctionMask(mask: number): void;
  94666. /**
  94667. * Gets the current stencil operation when stencil fails
  94668. * @returns a number defining stencil operation to use when stencil fails
  94669. */
  94670. getStencilOperationFail(): number;
  94671. /**
  94672. * Gets the current stencil operation when depth fails
  94673. * @returns a number defining stencil operation to use when depth fails
  94674. */
  94675. getStencilOperationDepthFail(): number;
  94676. /**
  94677. * Gets the current stencil operation when stencil passes
  94678. * @returns a number defining stencil operation to use when stencil passes
  94679. */
  94680. getStencilOperationPass(): number;
  94681. /**
  94682. * Sets the stencil operation to use when stencil fails
  94683. * @param operation defines the stencil operation to use when stencil fails
  94684. */
  94685. setStencilOperationFail(operation: number): void;
  94686. /**
  94687. * Sets the stencil operation to use when depth fails
  94688. * @param operation defines the stencil operation to use when depth fails
  94689. */
  94690. setStencilOperationDepthFail(operation: number): void;
  94691. /**
  94692. * Sets the stencil operation to use when stencil passes
  94693. * @param operation defines the stencil operation to use when stencil passes
  94694. */
  94695. setStencilOperationPass(operation: number): void;
  94696. /**
  94697. * Sets a boolean indicating if the dithering state is enabled or disabled
  94698. * @param value defines the dithering state
  94699. */
  94700. setDitheringState(value: boolean): void;
  94701. /**
  94702. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94703. * @param value defines the rasterizer state
  94704. */
  94705. setRasterizerState(value: boolean): void;
  94706. /**
  94707. * stop executing a render loop function and remove it from the execution array
  94708. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94709. */
  94710. stopRenderLoop(renderFunction?: () => void): void;
  94711. /** @hidden */
  94712. _renderLoop(): void;
  94713. /**
  94714. * Register and execute a render loop. The engine can have more than one render function
  94715. * @param renderFunction defines the function to continuously execute
  94716. */
  94717. runRenderLoop(renderFunction: () => void): void;
  94718. /**
  94719. * Toggle full screen mode
  94720. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94721. */
  94722. switchFullscreen(requestPointerLock: boolean): void;
  94723. /**
  94724. * Enters full screen mode
  94725. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94726. */
  94727. enterFullscreen(requestPointerLock: boolean): void;
  94728. /**
  94729. * Exits full screen mode
  94730. */
  94731. exitFullscreen(): void;
  94732. /**
  94733. * Enters Pointerlock mode
  94734. */
  94735. enterPointerlock(): void;
  94736. /**
  94737. * Exits Pointerlock mode
  94738. */
  94739. exitPointerlock(): void;
  94740. /**
  94741. * Clear the current render buffer or the current render target (if any is set up)
  94742. * @param color defines the color to use
  94743. * @param backBuffer defines if the back buffer must be cleared
  94744. * @param depth defines if the depth buffer must be cleared
  94745. * @param stencil defines if the stencil buffer must be cleared
  94746. */
  94747. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94748. /**
  94749. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94750. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94751. * @param y defines the y-coordinate of the corner of the clear rectangle
  94752. * @param width defines the width of the clear rectangle
  94753. * @param height defines the height of the clear rectangle
  94754. * @param clearColor defines the clear color
  94755. */
  94756. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94757. /**
  94758. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94759. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94760. * @param y defines the y-coordinate of the corner of the clear rectangle
  94761. * @param width defines the width of the clear rectangle
  94762. * @param height defines the height of the clear rectangle
  94763. */
  94764. enableScissor(x: number, y: number, width: number, height: number): void;
  94765. /**
  94766. * Disable previously set scissor test rectangle
  94767. */
  94768. disableScissor(): void;
  94769. private _viewportCached;
  94770. /** @hidden */
  94771. _viewport(x: number, y: number, width: number, height: number): void;
  94772. /**
  94773. * Set the WebGL's viewport
  94774. * @param viewport defines the viewport element to be used
  94775. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94776. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94777. */
  94778. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94779. /**
  94780. * Directly set the WebGL Viewport
  94781. * @param x defines the x coordinate of the viewport (in screen space)
  94782. * @param y defines the y coordinate of the viewport (in screen space)
  94783. * @param width defines the width of the viewport (in screen space)
  94784. * @param height defines the height of the viewport (in screen space)
  94785. * @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
  94786. */
  94787. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94788. /**
  94789. * Begin a new frame
  94790. */
  94791. beginFrame(): void;
  94792. /**
  94793. * Enf the current frame
  94794. */
  94795. endFrame(): void;
  94796. /**
  94797. * Resize the view according to the canvas' size
  94798. */
  94799. resize(): void;
  94800. /**
  94801. * Force a specific size of the canvas
  94802. * @param width defines the new canvas' width
  94803. * @param height defines the new canvas' height
  94804. */
  94805. setSize(width: number, height: number): void;
  94806. /**
  94807. * Binds the frame buffer to the specified texture.
  94808. * @param texture The texture to render to or null for the default canvas
  94809. * @param faceIndex The face of the texture to render to in case of cube texture
  94810. * @param requiredWidth The width of the target to render to
  94811. * @param requiredHeight The height of the target to render to
  94812. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94813. * @param depthStencilTexture The depth stencil texture to use to render
  94814. * @param lodLevel defines le lod level to bind to the frame buffer
  94815. */
  94816. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94817. /** @hidden */
  94818. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94819. /**
  94820. * Unbind the current render target texture from the webGL context
  94821. * @param texture defines the render target texture to unbind
  94822. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94823. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94824. */
  94825. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94826. /**
  94827. * Force the mipmap generation for the given render target texture
  94828. * @param texture defines the render target texture to use
  94829. */
  94830. generateMipMapsForCubemap(texture: InternalTexture): void;
  94831. /**
  94832. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94833. */
  94834. flushFramebuffer(): void;
  94835. /**
  94836. * Unbind the current render target and bind the default framebuffer
  94837. */
  94838. restoreDefaultFramebuffer(): void;
  94839. /**
  94840. * Create an uniform buffer
  94841. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94842. * @param elements defines the content of the uniform buffer
  94843. * @returns the webGL uniform buffer
  94844. */
  94845. createUniformBuffer(elements: FloatArray): DataBuffer;
  94846. /**
  94847. * Create a dynamic uniform buffer
  94848. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94849. * @param elements defines the content of the uniform buffer
  94850. * @returns the webGL uniform buffer
  94851. */
  94852. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94853. /**
  94854. * Update an existing uniform buffer
  94855. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94856. * @param uniformBuffer defines the target uniform buffer
  94857. * @param elements defines the content to update
  94858. * @param offset defines the offset in the uniform buffer where update should start
  94859. * @param count defines the size of the data to update
  94860. */
  94861. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94862. private _resetVertexBufferBinding;
  94863. /**
  94864. * Creates a vertex buffer
  94865. * @param data the data for the vertex buffer
  94866. * @returns the new WebGL static buffer
  94867. */
  94868. createVertexBuffer(data: DataArray): DataBuffer;
  94869. /**
  94870. * Creates a dynamic vertex buffer
  94871. * @param data the data for the dynamic vertex buffer
  94872. * @returns the new WebGL dynamic buffer
  94873. */
  94874. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94875. /**
  94876. * Update a dynamic index buffer
  94877. * @param indexBuffer defines the target index buffer
  94878. * @param indices defines the data to update
  94879. * @param offset defines the offset in the target index buffer where update should start
  94880. */
  94881. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94882. /**
  94883. * Updates a dynamic vertex buffer.
  94884. * @param vertexBuffer the vertex buffer to update
  94885. * @param data the data used to update the vertex buffer
  94886. * @param byteOffset the byte offset of the data
  94887. * @param byteLength the byte length of the data
  94888. */
  94889. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94890. private _resetIndexBufferBinding;
  94891. /**
  94892. * Creates a new index buffer
  94893. * @param indices defines the content of the index buffer
  94894. * @param updatable defines if the index buffer must be updatable
  94895. * @returns a new webGL buffer
  94896. */
  94897. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94898. /**
  94899. * Bind a webGL buffer to the webGL context
  94900. * @param buffer defines the buffer to bind
  94901. */
  94902. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94903. /**
  94904. * Bind an uniform buffer to the current webGL context
  94905. * @param buffer defines the buffer to bind
  94906. */
  94907. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94908. /**
  94909. * Bind a buffer to the current webGL context at a given location
  94910. * @param buffer defines the buffer to bind
  94911. * @param location defines the index where to bind the buffer
  94912. */
  94913. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94914. /**
  94915. * Bind a specific block at a given index in a specific shader program
  94916. * @param pipelineContext defines the pipeline context to use
  94917. * @param blockName defines the block name
  94918. * @param index defines the index where to bind the block
  94919. */
  94920. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94921. private bindIndexBuffer;
  94922. private bindBuffer;
  94923. /**
  94924. * update the bound buffer with the given data
  94925. * @param data defines the data to update
  94926. */
  94927. updateArrayBuffer(data: Float32Array): void;
  94928. private _vertexAttribPointer;
  94929. private _bindIndexBufferWithCache;
  94930. private _bindVertexBuffersAttributes;
  94931. /**
  94932. * Records a vertex array object
  94933. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94934. * @param vertexBuffers defines the list of vertex buffers to store
  94935. * @param indexBuffer defines the index buffer to store
  94936. * @param effect defines the effect to store
  94937. * @returns the new vertex array object
  94938. */
  94939. recordVertexArrayObject(vertexBuffers: {
  94940. [key: string]: VertexBuffer;
  94941. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94942. /**
  94943. * Bind a specific vertex array object
  94944. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94945. * @param vertexArrayObject defines the vertex array object to bind
  94946. * @param indexBuffer defines the index buffer to bind
  94947. */
  94948. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94949. /**
  94950. * Bind webGl buffers directly to the webGL context
  94951. * @param vertexBuffer defines the vertex buffer to bind
  94952. * @param indexBuffer defines the index buffer to bind
  94953. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94954. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94955. * @param effect defines the effect associated with the vertex buffer
  94956. */
  94957. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94958. private _unbindVertexArrayObject;
  94959. /**
  94960. * Bind a list of vertex buffers to the webGL context
  94961. * @param vertexBuffers defines the list of vertex buffers to bind
  94962. * @param indexBuffer defines the index buffer to bind
  94963. * @param effect defines the effect associated with the vertex buffers
  94964. */
  94965. bindBuffers(vertexBuffers: {
  94966. [key: string]: Nullable<VertexBuffer>;
  94967. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94968. /**
  94969. * Unbind all instance attributes
  94970. */
  94971. unbindInstanceAttributes(): void;
  94972. /**
  94973. * Release and free the memory of a vertex array object
  94974. * @param vao defines the vertex array object to delete
  94975. */
  94976. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94977. /** @hidden */
  94978. _releaseBuffer(buffer: DataBuffer): boolean;
  94979. /**
  94980. * Creates a webGL buffer to use with instanciation
  94981. * @param capacity defines the size of the buffer
  94982. * @returns the webGL buffer
  94983. */
  94984. createInstancesBuffer(capacity: number): DataBuffer;
  94985. /**
  94986. * Delete a webGL buffer used with instanciation
  94987. * @param buffer defines the webGL buffer to delete
  94988. */
  94989. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94990. /**
  94991. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94992. * @param instancesBuffer defines the webGL buffer to update and bind
  94993. * @param data defines the data to store in the buffer
  94994. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94995. */
  94996. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94997. /**
  94998. * Apply all cached states (depth, culling, stencil and alpha)
  94999. */
  95000. applyStates(): void;
  95001. /**
  95002. * Send a draw order
  95003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95004. * @param indexStart defines the starting index
  95005. * @param indexCount defines the number of index to draw
  95006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95007. */
  95008. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95009. /**
  95010. * Draw a list of points
  95011. * @param verticesStart defines the index of first vertex to draw
  95012. * @param verticesCount defines the count of vertices to draw
  95013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95014. */
  95015. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95016. /**
  95017. * Draw a list of unindexed primitives
  95018. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95019. * @param verticesStart defines the index of first vertex to draw
  95020. * @param verticesCount defines the count of vertices to draw
  95021. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95022. */
  95023. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95024. /**
  95025. * Draw a list of indexed primitives
  95026. * @param fillMode defines the primitive to use
  95027. * @param indexStart defines the starting index
  95028. * @param indexCount defines the number of index to draw
  95029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95030. */
  95031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95032. /**
  95033. * Draw a list of unindexed primitives
  95034. * @param fillMode defines the primitive to use
  95035. * @param verticesStart defines the index of first vertex to draw
  95036. * @param verticesCount defines the count of vertices to draw
  95037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95038. */
  95039. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95040. private _drawMode;
  95041. /** @hidden */
  95042. _releaseEffect(effect: Effect): void;
  95043. /** @hidden */
  95044. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95045. /**
  95046. * Create a new effect (used to store vertex/fragment shaders)
  95047. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95048. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95049. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95050. * @param samplers defines an array of string used to represent textures
  95051. * @param defines defines the string containing the defines to use to compile the shaders
  95052. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95053. * @param onCompiled defines a function to call when the effect creation is successful
  95054. * @param onError defines a function to call when the effect creation has failed
  95055. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95056. * @returns the new Effect
  95057. */
  95058. 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;
  95059. private _compileShader;
  95060. private _compileRawShader;
  95061. /**
  95062. * Directly creates a webGL program
  95063. * @param pipelineContext defines the pipeline context to attach to
  95064. * @param vertexCode defines the vertex shader code to use
  95065. * @param fragmentCode defines the fragment shader code to use
  95066. * @param context defines the webGL context to use (if not set, the current one will be used)
  95067. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95068. * @returns the new webGL program
  95069. */
  95070. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95071. /**
  95072. * Creates a webGL program
  95073. * @param pipelineContext defines the pipeline context to attach to
  95074. * @param vertexCode defines the vertex shader code to use
  95075. * @param fragmentCode defines the fragment shader code to use
  95076. * @param defines defines the string containing the defines to use to compile the shaders
  95077. * @param context defines the webGL context to use (if not set, the current one will be used)
  95078. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95079. * @returns the new webGL program
  95080. */
  95081. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95082. /**
  95083. * Creates a new pipeline context
  95084. * @returns the new pipeline
  95085. */
  95086. createPipelineContext(): WebGLPipelineContext;
  95087. private _createShaderProgram;
  95088. private _finalizePipelineContext;
  95089. /** @hidden */
  95090. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95091. /** @hidden */
  95092. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95093. /** @hidden */
  95094. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95095. /**
  95096. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95097. * @param pipelineContext defines the pipeline context to use
  95098. * @param uniformsNames defines the list of uniform names
  95099. * @returns an array of webGL uniform locations
  95100. */
  95101. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95102. /**
  95103. * Gets the lsit of active attributes for a given webGL program
  95104. * @param pipelineContext defines the pipeline context to use
  95105. * @param attributesNames defines the list of attribute names to get
  95106. * @returns an array of indices indicating the offset of each attribute
  95107. */
  95108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95109. /**
  95110. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95111. * @param effect defines the effect to activate
  95112. */
  95113. enableEffect(effect: Nullable<Effect>): void;
  95114. /**
  95115. * Set the value of an uniform to an array of int32
  95116. * @param uniform defines the webGL uniform location where to store the value
  95117. * @param array defines the array of int32 to store
  95118. */
  95119. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95120. /**
  95121. * Set the value of an uniform to an array of int32 (stored as vec2)
  95122. * @param uniform defines the webGL uniform location where to store the value
  95123. * @param array defines the array of int32 to store
  95124. */
  95125. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95126. /**
  95127. * Set the value of an uniform to an array of int32 (stored as vec3)
  95128. * @param uniform defines the webGL uniform location where to store the value
  95129. * @param array defines the array of int32 to store
  95130. */
  95131. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95132. /**
  95133. * Set the value of an uniform to an array of int32 (stored as vec4)
  95134. * @param uniform defines the webGL uniform location where to store the value
  95135. * @param array defines the array of int32 to store
  95136. */
  95137. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95138. /**
  95139. * Set the value of an uniform to an array of float32
  95140. * @param uniform defines the webGL uniform location where to store the value
  95141. * @param array defines the array of float32 to store
  95142. */
  95143. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95144. /**
  95145. * Set the value of an uniform to an array of float32 (stored as vec2)
  95146. * @param uniform defines the webGL uniform location where to store the value
  95147. * @param array defines the array of float32 to store
  95148. */
  95149. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95150. /**
  95151. * Set the value of an uniform to an array of float32 (stored as vec3)
  95152. * @param uniform defines the webGL uniform location where to store the value
  95153. * @param array defines the array of float32 to store
  95154. */
  95155. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95156. /**
  95157. * Set the value of an uniform to an array of float32 (stored as vec4)
  95158. * @param uniform defines the webGL uniform location where to store the value
  95159. * @param array defines the array of float32 to store
  95160. */
  95161. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95162. /**
  95163. * Set the value of an uniform to an array of number
  95164. * @param uniform defines the webGL uniform location where to store the value
  95165. * @param array defines the array of number to store
  95166. */
  95167. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95168. /**
  95169. * Set the value of an uniform to an array of number (stored as vec2)
  95170. * @param uniform defines the webGL uniform location where to store the value
  95171. * @param array defines the array of number to store
  95172. */
  95173. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95174. /**
  95175. * Set the value of an uniform to an array of number (stored as vec3)
  95176. * @param uniform defines the webGL uniform location where to store the value
  95177. * @param array defines the array of number to store
  95178. */
  95179. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95180. /**
  95181. * Set the value of an uniform to an array of number (stored as vec4)
  95182. * @param uniform defines the webGL uniform location where to store the value
  95183. * @param array defines the array of number to store
  95184. */
  95185. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95186. /**
  95187. * Set the value of an uniform to an array of float32 (stored as matrices)
  95188. * @param uniform defines the webGL uniform location where to store the value
  95189. * @param matrices defines the array of float32 to store
  95190. */
  95191. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95192. /**
  95193. * Set the value of an uniform to a matrix (3x3)
  95194. * @param uniform defines the webGL uniform location where to store the value
  95195. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95196. */
  95197. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95198. /**
  95199. * Set the value of an uniform to a matrix (2x2)
  95200. * @param uniform defines the webGL uniform location where to store the value
  95201. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95202. */
  95203. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95204. /**
  95205. * Set the value of an uniform to a number (int)
  95206. * @param uniform defines the webGL uniform location where to store the value
  95207. * @param value defines the int number to store
  95208. */
  95209. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95210. /**
  95211. * Set the value of an uniform to a number (float)
  95212. * @param uniform defines the webGL uniform location where to store the value
  95213. * @param value defines the float number to store
  95214. */
  95215. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95216. /**
  95217. * Set the value of an uniform to a vec2
  95218. * @param uniform defines the webGL uniform location where to store the value
  95219. * @param x defines the 1st component of the value
  95220. * @param y defines the 2nd component of the value
  95221. */
  95222. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95223. /**
  95224. * Set the value of an uniform to a vec3
  95225. * @param uniform defines the webGL uniform location where to store the value
  95226. * @param x defines the 1st component of the value
  95227. * @param y defines the 2nd component of the value
  95228. * @param z defines the 3rd component of the value
  95229. */
  95230. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95231. /**
  95232. * Set the value of an uniform to a boolean
  95233. * @param uniform defines the webGL uniform location where to store the value
  95234. * @param bool defines the boolean to store
  95235. */
  95236. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95237. /**
  95238. * Set the value of an uniform to a vec4
  95239. * @param uniform defines the webGL uniform location where to store the value
  95240. * @param x defines the 1st component of the value
  95241. * @param y defines the 2nd component of the value
  95242. * @param z defines the 3rd component of the value
  95243. * @param w defines the 4th component of the value
  95244. */
  95245. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95246. /**
  95247. * Sets a Color4 on a uniform variable
  95248. * @param uniform defines the uniform location
  95249. * @param color4 defines the value to be set
  95250. */
  95251. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95252. /**
  95253. * Set various states to the webGL context
  95254. * @param culling defines backface culling state
  95255. * @param zOffset defines the value to apply to zOffset (0 by default)
  95256. * @param force defines if states must be applied even if cache is up to date
  95257. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95258. */
  95259. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95260. /**
  95261. * Set the z offset to apply to current rendering
  95262. * @param value defines the offset to apply
  95263. */
  95264. setZOffset(value: number): void;
  95265. /**
  95266. * Gets the current value of the zOffset
  95267. * @returns the current zOffset state
  95268. */
  95269. getZOffset(): number;
  95270. /**
  95271. * Enable or disable depth buffering
  95272. * @param enable defines the state to set
  95273. */
  95274. setDepthBuffer(enable: boolean): void;
  95275. /**
  95276. * Gets a boolean indicating if depth writing is enabled
  95277. * @returns the current depth writing state
  95278. */
  95279. getDepthWrite(): boolean;
  95280. /**
  95281. * Enable or disable depth writing
  95282. * @param enable defines the state to set
  95283. */
  95284. setDepthWrite(enable: boolean): void;
  95285. /**
  95286. * Enable or disable color writing
  95287. * @param enable defines the state to set
  95288. */
  95289. setColorWrite(enable: boolean): void;
  95290. /**
  95291. * Gets a boolean indicating if color writing is enabled
  95292. * @returns the current color writing state
  95293. */
  95294. getColorWrite(): boolean;
  95295. /**
  95296. * Sets alpha constants used by some alpha blending modes
  95297. * @param r defines the red component
  95298. * @param g defines the green component
  95299. * @param b defines the blue component
  95300. * @param a defines the alpha component
  95301. */
  95302. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95303. /**
  95304. * Sets the current alpha mode
  95305. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95306. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95307. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95308. */
  95309. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95310. /**
  95311. * Gets the current alpha mode
  95312. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95313. * @returns the current alpha mode
  95314. */
  95315. getAlphaMode(): number;
  95316. /**
  95317. * Clears the list of texture accessible through engine.
  95318. * This can help preventing texture load conflict due to name collision.
  95319. */
  95320. clearInternalTexturesCache(): void;
  95321. /**
  95322. * Force the entire cache to be cleared
  95323. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95324. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95325. */
  95326. wipeCaches(bruteForce?: boolean): void;
  95327. /**
  95328. * Set the compressed texture format to use, based on the formats you have, and the formats
  95329. * supported by the hardware / browser.
  95330. *
  95331. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95332. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95333. * to API arguments needed to compressed textures. This puts the burden on the container
  95334. * generator to house the arcane code for determining these for current & future formats.
  95335. *
  95336. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95337. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95338. *
  95339. * Note: The result of this call is not taken into account when a texture is base64.
  95340. *
  95341. * @param formatsAvailable defines the list of those format families you have created
  95342. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95343. *
  95344. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95345. * @returns The extension selected.
  95346. */
  95347. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95348. /** @hidden */
  95349. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95350. min: number;
  95351. mag: number;
  95352. };
  95353. /** @hidden */
  95354. _createTexture(): WebGLTexture;
  95355. /**
  95356. * Usually called from Texture.ts.
  95357. * Passed information to create a WebGLTexture
  95358. * @param urlArg defines a value which contains one of the following:
  95359. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95360. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95361. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95363. * @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)
  95364. * @param scene needed for loading to the correct scene
  95365. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95366. * @param onLoad optional callback to be called upon successful completion
  95367. * @param onError optional callback to be called upon failure
  95368. * @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
  95369. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95370. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95371. * @param forcedExtension defines the extension to use to pick the right loader
  95372. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95373. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95374. */
  95375. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  95376. /**
  95377. * @hidden
  95378. * Rescales a texture
  95379. * @param source input texutre
  95380. * @param destination destination texture
  95381. * @param scene scene to use to render the resize
  95382. * @param internalFormat format to use when resizing
  95383. * @param onComplete callback to be called when resize has completed
  95384. */
  95385. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95386. private _unpackFlipYCached;
  95387. /**
  95388. * In case you are sharing the context with other applications, it might
  95389. * be interested to not cache the unpack flip y state to ensure a consistent
  95390. * value would be set.
  95391. */
  95392. enableUnpackFlipYCached: boolean;
  95393. /** @hidden */
  95394. _unpackFlipY(value: boolean): void;
  95395. /** @hidden */
  95396. _getUnpackAlignement(): number;
  95397. /**
  95398. * Creates a dynamic texture
  95399. * @param width defines the width of the texture
  95400. * @param height defines the height of the texture
  95401. * @param generateMipMaps defines if the engine should generate the mip levels
  95402. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95403. * @returns the dynamic texture inside an InternalTexture
  95404. */
  95405. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95406. /**
  95407. * Update the sampling mode of a given texture
  95408. * @param samplingMode defines the required sampling mode
  95409. * @param texture defines the texture to update
  95410. */
  95411. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95412. /**
  95413. * Update the content of a dynamic texture
  95414. * @param texture defines the texture to update
  95415. * @param canvas defines the canvas containing the source
  95416. * @param invertY defines if data must be stored with Y axis inverted
  95417. * @param premulAlpha defines if alpha is stored as premultiplied
  95418. * @param format defines the format of the data
  95419. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95420. */
  95421. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95422. /**
  95423. * Update a video texture
  95424. * @param texture defines the texture to update
  95425. * @param video defines the video element to use
  95426. * @param invertY defines if data must be stored with Y axis inverted
  95427. */
  95428. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95429. /**
  95430. * Updates a depth texture Comparison Mode and Function.
  95431. * If the comparison Function is equal to 0, the mode will be set to none.
  95432. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95433. * @param texture The texture to set the comparison function for
  95434. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95435. */
  95436. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95437. /** @hidden */
  95438. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95439. width: number;
  95440. height: number;
  95441. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95442. /**
  95443. * Creates a depth stencil texture.
  95444. * This is only available in WebGL 2 or with the depth texture extension available.
  95445. * @param size The size of face edge in the texture.
  95446. * @param options The options defining the texture.
  95447. * @returns The texture
  95448. */
  95449. createDepthStencilTexture(size: number | {
  95450. width: number;
  95451. height: number;
  95452. }, options: DepthTextureCreationOptions): InternalTexture;
  95453. /**
  95454. * Creates a depth stencil texture.
  95455. * This is only available in WebGL 2 or with the depth texture extension available.
  95456. * @param size The size of face edge in the texture.
  95457. * @param options The options defining the texture.
  95458. * @returns The texture
  95459. */
  95460. private _createDepthStencilTexture;
  95461. /**
  95462. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95463. * @param renderTarget The render target to set the frame buffer for
  95464. */
  95465. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95466. /**
  95467. * Creates a new render target texture
  95468. * @param size defines the size of the texture
  95469. * @param options defines the options used to create the texture
  95470. * @returns a new render target texture stored in an InternalTexture
  95471. */
  95472. createRenderTargetTexture(size: number | {
  95473. width: number;
  95474. height: number;
  95475. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95476. /** @hidden */
  95477. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95478. /**
  95479. * Updates the sample count of a render target texture
  95480. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95481. * @param texture defines the texture to update
  95482. * @param samples defines the sample count to set
  95483. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95484. */
  95485. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95486. /** @hidden */
  95487. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95488. /** @hidden */
  95489. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95490. /** @hidden */
  95491. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95492. /** @hidden */
  95493. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95494. /**
  95495. * @hidden
  95496. */
  95497. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95498. private _prepareWebGLTextureContinuation;
  95499. private _prepareWebGLTexture;
  95500. /** @hidden */
  95501. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95502. /** @hidden */
  95503. _releaseFramebufferObjects(texture: InternalTexture): void;
  95504. /** @hidden */
  95505. _releaseTexture(texture: InternalTexture): void;
  95506. private setProgram;
  95507. private _boundUniforms;
  95508. /**
  95509. * Binds an effect to the webGL context
  95510. * @param effect defines the effect to bind
  95511. */
  95512. bindSamplers(effect: Effect): void;
  95513. private _activateCurrentTexture;
  95514. /** @hidden */
  95515. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95516. /** @hidden */
  95517. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95518. /**
  95519. * Sets a texture to the webGL context from a postprocess
  95520. * @param channel defines the channel to use
  95521. * @param postProcess defines the source postprocess
  95522. */
  95523. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95524. /**
  95525. * Binds the output of the passed in post process to the texture channel specified
  95526. * @param channel The channel the texture should be bound to
  95527. * @param postProcess The post process which's output should be bound
  95528. */
  95529. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95530. /**
  95531. * Unbind all textures from the webGL context
  95532. */
  95533. unbindAllTextures(): void;
  95534. /**
  95535. * Sets a texture to the according uniform.
  95536. * @param channel The texture channel
  95537. * @param uniform The uniform to set
  95538. * @param texture The texture to apply
  95539. */
  95540. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95541. /**
  95542. * Sets a depth stencil texture from a render target to the according uniform.
  95543. * @param channel The texture channel
  95544. * @param uniform The uniform to set
  95545. * @param texture The render target texture containing the depth stencil texture to apply
  95546. */
  95547. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95548. private _bindSamplerUniformToChannel;
  95549. private _getTextureWrapMode;
  95550. private _setTexture;
  95551. /**
  95552. * Sets an array of texture to the webGL context
  95553. * @param channel defines the channel where the texture array must be set
  95554. * @param uniform defines the associated uniform location
  95555. * @param textures defines the array of textures to bind
  95556. */
  95557. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95558. /** @hidden */
  95559. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95560. private _setTextureParameterFloat;
  95561. private _setTextureParameterInteger;
  95562. /**
  95563. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95564. * @param x defines the x coordinate of the rectangle where pixels must be read
  95565. * @param y defines the y coordinate of the rectangle where pixels must be read
  95566. * @param width defines the width of the rectangle where pixels must be read
  95567. * @param height defines the height of the rectangle where pixels must be read
  95568. * @returns a Uint8Array containing RGBA colors
  95569. */
  95570. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95571. /**
  95572. * Add an externaly attached data from its key.
  95573. * This method call will fail and return false, if such key already exists.
  95574. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95575. * @param key the unique key that identifies the data
  95576. * @param data the data object to associate to the key for this Engine instance
  95577. * @return true if no such key were already present and the data was added successfully, false otherwise
  95578. */
  95579. addExternalData<T>(key: string, data: T): boolean;
  95580. /**
  95581. * Get an externaly attached data from its key
  95582. * @param key the unique key that identifies the data
  95583. * @return the associated data, if present (can be null), or undefined if not present
  95584. */
  95585. getExternalData<T>(key: string): T;
  95586. /**
  95587. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95588. * @param key the unique key that identifies the data
  95589. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95590. * @return the associated data, can be null if the factory returned null.
  95591. */
  95592. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95593. /**
  95594. * Remove an externaly attached data from the Engine instance
  95595. * @param key the unique key that identifies the data
  95596. * @return true if the data was successfully removed, false if it doesn't exist
  95597. */
  95598. removeExternalData(key: string): boolean;
  95599. /**
  95600. * Unbind all vertex attributes from the webGL context
  95601. */
  95602. unbindAllAttributes(): void;
  95603. /**
  95604. * 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
  95605. */
  95606. releaseEffects(): void;
  95607. /**
  95608. * Dispose and release all associated resources
  95609. */
  95610. dispose(): void;
  95611. /**
  95612. * Display the loading screen
  95613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95614. */
  95615. displayLoadingUI(): void;
  95616. /**
  95617. * Hide the loading screen
  95618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95619. */
  95620. hideLoadingUI(): void;
  95621. /**
  95622. * Gets the current loading screen object
  95623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95624. */
  95625. /**
  95626. * Sets the current loading screen object
  95627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95628. */
  95629. loadingScreen: ILoadingScreen;
  95630. /**
  95631. * Sets the current loading screen text
  95632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95633. */
  95634. loadingUIText: string;
  95635. /**
  95636. * Sets the current loading screen background color
  95637. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95638. */
  95639. loadingUIBackgroundColor: string;
  95640. /**
  95641. * Attach a new callback raised when context lost event is fired
  95642. * @param callback defines the callback to call
  95643. */
  95644. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95645. /**
  95646. * Attach a new callback raised when context restored event is fired
  95647. * @param callback defines the callback to call
  95648. */
  95649. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95650. /**
  95651. * Gets the source code of the vertex shader associated with a specific webGL program
  95652. * @param program defines the program to use
  95653. * @returns a string containing the source code of the vertex shader associated with the program
  95654. */
  95655. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95656. /**
  95657. * Gets the source code of the fragment shader associated with a specific webGL program
  95658. * @param program defines the program to use
  95659. * @returns a string containing the source code of the fragment shader associated with the program
  95660. */
  95661. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95662. /**
  95663. * Get the current error code of the webGL context
  95664. * @returns the error code
  95665. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95666. */
  95667. getError(): number;
  95668. /**
  95669. * Gets the current framerate
  95670. * @returns a number representing the framerate
  95671. */
  95672. getFps(): number;
  95673. /**
  95674. * Gets the time spent between current and previous frame
  95675. * @returns a number representing the delta time in ms
  95676. */
  95677. getDeltaTime(): number;
  95678. private _measureFps;
  95679. /** @hidden */
  95680. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95681. private _canRenderToFloatFramebuffer;
  95682. private _canRenderToHalfFloatFramebuffer;
  95683. private _canRenderToFramebuffer;
  95684. /** @hidden */
  95685. _getWebGLTextureType(type: number): number;
  95686. /** @hidden */
  95687. _getInternalFormat(format: number): number;
  95688. /** @hidden */
  95689. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95690. /** @hidden */
  95691. _getRGBAMultiSampleBufferFormat(type: number): number;
  95692. /** @hidden */
  95693. _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;
  95694. /** @hidden */
  95695. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95696. /**
  95697. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95698. * @returns true if the engine can be created
  95699. * @ignorenaming
  95700. */
  95701. static isSupported(): boolean;
  95702. /**
  95703. * Find the next highest power of two.
  95704. * @param x Number to start search from.
  95705. * @return Next highest power of two.
  95706. */
  95707. static CeilingPOT(x: number): number;
  95708. /**
  95709. * Find the next lowest power of two.
  95710. * @param x Number to start search from.
  95711. * @return Next lowest power of two.
  95712. */
  95713. static FloorPOT(x: number): number;
  95714. /**
  95715. * Find the nearest power of two.
  95716. * @param x Number to start search from.
  95717. * @return Next nearest power of two.
  95718. */
  95719. static NearestPOT(x: number): number;
  95720. /**
  95721. * Get the closest exponent of two
  95722. * @param value defines the value to approximate
  95723. * @param max defines the maximum value to return
  95724. * @param mode defines how to define the closest value
  95725. * @returns closest exponent of two of the given value
  95726. */
  95727. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95728. /**
  95729. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95730. * @param func - the function to be called
  95731. * @param requester - the object that will request the next frame. Falls back to window.
  95732. * @returns frame number
  95733. */
  95734. static QueueNewFrame(func: () => void, requester?: any): number;
  95735. /**
  95736. * Ask the browser to promote the current element to pointerlock mode
  95737. * @param element defines the DOM element to promote
  95738. */
  95739. static _RequestPointerlock(element: HTMLElement): void;
  95740. /**
  95741. * Asks the browser to exit pointerlock mode
  95742. */
  95743. static _ExitPointerlock(): void;
  95744. /**
  95745. * Ask the browser to promote the current element to fullscreen rendering mode
  95746. * @param element defines the DOM element to promote
  95747. */
  95748. static _RequestFullscreen(element: HTMLElement): void;
  95749. /**
  95750. * Asks the browser to exit fullscreen mode
  95751. */
  95752. static _ExitFullscreen(): void;
  95753. }
  95754. }
  95755. declare module BABYLON {
  95756. /**
  95757. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95758. * during the life time of the application.
  95759. */
  95760. export class EngineStore {
  95761. /** Gets the list of created engines */
  95762. static Instances: Engine[];
  95763. /** @hidden */
  95764. static _LastCreatedScene: Nullable<Scene>;
  95765. /**
  95766. * Gets the latest created engine
  95767. */
  95768. static readonly LastCreatedEngine: Nullable<Engine>;
  95769. /**
  95770. * Gets the latest created scene
  95771. */
  95772. static readonly LastCreatedScene: Nullable<Scene>;
  95773. /**
  95774. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95775. * @ignorenaming
  95776. */
  95777. static UseFallbackTexture: boolean;
  95778. /**
  95779. * Texture content used if a texture cannot loaded
  95780. * @ignorenaming
  95781. */
  95782. static FallbackTexture: string;
  95783. }
  95784. }
  95785. declare module BABYLON {
  95786. /**
  95787. * Helper class that provides a small promise polyfill
  95788. */
  95789. export class PromisePolyfill {
  95790. /**
  95791. * Static function used to check if the polyfill is required
  95792. * If this is the case then the function will inject the polyfill to window.Promise
  95793. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95794. */
  95795. static Apply(force?: boolean): void;
  95796. }
  95797. }
  95798. declare module BABYLON {
  95799. /**
  95800. * Interface for screenshot methods with describe argument called `size` as object with options
  95801. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  95802. */
  95803. export interface IScreenshotSize {
  95804. /**
  95805. * number in pixels for canvas height
  95806. */
  95807. height?: number;
  95808. /**
  95809. * multiplier allowing render at a higher or lower resolution
  95810. * If value is defined then height and width will be ignored and taken from camera
  95811. */
  95812. precision?: number;
  95813. /**
  95814. * number in pixels for canvas width
  95815. */
  95816. width?: number;
  95817. }
  95818. }
  95819. declare module BABYLON {
  95820. interface IColor4Like {
  95821. r: float;
  95822. g: float;
  95823. b: float;
  95824. a: float;
  95825. }
  95826. /**
  95827. * Class containing a set of static utilities functions
  95828. */
  95829. export class Tools {
  95830. /**
  95831. * Gets or sets the base URL to use to load assets
  95832. */
  95833. static BaseUrl: string;
  95834. /**
  95835. * Enable/Disable Custom HTTP Request Headers globally.
  95836. * default = false
  95837. * @see CustomRequestHeaders
  95838. */
  95839. static UseCustomRequestHeaders: boolean;
  95840. /**
  95841. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95842. * i.e. when loading files, where the server/service expects an Authorization header
  95843. */
  95844. static CustomRequestHeaders: {
  95845. [key: string]: string;
  95846. };
  95847. /**
  95848. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95849. */
  95850. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95851. /**
  95852. * Default behaviour for cors in the application.
  95853. * It can be a string if the expected behavior is identical in the entire app.
  95854. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95855. */
  95856. static CorsBehavior: string | ((url: string | string[]) => string);
  95857. /**
  95858. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95859. * @ignorenaming
  95860. */
  95861. static UseFallbackTexture: boolean;
  95862. /**
  95863. * Use this object to register external classes like custom textures or material
  95864. * to allow the laoders to instantiate them
  95865. */
  95866. static RegisteredExternalClasses: {
  95867. [key: string]: Object;
  95868. };
  95869. /**
  95870. * Texture content used if a texture cannot loaded
  95871. * @ignorenaming
  95872. */
  95873. static fallbackTexture: string;
  95874. /**
  95875. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95876. * @param u defines the coordinate on X axis
  95877. * @param v defines the coordinate on Y axis
  95878. * @param width defines the width of the source data
  95879. * @param height defines the height of the source data
  95880. * @param pixels defines the source byte array
  95881. * @param color defines the output color
  95882. */
  95883. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95884. /**
  95885. * Interpolates between a and b via alpha
  95886. * @param a The lower value (returned when alpha = 0)
  95887. * @param b The upper value (returned when alpha = 1)
  95888. * @param alpha The interpolation-factor
  95889. * @return The mixed value
  95890. */
  95891. static Mix(a: number, b: number, alpha: number): number;
  95892. /**
  95893. * Tries to instantiate a new object from a given class name
  95894. * @param className defines the class name to instantiate
  95895. * @returns the new object or null if the system was not able to do the instantiation
  95896. */
  95897. static Instantiate(className: string): any;
  95898. /**
  95899. * Provides a slice function that will work even on IE
  95900. * @param data defines the array to slice
  95901. * @param start defines the start of the data (optional)
  95902. * @param end defines the end of the data (optional)
  95903. * @returns the new sliced array
  95904. */
  95905. static Slice<T>(data: T, start?: number, end?: number): T;
  95906. /**
  95907. * Polyfill for setImmediate
  95908. * @param action defines the action to execute after the current execution block
  95909. */
  95910. static SetImmediate(action: () => void): void;
  95911. /**
  95912. * Function indicating if a number is an exponent of 2
  95913. * @param value defines the value to test
  95914. * @returns true if the value is an exponent of 2
  95915. */
  95916. static IsExponentOfTwo(value: number): boolean;
  95917. private static _tmpFloatArray;
  95918. /**
  95919. * Returns the nearest 32-bit single precision float representation of a Number
  95920. * @param value A Number. If the parameter is of a different type, it will get converted
  95921. * to a number or to NaN if it cannot be converted
  95922. * @returns number
  95923. */
  95924. static FloatRound(value: number): number;
  95925. /**
  95926. * Extracts the filename from a path
  95927. * @param path defines the path to use
  95928. * @returns the filename
  95929. */
  95930. static GetFilename(path: string): string;
  95931. /**
  95932. * Extracts the "folder" part of a path (everything before the filename).
  95933. * @param uri The URI to extract the info from
  95934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95935. * @returns The "folder" part of the path
  95936. */
  95937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95938. /**
  95939. * Extracts text content from a DOM element hierarchy
  95940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95941. */
  95942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95943. /**
  95944. * Convert an angle in radians to degrees
  95945. * @param angle defines the angle to convert
  95946. * @returns the angle in degrees
  95947. */
  95948. static ToDegrees(angle: number): number;
  95949. /**
  95950. * Convert an angle in degrees to radians
  95951. * @param angle defines the angle to convert
  95952. * @returns the angle in radians
  95953. */
  95954. static ToRadians(angle: number): number;
  95955. /**
  95956. * Encode a buffer to a base64 string
  95957. * @param buffer defines the buffer to encode
  95958. * @returns the encoded string
  95959. */
  95960. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95961. /**
  95962. * Returns an array if obj is not an array
  95963. * @param obj defines the object to evaluate as an array
  95964. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95965. * @returns either obj directly if obj is an array or a new array containing obj
  95966. */
  95967. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95968. /**
  95969. * Gets the pointer prefix to use
  95970. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95971. */
  95972. static GetPointerPrefix(): string;
  95973. /**
  95974. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95975. * @param url define the url we are trying
  95976. * @param element define the dom element where to configure the cors policy
  95977. */
  95978. static SetCorsBehavior(url: string | string[], element: {
  95979. crossOrigin: string | null;
  95980. }): void;
  95981. /**
  95982. * Removes unwanted characters from an url
  95983. * @param url defines the url to clean
  95984. * @returns the cleaned url
  95985. */
  95986. static CleanUrl(url: string): string;
  95987. /**
  95988. * Gets or sets a function used to pre-process url before using them to load assets
  95989. */
  95990. static PreprocessUrl: (url: string) => string;
  95991. /**
  95992. * Loads an image as an HTMLImageElement.
  95993. * @param input url string, ArrayBuffer, or Blob to load
  95994. * @param onLoad callback called when the image successfully loads
  95995. * @param onError callback called when the image fails to load
  95996. * @param offlineProvider offline provider for caching
  95997. * @returns the HTMLImageElement of the loaded image
  95998. */
  95999. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96000. /**
  96001. * Loads a file
  96002. * @param url url string, ArrayBuffer, or Blob to load
  96003. * @param onSuccess callback called when the file successfully loads
  96004. * @param onProgress callback called while file is loading (if the server supports this mode)
  96005. * @param offlineProvider defines the offline provider for caching
  96006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96007. * @param onError callback called when the file fails to load
  96008. * @returns a file request object
  96009. */
  96010. 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;
  96011. /**
  96012. * Loads a file from a url
  96013. * @param url the file url to load
  96014. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96015. */
  96016. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96017. /**
  96018. * Load a script (identified by an url). When the url returns, the
  96019. * content of this file is added into a new script element, attached to the DOM (body element)
  96020. * @param scriptUrl defines the url of the script to laod
  96021. * @param onSuccess defines the callback called when the script is loaded
  96022. * @param onError defines the callback to call if an error occurs
  96023. * @param scriptId defines the id of the script element
  96024. */
  96025. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96026. /**
  96027. * Load an asynchronous script (identified by an url). When the url returns, the
  96028. * content of this file is added into a new script element, attached to the DOM (body element)
  96029. * @param scriptUrl defines the url of the script to laod
  96030. * @param scriptId defines the id of the script element
  96031. * @returns a promise request object
  96032. */
  96033. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96034. /**
  96035. * Loads a file from a blob
  96036. * @param fileToLoad defines the blob to use
  96037. * @param callback defines the callback to call when data is loaded
  96038. * @param progressCallback defines the callback to call during loading process
  96039. * @returns a file request object
  96040. */
  96041. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96042. /**
  96043. * Loads a file
  96044. * @param fileToLoad defines the file to load
  96045. * @param callback defines the callback to call when data is loaded
  96046. * @param progressCallBack defines the callback to call during loading process
  96047. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96048. * @returns a file request object
  96049. */
  96050. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96051. /**
  96052. * Creates a data url from a given string content
  96053. * @param content defines the content to convert
  96054. * @returns the new data url link
  96055. */
  96056. static FileAsURL(content: string): string;
  96057. /**
  96058. * Format the given number to a specific decimal format
  96059. * @param value defines the number to format
  96060. * @param decimals defines the number of decimals to use
  96061. * @returns the formatted string
  96062. */
  96063. static Format(value: number, decimals?: number): string;
  96064. /**
  96065. * Tries to copy an object by duplicating every property
  96066. * @param source defines the source object
  96067. * @param destination defines the target object
  96068. * @param doNotCopyList defines a list of properties to avoid
  96069. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96070. */
  96071. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96072. /**
  96073. * Gets a boolean indicating if the given object has no own property
  96074. * @param obj defines the object to test
  96075. * @returns true if object has no own property
  96076. */
  96077. static IsEmpty(obj: any): boolean;
  96078. /**
  96079. * Function used to register events at window level
  96080. * @param windowElement defines the Window object to use
  96081. * @param events defines the events to register
  96082. */
  96083. static RegisterTopRootEvents(windowElement: Window, events: {
  96084. name: string;
  96085. handler: Nullable<(e: FocusEvent) => any>;
  96086. }[]): void;
  96087. /**
  96088. * Function used to unregister events from window level
  96089. * @param windowElement defines the Window object to use
  96090. * @param events defines the events to unregister
  96091. */
  96092. static UnregisterTopRootEvents(windowElement: Window, events: {
  96093. name: string;
  96094. handler: Nullable<(e: FocusEvent) => any>;
  96095. }[]): void;
  96096. /**
  96097. * @ignore
  96098. */
  96099. static _ScreenshotCanvas: HTMLCanvasElement;
  96100. /**
  96101. * Dumps the current bound framebuffer
  96102. * @param width defines the rendering width
  96103. * @param height defines the rendering height
  96104. * @param engine defines the hosting engine
  96105. * @param successCallback defines the callback triggered once the data are available
  96106. * @param mimeType defines the mime type of the result
  96107. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96108. */
  96109. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96110. /**
  96111. * Converts the canvas data to blob.
  96112. * This acts as a polyfill for browsers not supporting the to blob function.
  96113. * @param canvas Defines the canvas to extract the data from
  96114. * @param successCallback Defines the callback triggered once the data are available
  96115. * @param mimeType Defines the mime type of the result
  96116. */
  96117. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96118. /**
  96119. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96120. * @param successCallback defines the callback triggered once the data are available
  96121. * @param mimeType defines the mime type of the result
  96122. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96123. */
  96124. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96125. /**
  96126. * Downloads a blob in the browser
  96127. * @param blob defines the blob to download
  96128. * @param fileName defines the name of the downloaded file
  96129. */
  96130. static Download(blob: Blob, fileName: string): void;
  96131. /**
  96132. * Captures a screenshot of the current rendering
  96133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96134. * @param engine defines the rendering engine
  96135. * @param camera defines the source camera
  96136. * @param size This parameter can be set to a single number or to an object with the
  96137. * following (optional) properties: precision, width, height. If a single number is passed,
  96138. * it will be used for both width and height. If an object is passed, the screenshot size
  96139. * will be derived from the parameters. The precision property is a multiplier allowing
  96140. * rendering at a higher or lower resolution
  96141. * @param successCallback defines the callback receives a single parameter which contains the
  96142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96143. * src parameter of an <img> to display it
  96144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96145. * Check your browser for supported MIME types
  96146. */
  96147. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96148. /**
  96149. * Captures a screenshot of the current rendering
  96150. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96151. * @param engine defines the rendering engine
  96152. * @param camera defines the source camera
  96153. * @param size This parameter can be set to a single number or to an object with the
  96154. * following (optional) properties: precision, width, height. If a single number is passed,
  96155. * it will be used for both width and height. If an object is passed, the screenshot size
  96156. * will be derived from the parameters. The precision property is a multiplier allowing
  96157. * rendering at a higher or lower resolution
  96158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96159. * Check your browser for supported MIME types
  96160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96161. * to the src parameter of an <img> to display it
  96162. */
  96163. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96164. /**
  96165. * Generates an image screenshot from the specified camera.
  96166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96167. * @param engine The engine to use for rendering
  96168. * @param camera The camera to use for rendering
  96169. * @param size This parameter can be set to a single number or to an object with the
  96170. * following (optional) properties: precision, width, height. If a single number is passed,
  96171. * it will be used for both width and height. If an object is passed, the screenshot size
  96172. * will be derived from the parameters. The precision property is a multiplier allowing
  96173. * rendering at a higher or lower resolution
  96174. * @param successCallback The callback receives a single parameter which contains the
  96175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96176. * src parameter of an <img> to display it
  96177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96178. * Check your browser for supported MIME types
  96179. * @param samples Texture samples (default: 1)
  96180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96181. * @param fileName A name for for the downloaded file.
  96182. */
  96183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96184. /**
  96185. * Generates an image screenshot from the specified camera.
  96186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96187. * @param engine The engine to use for rendering
  96188. * @param camera The camera to use for rendering
  96189. * @param size This parameter can be set to a single number or to an object with the
  96190. * following (optional) properties: precision, width, height. If a single number is passed,
  96191. * it will be used for both width and height. If an object is passed, the screenshot size
  96192. * will be derived from the parameters. The precision property is a multiplier allowing
  96193. * rendering at a higher or lower resolution
  96194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96195. * Check your browser for supported MIME types
  96196. * @param samples Texture samples (default: 1)
  96197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96198. * @param fileName A name for for the downloaded file.
  96199. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96200. * to the src parameter of an <img> to display it
  96201. */
  96202. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96203. /**
  96204. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96205. * Be aware Math.random() could cause collisions, but:
  96206. * "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"
  96207. * @returns a pseudo random id
  96208. */
  96209. static RandomId(): string;
  96210. /**
  96211. * Test if the given uri is a base64 string
  96212. * @param uri The uri to test
  96213. * @return True if the uri is a base64 string or false otherwise
  96214. */
  96215. static IsBase64(uri: string): boolean;
  96216. /**
  96217. * Decode the given base64 uri.
  96218. * @param uri The uri to decode
  96219. * @return The decoded base64 data.
  96220. */
  96221. static DecodeBase64(uri: string): ArrayBuffer;
  96222. /**
  96223. * Gets the absolute url.
  96224. * @param url the input url
  96225. * @return the absolute url
  96226. */
  96227. static GetAbsoluteUrl(url: string): string;
  96228. /**
  96229. * No log
  96230. */
  96231. static readonly NoneLogLevel: number;
  96232. /**
  96233. * Only message logs
  96234. */
  96235. static readonly MessageLogLevel: number;
  96236. /**
  96237. * Only warning logs
  96238. */
  96239. static readonly WarningLogLevel: number;
  96240. /**
  96241. * Only error logs
  96242. */
  96243. static readonly ErrorLogLevel: number;
  96244. /**
  96245. * All logs
  96246. */
  96247. static readonly AllLogLevel: number;
  96248. /**
  96249. * Gets a value indicating the number of loading errors
  96250. * @ignorenaming
  96251. */
  96252. static readonly errorsCount: number;
  96253. /**
  96254. * Callback called when a new log is added
  96255. */
  96256. static OnNewCacheEntry: (entry: string) => void;
  96257. /**
  96258. * Log a message to the console
  96259. * @param message defines the message to log
  96260. */
  96261. static Log(message: string): void;
  96262. /**
  96263. * Write a warning message to the console
  96264. * @param message defines the message to log
  96265. */
  96266. static Warn(message: string): void;
  96267. /**
  96268. * Write an error message to the console
  96269. * @param message defines the message to log
  96270. */
  96271. static Error(message: string): void;
  96272. /**
  96273. * Gets current log cache (list of logs)
  96274. */
  96275. static readonly LogCache: string;
  96276. /**
  96277. * Clears the log cache
  96278. */
  96279. static ClearLogCache(): void;
  96280. /**
  96281. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96282. */
  96283. static LogLevels: number;
  96284. /**
  96285. * Checks if the window object exists
  96286. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96287. */
  96288. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96289. /**
  96290. * No performance log
  96291. */
  96292. static readonly PerformanceNoneLogLevel: number;
  96293. /**
  96294. * Use user marks to log performance
  96295. */
  96296. static readonly PerformanceUserMarkLogLevel: number;
  96297. /**
  96298. * Log performance to the console
  96299. */
  96300. static readonly PerformanceConsoleLogLevel: number;
  96301. private static _performance;
  96302. /**
  96303. * Sets the current performance log level
  96304. */
  96305. static PerformanceLogLevel: number;
  96306. private static _StartPerformanceCounterDisabled;
  96307. private static _EndPerformanceCounterDisabled;
  96308. private static _StartUserMark;
  96309. private static _EndUserMark;
  96310. private static _StartPerformanceConsole;
  96311. private static _EndPerformanceConsole;
  96312. /**
  96313. * Starts a performance counter
  96314. */
  96315. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96316. /**
  96317. * Ends a specific performance coutner
  96318. */
  96319. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96320. /**
  96321. * Gets either window.performance.now() if supported or Date.now() else
  96322. */
  96323. static readonly Now: number;
  96324. /**
  96325. * This method will return the name of the class used to create the instance of the given object.
  96326. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96327. * @param object the object to get the class name from
  96328. * @param isType defines if the object is actually a type
  96329. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96330. */
  96331. static GetClassName(object: any, isType?: boolean): string;
  96332. /**
  96333. * Gets the first element of an array satisfying a given predicate
  96334. * @param array defines the array to browse
  96335. * @param predicate defines the predicate to use
  96336. * @returns null if not found or the element
  96337. */
  96338. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96339. /**
  96340. * This method will return the name of the full name of the class, including its owning module (if any).
  96341. * 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).
  96342. * @param object the object to get the class name from
  96343. * @param isType defines if the object is actually a type
  96344. * @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.
  96345. * @ignorenaming
  96346. */
  96347. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96348. /**
  96349. * Returns a promise that resolves after the given amount of time.
  96350. * @param delay Number of milliseconds to delay
  96351. * @returns Promise that resolves after the given amount of time
  96352. */
  96353. static DelayAsync(delay: number): Promise<void>;
  96354. }
  96355. /**
  96356. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96357. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96358. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96359. * @param name The name of the class, case should be preserved
  96360. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96361. */
  96362. export function className(name: string, module?: string): (target: Object) => void;
  96363. /**
  96364. * An implementation of a loop for asynchronous functions.
  96365. */
  96366. export class AsyncLoop {
  96367. /**
  96368. * Defines the number of iterations for the loop
  96369. */
  96370. iterations: number;
  96371. /**
  96372. * Defines the current index of the loop.
  96373. */
  96374. index: number;
  96375. private _done;
  96376. private _fn;
  96377. private _successCallback;
  96378. /**
  96379. * Constructor.
  96380. * @param iterations the number of iterations.
  96381. * @param func the function to run each iteration
  96382. * @param successCallback the callback that will be called upon succesful execution
  96383. * @param offset starting offset.
  96384. */
  96385. constructor(
  96386. /**
  96387. * Defines the number of iterations for the loop
  96388. */
  96389. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96390. /**
  96391. * Execute the next iteration. Must be called after the last iteration was finished.
  96392. */
  96393. executeNext(): void;
  96394. /**
  96395. * Break the loop and run the success callback.
  96396. */
  96397. breakLoop(): void;
  96398. /**
  96399. * Create and run an async loop.
  96400. * @param iterations the number of iterations.
  96401. * @param fn the function to run each iteration
  96402. * @param successCallback the callback that will be called upon succesful execution
  96403. * @param offset starting offset.
  96404. * @returns the created async loop object
  96405. */
  96406. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96407. /**
  96408. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96409. * @param iterations total number of iterations
  96410. * @param syncedIterations number of synchronous iterations in each async iteration.
  96411. * @param fn the function to call each iteration.
  96412. * @param callback a success call back that will be called when iterating stops.
  96413. * @param breakFunction a break condition (optional)
  96414. * @param timeout timeout settings for the setTimeout function. default - 0.
  96415. * @returns the created async loop object
  96416. */
  96417. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96418. }
  96419. }
  96420. declare module BABYLON {
  96421. /** @hidden */
  96422. export interface ICollisionCoordinator {
  96423. createCollider(): Collider;
  96424. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96425. init(scene: Scene): void;
  96426. }
  96427. /** @hidden */
  96428. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96429. private _scene;
  96430. private _scaledPosition;
  96431. private _scaledVelocity;
  96432. private _finalPosition;
  96433. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96434. createCollider(): Collider;
  96435. init(scene: Scene): void;
  96436. private _collideWithWorld;
  96437. }
  96438. }
  96439. declare module BABYLON {
  96440. /**
  96441. * Class used to manage all inputs for the scene.
  96442. */
  96443. export class InputManager {
  96444. /** The distance in pixel that you have to move to prevent some events */
  96445. static DragMovementThreshold: number;
  96446. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96447. static LongPressDelay: number;
  96448. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96449. static DoubleClickDelay: number;
  96450. /** If you need to check double click without raising a single click at first click, enable this flag */
  96451. static ExclusiveDoubleClickMode: boolean;
  96452. private _wheelEventName;
  96453. private _onPointerMove;
  96454. private _onPointerDown;
  96455. private _onPointerUp;
  96456. private _initClickEvent;
  96457. private _initActionManager;
  96458. private _delayedSimpleClick;
  96459. private _delayedSimpleClickTimeout;
  96460. private _previousDelayedSimpleClickTimeout;
  96461. private _meshPickProceed;
  96462. private _previousButtonPressed;
  96463. private _currentPickResult;
  96464. private _previousPickResult;
  96465. private _totalPointersPressed;
  96466. private _doubleClickOccured;
  96467. private _pointerOverMesh;
  96468. private _pickedDownMesh;
  96469. private _pickedUpMesh;
  96470. private _pointerX;
  96471. private _pointerY;
  96472. private _unTranslatedPointerX;
  96473. private _unTranslatedPointerY;
  96474. private _startingPointerPosition;
  96475. private _previousStartingPointerPosition;
  96476. private _startingPointerTime;
  96477. private _previousStartingPointerTime;
  96478. private _pointerCaptures;
  96479. private _onKeyDown;
  96480. private _onKeyUp;
  96481. private _onCanvasFocusObserver;
  96482. private _onCanvasBlurObserver;
  96483. private _scene;
  96484. /**
  96485. * Creates a new InputManager
  96486. * @param scene defines the hosting scene
  96487. */
  96488. constructor(scene: Scene);
  96489. /**
  96490. * Gets the mesh that is currently under the pointer
  96491. */
  96492. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96493. /**
  96494. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96495. */
  96496. readonly unTranslatedPointer: Vector2;
  96497. /**
  96498. * Gets or sets the current on-screen X position of the pointer
  96499. */
  96500. pointerX: number;
  96501. /**
  96502. * Gets or sets the current on-screen Y position of the pointer
  96503. */
  96504. pointerY: number;
  96505. private _updatePointerPosition;
  96506. private _processPointerMove;
  96507. private _setRayOnPointerInfo;
  96508. private _checkPrePointerObservable;
  96509. /**
  96510. * Use this method to simulate a pointer move on a mesh
  96511. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96512. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96513. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96514. */
  96515. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96516. /**
  96517. * Use this method to simulate a pointer down on a mesh
  96518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96521. */
  96522. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96523. private _processPointerDown;
  96524. /** @hidden */
  96525. _isPointerSwiping(): boolean;
  96526. /**
  96527. * Use this method to simulate a pointer up on a mesh
  96528. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96529. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96530. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96531. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96532. */
  96533. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96534. private _processPointerUp;
  96535. /**
  96536. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96537. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96538. * @returns true if the pointer was captured
  96539. */
  96540. isPointerCaptured(pointerId?: number): boolean;
  96541. /**
  96542. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96543. * @param attachUp defines if you want to attach events to pointerup
  96544. * @param attachDown defines if you want to attach events to pointerdown
  96545. * @param attachMove defines if you want to attach events to pointermove
  96546. */
  96547. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96548. /**
  96549. * Detaches all event handlers
  96550. */
  96551. detachControl(): void;
  96552. /**
  96553. * Force the value of meshUnderPointer
  96554. * @param mesh defines the mesh to use
  96555. */
  96556. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96557. /**
  96558. * Gets the mesh under the pointer
  96559. * @returns a Mesh or null if no mesh is under the pointer
  96560. */
  96561. getPointerOverMesh(): Nullable<AbstractMesh>;
  96562. }
  96563. }
  96564. declare module BABYLON {
  96565. /**
  96566. * Helper class used to generate session unique ID
  96567. */
  96568. export class UniqueIdGenerator {
  96569. private static _UniqueIdCounter;
  96570. /**
  96571. * Gets an unique (relatively to the current scene) Id
  96572. */
  96573. static readonly UniqueId: number;
  96574. }
  96575. }
  96576. declare module BABYLON {
  96577. /**
  96578. * This class defines the direct association between an animation and a target
  96579. */
  96580. export class TargetedAnimation {
  96581. /**
  96582. * Animation to perform
  96583. */
  96584. animation: Animation;
  96585. /**
  96586. * Target to animate
  96587. */
  96588. target: any;
  96589. /**
  96590. * Serialize the object
  96591. * @returns the JSON object representing the current entity
  96592. */
  96593. serialize(): any;
  96594. }
  96595. /**
  96596. * Use this class to create coordinated animations on multiple targets
  96597. */
  96598. export class AnimationGroup implements IDisposable {
  96599. /** The name of the animation group */
  96600. name: string;
  96601. private _scene;
  96602. private _targetedAnimations;
  96603. private _animatables;
  96604. private _from;
  96605. private _to;
  96606. private _isStarted;
  96607. private _isPaused;
  96608. private _speedRatio;
  96609. private _loopAnimation;
  96610. /**
  96611. * Gets or sets the unique id of the node
  96612. */
  96613. uniqueId: number;
  96614. /**
  96615. * This observable will notify when one animation have ended
  96616. */
  96617. onAnimationEndObservable: Observable<TargetedAnimation>;
  96618. /**
  96619. * Observer raised when one animation loops
  96620. */
  96621. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96622. /**
  96623. * This observable will notify when all animations have ended.
  96624. */
  96625. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96626. /**
  96627. * This observable will notify when all animations have paused.
  96628. */
  96629. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96630. /**
  96631. * This observable will notify when all animations are playing.
  96632. */
  96633. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96634. /**
  96635. * Gets the first frame
  96636. */
  96637. readonly from: number;
  96638. /**
  96639. * Gets the last frame
  96640. */
  96641. readonly to: number;
  96642. /**
  96643. * Define if the animations are started
  96644. */
  96645. readonly isStarted: boolean;
  96646. /**
  96647. * Gets a value indicating that the current group is playing
  96648. */
  96649. readonly isPlaying: boolean;
  96650. /**
  96651. * Gets or sets the speed ratio to use for all animations
  96652. */
  96653. /**
  96654. * Gets or sets the speed ratio to use for all animations
  96655. */
  96656. speedRatio: number;
  96657. /**
  96658. * Gets or sets if all animations should loop or not
  96659. */
  96660. loopAnimation: boolean;
  96661. /**
  96662. * Gets the targeted animations for this animation group
  96663. */
  96664. readonly targetedAnimations: Array<TargetedAnimation>;
  96665. /**
  96666. * returning the list of animatables controlled by this animation group.
  96667. */
  96668. readonly animatables: Array<Animatable>;
  96669. /**
  96670. * Instantiates a new Animation Group.
  96671. * This helps managing several animations at once.
  96672. * @see http://doc.babylonjs.com/how_to/group
  96673. * @param name Defines the name of the group
  96674. * @param scene Defines the scene the group belongs to
  96675. */
  96676. constructor(
  96677. /** The name of the animation group */
  96678. name: string, scene?: Nullable<Scene>);
  96679. /**
  96680. * Add an animation (with its target) in the group
  96681. * @param animation defines the animation we want to add
  96682. * @param target defines the target of the animation
  96683. * @returns the TargetedAnimation object
  96684. */
  96685. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96686. /**
  96687. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96688. * It can add constant keys at begin or end
  96689. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96690. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96691. * @returns the animation group
  96692. */
  96693. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96694. /**
  96695. * Start all animations on given targets
  96696. * @param loop defines if animations must loop
  96697. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96698. * @param from defines the from key (optional)
  96699. * @param to defines the to key (optional)
  96700. * @returns the current animation group
  96701. */
  96702. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96703. /**
  96704. * Pause all animations
  96705. * @returns the animation group
  96706. */
  96707. pause(): AnimationGroup;
  96708. /**
  96709. * Play all animations to initial state
  96710. * This function will start() the animations if they were not started or will restart() them if they were paused
  96711. * @param loop defines if animations must loop
  96712. * @returns the animation group
  96713. */
  96714. play(loop?: boolean): AnimationGroup;
  96715. /**
  96716. * Reset all animations to initial state
  96717. * @returns the animation group
  96718. */
  96719. reset(): AnimationGroup;
  96720. /**
  96721. * Restart animations from key 0
  96722. * @returns the animation group
  96723. */
  96724. restart(): AnimationGroup;
  96725. /**
  96726. * Stop all animations
  96727. * @returns the animation group
  96728. */
  96729. stop(): AnimationGroup;
  96730. /**
  96731. * Set animation weight for all animatables
  96732. * @param weight defines the weight to use
  96733. * @return the animationGroup
  96734. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96735. */
  96736. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96737. /**
  96738. * Synchronize and normalize all animatables with a source animatable
  96739. * @param root defines the root animatable to synchronize with
  96740. * @return the animationGroup
  96741. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96742. */
  96743. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96744. /**
  96745. * Goes to a specific frame in this animation group
  96746. * @param frame the frame number to go to
  96747. * @return the animationGroup
  96748. */
  96749. goToFrame(frame: number): AnimationGroup;
  96750. /**
  96751. * Dispose all associated resources
  96752. */
  96753. dispose(): void;
  96754. private _checkAnimationGroupEnded;
  96755. /**
  96756. * Clone the current animation group and returns a copy
  96757. * @param newName defines the name of the new group
  96758. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96759. * @returns the new aniamtion group
  96760. */
  96761. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96762. /**
  96763. * Serializes the animationGroup to an object
  96764. * @returns Serialized object
  96765. */
  96766. serialize(): any;
  96767. /**
  96768. * Returns a new AnimationGroup object parsed from the source provided.
  96769. * @param parsedAnimationGroup defines the source
  96770. * @param scene defines the scene that will receive the animationGroup
  96771. * @returns a new AnimationGroup
  96772. */
  96773. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96774. /**
  96775. * Returns the string "AnimationGroup"
  96776. * @returns "AnimationGroup"
  96777. */
  96778. getClassName(): string;
  96779. /**
  96780. * Creates a detailled string about the object
  96781. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96782. * @returns a string representing the object
  96783. */
  96784. toString(fullDetails?: boolean): string;
  96785. }
  96786. }
  96787. declare module BABYLON {
  96788. /**
  96789. * Define an interface for all classes that will hold resources
  96790. */
  96791. export interface IDisposable {
  96792. /**
  96793. * Releases all held resources
  96794. */
  96795. dispose(): void;
  96796. }
  96797. /** Interface defining initialization parameters for Scene class */
  96798. export interface SceneOptions {
  96799. /**
  96800. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96801. * It will improve performance when the number of geometries becomes important.
  96802. */
  96803. useGeometryUniqueIdsMap?: boolean;
  96804. /**
  96805. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96806. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96807. */
  96808. useMaterialMeshMap?: boolean;
  96809. /**
  96810. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96811. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96812. */
  96813. useClonedMeshhMap?: boolean;
  96814. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96815. virtual?: boolean;
  96816. }
  96817. /**
  96818. * Represents a scene to be rendered by the engine.
  96819. * @see http://doc.babylonjs.com/features/scene
  96820. */
  96821. export class Scene extends AbstractScene implements IAnimatable {
  96822. /** The fog is deactivated */
  96823. static readonly FOGMODE_NONE: number;
  96824. /** The fog density is following an exponential function */
  96825. static readonly FOGMODE_EXP: number;
  96826. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96827. static readonly FOGMODE_EXP2: number;
  96828. /** The fog density is following a linear function. */
  96829. static readonly FOGMODE_LINEAR: number;
  96830. /**
  96831. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96833. */
  96834. static MinDeltaTime: number;
  96835. /**
  96836. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96837. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96838. */
  96839. static MaxDeltaTime: number;
  96840. /**
  96841. * Factory used to create the default material.
  96842. * @param name The name of the material to create
  96843. * @param scene The scene to create the material for
  96844. * @returns The default material
  96845. */
  96846. static DefaultMaterialFactory(scene: Scene): Material;
  96847. /**
  96848. * Factory used to create the a collision coordinator.
  96849. * @returns The collision coordinator
  96850. */
  96851. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96852. /** @hidden */
  96853. _inputManager: InputManager;
  96854. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96855. cameraToUseForPointers: Nullable<Camera>;
  96856. /** @hidden */
  96857. readonly _isScene: boolean;
  96858. /**
  96859. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96860. */
  96861. autoClear: boolean;
  96862. /**
  96863. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96864. */
  96865. autoClearDepthAndStencil: boolean;
  96866. /**
  96867. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96868. */
  96869. clearColor: Color4;
  96870. /**
  96871. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96872. */
  96873. ambientColor: Color3;
  96874. /**
  96875. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96876. * It should only be one of the following (if not the default embedded one):
  96877. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96878. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96879. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96880. * The material properties need to be setup according to the type of texture in use.
  96881. */
  96882. environmentBRDFTexture: BaseTexture;
  96883. /** @hidden */
  96884. protected _environmentTexture: Nullable<BaseTexture>;
  96885. /**
  96886. * Texture used in all pbr material as the reflection texture.
  96887. * As in the majority of the scene they are the same (exception for multi room and so on),
  96888. * this is easier to reference from here than from all the materials.
  96889. */
  96890. /**
  96891. * Texture used in all pbr material as the reflection texture.
  96892. * As in the majority of the scene they are the same (exception for multi room and so on),
  96893. * this is easier to set here than in all the materials.
  96894. */
  96895. environmentTexture: Nullable<BaseTexture>;
  96896. /** @hidden */
  96897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96898. /**
  96899. * Default image processing configuration used either in the rendering
  96900. * Forward main pass or through the imageProcessingPostProcess if present.
  96901. * As in the majority of the scene they are the same (exception for multi camera),
  96902. * this is easier to reference from here than from all the materials and post process.
  96903. *
  96904. * No setter as we it is a shared configuration, you can set the values instead.
  96905. */
  96906. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96907. private _forceWireframe;
  96908. /**
  96909. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96910. */
  96911. forceWireframe: boolean;
  96912. private _forcePointsCloud;
  96913. /**
  96914. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96915. */
  96916. forcePointsCloud: boolean;
  96917. /**
  96918. * Gets or sets the active clipplane 1
  96919. */
  96920. clipPlane: Nullable<Plane>;
  96921. /**
  96922. * Gets or sets the active clipplane 2
  96923. */
  96924. clipPlane2: Nullable<Plane>;
  96925. /**
  96926. * Gets or sets the active clipplane 3
  96927. */
  96928. clipPlane3: Nullable<Plane>;
  96929. /**
  96930. * Gets or sets the active clipplane 4
  96931. */
  96932. clipPlane4: Nullable<Plane>;
  96933. /**
  96934. * Gets or sets a boolean indicating if animations are enabled
  96935. */
  96936. animationsEnabled: boolean;
  96937. private _animationPropertiesOverride;
  96938. /**
  96939. * Gets or sets the animation properties override
  96940. */
  96941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96942. /**
  96943. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96944. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96945. */
  96946. useConstantAnimationDeltaTime: boolean;
  96947. /**
  96948. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96949. * Please note that it requires to run a ray cast through the scene on every frame
  96950. */
  96951. constantlyUpdateMeshUnderPointer: boolean;
  96952. /**
  96953. * Defines the HTML cursor to use when hovering over interactive elements
  96954. */
  96955. hoverCursor: string;
  96956. /**
  96957. * Defines the HTML default cursor to use (empty by default)
  96958. */
  96959. defaultCursor: string;
  96960. /**
  96961. * This is used to call preventDefault() on pointer down
  96962. * in order to block unwanted artifacts like system double clicks
  96963. */
  96964. preventDefaultOnPointerDown: boolean;
  96965. /**
  96966. * This is used to call preventDefault() on pointer up
  96967. * in order to block unwanted artifacts like system double clicks
  96968. */
  96969. preventDefaultOnPointerUp: boolean;
  96970. /**
  96971. * Gets or sets user defined metadata
  96972. */
  96973. metadata: any;
  96974. /**
  96975. * For internal use only. Please do not use.
  96976. */
  96977. reservedDataStore: any;
  96978. /**
  96979. * Gets the name of the plugin used to load this scene (null by default)
  96980. */
  96981. loadingPluginName: string;
  96982. /**
  96983. * Use this array to add regular expressions used to disable offline support for specific urls
  96984. */
  96985. disableOfflineSupportExceptionRules: RegExp[];
  96986. /**
  96987. * An event triggered when the scene is disposed.
  96988. */
  96989. onDisposeObservable: Observable<Scene>;
  96990. private _onDisposeObserver;
  96991. /** Sets a function to be executed when this scene is disposed. */
  96992. onDispose: () => void;
  96993. /**
  96994. * An event triggered before rendering the scene (right after animations and physics)
  96995. */
  96996. onBeforeRenderObservable: Observable<Scene>;
  96997. private _onBeforeRenderObserver;
  96998. /** Sets a function to be executed before rendering this scene */
  96999. beforeRender: Nullable<() => void>;
  97000. /**
  97001. * An event triggered after rendering the scene
  97002. */
  97003. onAfterRenderObservable: Observable<Scene>;
  97004. /**
  97005. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97006. */
  97007. onAfterRenderCameraObservable: Observable<Camera>;
  97008. private _onAfterRenderObserver;
  97009. /** Sets a function to be executed after rendering this scene */
  97010. afterRender: Nullable<() => void>;
  97011. /**
  97012. * An event triggered before animating the scene
  97013. */
  97014. onBeforeAnimationsObservable: Observable<Scene>;
  97015. /**
  97016. * An event triggered after animations processing
  97017. */
  97018. onAfterAnimationsObservable: Observable<Scene>;
  97019. /**
  97020. * An event triggered before draw calls are ready to be sent
  97021. */
  97022. onBeforeDrawPhaseObservable: Observable<Scene>;
  97023. /**
  97024. * An event triggered after draw calls have been sent
  97025. */
  97026. onAfterDrawPhaseObservable: Observable<Scene>;
  97027. /**
  97028. * An event triggered when the scene is ready
  97029. */
  97030. onReadyObservable: Observable<Scene>;
  97031. /**
  97032. * An event triggered before rendering a camera
  97033. */
  97034. onBeforeCameraRenderObservable: Observable<Camera>;
  97035. private _onBeforeCameraRenderObserver;
  97036. /** Sets a function to be executed before rendering a camera*/
  97037. beforeCameraRender: () => void;
  97038. /**
  97039. * An event triggered after rendering a camera
  97040. */
  97041. onAfterCameraRenderObservable: Observable<Camera>;
  97042. private _onAfterCameraRenderObserver;
  97043. /** Sets a function to be executed after rendering a camera*/
  97044. afterCameraRender: () => void;
  97045. /**
  97046. * An event triggered when active meshes evaluation is about to start
  97047. */
  97048. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97049. /**
  97050. * An event triggered when active meshes evaluation is done
  97051. */
  97052. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97053. /**
  97054. * An event triggered when particles rendering is about to start
  97055. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97056. */
  97057. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97058. /**
  97059. * An event triggered when particles rendering is done
  97060. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97061. */
  97062. onAfterParticlesRenderingObservable: Observable<Scene>;
  97063. /**
  97064. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97065. */
  97066. onDataLoadedObservable: Observable<Scene>;
  97067. /**
  97068. * An event triggered when a camera is created
  97069. */
  97070. onNewCameraAddedObservable: Observable<Camera>;
  97071. /**
  97072. * An event triggered when a camera is removed
  97073. */
  97074. onCameraRemovedObservable: Observable<Camera>;
  97075. /**
  97076. * An event triggered when a light is created
  97077. */
  97078. onNewLightAddedObservable: Observable<Light>;
  97079. /**
  97080. * An event triggered when a light is removed
  97081. */
  97082. onLightRemovedObservable: Observable<Light>;
  97083. /**
  97084. * An event triggered when a geometry is created
  97085. */
  97086. onNewGeometryAddedObservable: Observable<Geometry>;
  97087. /**
  97088. * An event triggered when a geometry is removed
  97089. */
  97090. onGeometryRemovedObservable: Observable<Geometry>;
  97091. /**
  97092. * An event triggered when a transform node is created
  97093. */
  97094. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97095. /**
  97096. * An event triggered when a transform node is removed
  97097. */
  97098. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97099. /**
  97100. * An event triggered when a mesh is created
  97101. */
  97102. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97103. /**
  97104. * An event triggered when a mesh is removed
  97105. */
  97106. onMeshRemovedObservable: Observable<AbstractMesh>;
  97107. /**
  97108. * An event triggered when a skeleton is created
  97109. */
  97110. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97111. /**
  97112. * An event triggered when a skeleton is removed
  97113. */
  97114. onSkeletonRemovedObservable: Observable<Skeleton>;
  97115. /**
  97116. * An event triggered when a material is created
  97117. */
  97118. onNewMaterialAddedObservable: Observable<Material>;
  97119. /**
  97120. * An event triggered when a material is removed
  97121. */
  97122. onMaterialRemovedObservable: Observable<Material>;
  97123. /**
  97124. * An event triggered when a texture is created
  97125. */
  97126. onNewTextureAddedObservable: Observable<BaseTexture>;
  97127. /**
  97128. * An event triggered when a texture is removed
  97129. */
  97130. onTextureRemovedObservable: Observable<BaseTexture>;
  97131. /**
  97132. * An event triggered when render targets are about to be rendered
  97133. * Can happen multiple times per frame.
  97134. */
  97135. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97136. /**
  97137. * An event triggered when render targets were rendered.
  97138. * Can happen multiple times per frame.
  97139. */
  97140. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97141. /**
  97142. * An event triggered before calculating deterministic simulation step
  97143. */
  97144. onBeforeStepObservable: Observable<Scene>;
  97145. /**
  97146. * An event triggered after calculating deterministic simulation step
  97147. */
  97148. onAfterStepObservable: Observable<Scene>;
  97149. /**
  97150. * An event triggered when the activeCamera property is updated
  97151. */
  97152. onActiveCameraChanged: Observable<Scene>;
  97153. /**
  97154. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97155. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97156. * 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)
  97157. */
  97158. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97159. /**
  97160. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97161. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97162. * 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)
  97163. */
  97164. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97165. /**
  97166. * This Observable will when a mesh has been imported into the scene.
  97167. */
  97168. onMeshImportedObservable: Observable<AbstractMesh>;
  97169. /**
  97170. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97171. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97172. */
  97173. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97174. /** @hidden */
  97175. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97176. /**
  97177. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97178. */
  97179. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97180. /**
  97181. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97182. */
  97183. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97184. /**
  97185. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97186. */
  97187. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97188. /** Callback called when a pointer move is detected */
  97189. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97190. /** Callback called when a pointer down is detected */
  97191. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97192. /** Callback called when a pointer up is detected */
  97193. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97194. /** Callback called when a pointer pick is detected */
  97195. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97196. /**
  97197. * 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).
  97198. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97199. */
  97200. onPrePointerObservable: Observable<PointerInfoPre>;
  97201. /**
  97202. * Observable event triggered each time an input event is received from the rendering canvas
  97203. */
  97204. onPointerObservable: Observable<PointerInfo>;
  97205. /**
  97206. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97207. */
  97208. readonly unTranslatedPointer: Vector2;
  97209. /**
  97210. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97211. */
  97212. static DragMovementThreshold: number;
  97213. /**
  97214. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97215. */
  97216. static LongPressDelay: number;
  97217. /**
  97218. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97219. */
  97220. static DoubleClickDelay: number;
  97221. /** If you need to check double click without raising a single click at first click, enable this flag */
  97222. static ExclusiveDoubleClickMode: boolean;
  97223. /** @hidden */
  97224. _mirroredCameraPosition: Nullable<Vector3>;
  97225. /**
  97226. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97227. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97228. */
  97229. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97230. /**
  97231. * Observable event triggered each time an keyboard event is received from the hosting window
  97232. */
  97233. onKeyboardObservable: Observable<KeyboardInfo>;
  97234. private _useRightHandedSystem;
  97235. /**
  97236. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97237. */
  97238. useRightHandedSystem: boolean;
  97239. private _timeAccumulator;
  97240. private _currentStepId;
  97241. private _currentInternalStep;
  97242. /**
  97243. * Sets the step Id used by deterministic lock step
  97244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97245. * @param newStepId defines the step Id
  97246. */
  97247. setStepId(newStepId: number): void;
  97248. /**
  97249. * Gets the step Id used by deterministic lock step
  97250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97251. * @returns the step Id
  97252. */
  97253. getStepId(): number;
  97254. /**
  97255. * Gets the internal step used by deterministic lock step
  97256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97257. * @returns the internal step
  97258. */
  97259. getInternalStep(): number;
  97260. private _fogEnabled;
  97261. /**
  97262. * Gets or sets a boolean indicating if fog is enabled on this scene
  97263. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97264. * (Default is true)
  97265. */
  97266. fogEnabled: boolean;
  97267. private _fogMode;
  97268. /**
  97269. * Gets or sets the fog mode to use
  97270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97271. * | mode | value |
  97272. * | --- | --- |
  97273. * | FOGMODE_NONE | 0 |
  97274. * | FOGMODE_EXP | 1 |
  97275. * | FOGMODE_EXP2 | 2 |
  97276. * | FOGMODE_LINEAR | 3 |
  97277. */
  97278. fogMode: number;
  97279. /**
  97280. * Gets or sets the fog color to use
  97281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97282. * (Default is Color3(0.2, 0.2, 0.3))
  97283. */
  97284. fogColor: Color3;
  97285. /**
  97286. * Gets or sets the fog density to use
  97287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97288. * (Default is 0.1)
  97289. */
  97290. fogDensity: number;
  97291. /**
  97292. * Gets or sets the fog start distance to use
  97293. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97294. * (Default is 0)
  97295. */
  97296. fogStart: number;
  97297. /**
  97298. * Gets or sets the fog end distance to use
  97299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97300. * (Default is 1000)
  97301. */
  97302. fogEnd: number;
  97303. private _shadowsEnabled;
  97304. /**
  97305. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97306. */
  97307. shadowsEnabled: boolean;
  97308. private _lightsEnabled;
  97309. /**
  97310. * Gets or sets a boolean indicating if lights are enabled on this scene
  97311. */
  97312. lightsEnabled: boolean;
  97313. /** All of the active cameras added to this scene. */
  97314. activeCameras: Camera[];
  97315. /** @hidden */
  97316. _activeCamera: Nullable<Camera>;
  97317. /** Gets or sets the current active camera */
  97318. activeCamera: Nullable<Camera>;
  97319. private _defaultMaterial;
  97320. /** The default material used on meshes when no material is affected */
  97321. /** The default material used on meshes when no material is affected */
  97322. defaultMaterial: Material;
  97323. private _texturesEnabled;
  97324. /**
  97325. * Gets or sets a boolean indicating if textures are enabled on this scene
  97326. */
  97327. texturesEnabled: boolean;
  97328. /**
  97329. * Gets or sets a boolean indicating if particles are enabled on this scene
  97330. */
  97331. particlesEnabled: boolean;
  97332. /**
  97333. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97334. */
  97335. spritesEnabled: boolean;
  97336. private _skeletonsEnabled;
  97337. /**
  97338. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97339. */
  97340. skeletonsEnabled: boolean;
  97341. /**
  97342. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97343. */
  97344. lensFlaresEnabled: boolean;
  97345. /**
  97346. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97348. */
  97349. collisionsEnabled: boolean;
  97350. private _collisionCoordinator;
  97351. /** @hidden */
  97352. readonly collisionCoordinator: ICollisionCoordinator;
  97353. /**
  97354. * Defines the gravity applied to this scene (used only for collisions)
  97355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97356. */
  97357. gravity: Vector3;
  97358. /**
  97359. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97360. */
  97361. postProcessesEnabled: boolean;
  97362. /**
  97363. * The list of postprocesses added to the scene
  97364. */
  97365. postProcesses: PostProcess[];
  97366. /**
  97367. * Gets the current postprocess manager
  97368. */
  97369. postProcessManager: PostProcessManager;
  97370. /**
  97371. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97372. */
  97373. renderTargetsEnabled: boolean;
  97374. /**
  97375. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97376. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97377. */
  97378. dumpNextRenderTargets: boolean;
  97379. /**
  97380. * The list of user defined render targets added to the scene
  97381. */
  97382. customRenderTargets: RenderTargetTexture[];
  97383. /**
  97384. * Defines if texture loading must be delayed
  97385. * If true, textures will only be loaded when they need to be rendered
  97386. */
  97387. useDelayedTextureLoading: boolean;
  97388. /**
  97389. * Gets the list of meshes imported to the scene through SceneLoader
  97390. */
  97391. importedMeshesFiles: String[];
  97392. /**
  97393. * Gets or sets a boolean indicating if probes are enabled on this scene
  97394. */
  97395. probesEnabled: boolean;
  97396. /**
  97397. * Gets or sets the current offline provider to use to store scene data
  97398. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97399. */
  97400. offlineProvider: IOfflineProvider;
  97401. /**
  97402. * Gets or sets the action manager associated with the scene
  97403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97404. */
  97405. actionManager: AbstractActionManager;
  97406. private _meshesForIntersections;
  97407. /**
  97408. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97409. */
  97410. proceduralTexturesEnabled: boolean;
  97411. private _engine;
  97412. private _totalVertices;
  97413. /** @hidden */
  97414. _activeIndices: PerfCounter;
  97415. /** @hidden */
  97416. _activeParticles: PerfCounter;
  97417. /** @hidden */
  97418. _activeBones: PerfCounter;
  97419. private _animationRatio;
  97420. /** @hidden */
  97421. _animationTimeLast: number;
  97422. /** @hidden */
  97423. _animationTime: number;
  97424. /**
  97425. * Gets or sets a general scale for animation speed
  97426. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97427. */
  97428. animationTimeScale: number;
  97429. /** @hidden */
  97430. _cachedMaterial: Nullable<Material>;
  97431. /** @hidden */
  97432. _cachedEffect: Nullable<Effect>;
  97433. /** @hidden */
  97434. _cachedVisibility: Nullable<number>;
  97435. private _renderId;
  97436. private _frameId;
  97437. private _executeWhenReadyTimeoutId;
  97438. private _intermediateRendering;
  97439. private _viewUpdateFlag;
  97440. private _projectionUpdateFlag;
  97441. /** @hidden */
  97442. _toBeDisposed: Nullable<IDisposable>[];
  97443. private _activeRequests;
  97444. /** @hidden */
  97445. _pendingData: any[];
  97446. private _isDisposed;
  97447. /**
  97448. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97449. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97450. */
  97451. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97452. private _activeMeshes;
  97453. private _processedMaterials;
  97454. private _renderTargets;
  97455. /** @hidden */
  97456. _activeParticleSystems: SmartArray<IParticleSystem>;
  97457. private _activeSkeletons;
  97458. private _softwareSkinnedMeshes;
  97459. private _renderingManager;
  97460. /** @hidden */
  97461. _activeAnimatables: Animatable[];
  97462. private _transformMatrix;
  97463. private _sceneUbo;
  97464. /** @hidden */
  97465. _viewMatrix: Matrix;
  97466. private _projectionMatrix;
  97467. /** @hidden */
  97468. _forcedViewPosition: Nullable<Vector3>;
  97469. /** @hidden */
  97470. _frustumPlanes: Plane[];
  97471. /**
  97472. * Gets the list of frustum planes (built from the active camera)
  97473. */
  97474. readonly frustumPlanes: Plane[];
  97475. /**
  97476. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97477. * This is useful if there are more lights that the maximum simulteanous authorized
  97478. */
  97479. requireLightSorting: boolean;
  97480. /** @hidden */
  97481. readonly useMaterialMeshMap: boolean;
  97482. /** @hidden */
  97483. readonly useClonedMeshhMap: boolean;
  97484. private _externalData;
  97485. private _uid;
  97486. /**
  97487. * @hidden
  97488. * Backing store of defined scene components.
  97489. */
  97490. _components: ISceneComponent[];
  97491. /**
  97492. * @hidden
  97493. * Backing store of defined scene components.
  97494. */
  97495. _serializableComponents: ISceneSerializableComponent[];
  97496. /**
  97497. * List of components to register on the next registration step.
  97498. */
  97499. private _transientComponents;
  97500. /**
  97501. * Registers the transient components if needed.
  97502. */
  97503. private _registerTransientComponents;
  97504. /**
  97505. * @hidden
  97506. * Add a component to the scene.
  97507. * Note that the ccomponent could be registered on th next frame if this is called after
  97508. * the register component stage.
  97509. * @param component Defines the component to add to the scene
  97510. */
  97511. _addComponent(component: ISceneComponent): void;
  97512. /**
  97513. * @hidden
  97514. * Gets a component from the scene.
  97515. * @param name defines the name of the component to retrieve
  97516. * @returns the component or null if not present
  97517. */
  97518. _getComponent(name: string): Nullable<ISceneComponent>;
  97519. /**
  97520. * @hidden
  97521. * Defines the actions happening before camera updates.
  97522. */
  97523. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97524. /**
  97525. * @hidden
  97526. * Defines the actions happening before clear the canvas.
  97527. */
  97528. _beforeClearStage: Stage<SimpleStageAction>;
  97529. /**
  97530. * @hidden
  97531. * Defines the actions when collecting render targets for the frame.
  97532. */
  97533. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97534. /**
  97535. * @hidden
  97536. * Defines the actions happening for one camera in the frame.
  97537. */
  97538. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97539. /**
  97540. * @hidden
  97541. * Defines the actions happening during the per mesh ready checks.
  97542. */
  97543. _isReadyForMeshStage: Stage<MeshStageAction>;
  97544. /**
  97545. * @hidden
  97546. * Defines the actions happening before evaluate active mesh checks.
  97547. */
  97548. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97549. /**
  97550. * @hidden
  97551. * Defines the actions happening during the evaluate sub mesh checks.
  97552. */
  97553. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97554. /**
  97555. * @hidden
  97556. * Defines the actions happening during the active mesh stage.
  97557. */
  97558. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97559. /**
  97560. * @hidden
  97561. * Defines the actions happening during the per camera render target step.
  97562. */
  97563. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97564. /**
  97565. * @hidden
  97566. * Defines the actions happening just before the active camera is drawing.
  97567. */
  97568. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97569. /**
  97570. * @hidden
  97571. * Defines the actions happening just before a render target is drawing.
  97572. */
  97573. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97574. /**
  97575. * @hidden
  97576. * Defines the actions happening just before a rendering group is drawing.
  97577. */
  97578. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97579. /**
  97580. * @hidden
  97581. * Defines the actions happening just before a mesh is drawing.
  97582. */
  97583. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97584. /**
  97585. * @hidden
  97586. * Defines the actions happening just after a mesh has been drawn.
  97587. */
  97588. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97589. /**
  97590. * @hidden
  97591. * Defines the actions happening just after a rendering group has been drawn.
  97592. */
  97593. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97594. /**
  97595. * @hidden
  97596. * Defines the actions happening just after the active camera has been drawn.
  97597. */
  97598. _afterCameraDrawStage: Stage<CameraStageAction>;
  97599. /**
  97600. * @hidden
  97601. * Defines the actions happening just after a render target has been drawn.
  97602. */
  97603. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97604. /**
  97605. * @hidden
  97606. * Defines the actions happening just after rendering all cameras and computing intersections.
  97607. */
  97608. _afterRenderStage: Stage<SimpleStageAction>;
  97609. /**
  97610. * @hidden
  97611. * Defines the actions happening when a pointer move event happens.
  97612. */
  97613. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97614. /**
  97615. * @hidden
  97616. * Defines the actions happening when a pointer down event happens.
  97617. */
  97618. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97619. /**
  97620. * @hidden
  97621. * Defines the actions happening when a pointer up event happens.
  97622. */
  97623. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97624. /**
  97625. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97626. */
  97627. private geometriesByUniqueId;
  97628. /**
  97629. * Creates a new Scene
  97630. * @param engine defines the engine to use to render this scene
  97631. * @param options defines the scene options
  97632. */
  97633. constructor(engine: Engine, options?: SceneOptions);
  97634. /**
  97635. * Gets a string idenfifying the name of the class
  97636. * @returns "Scene" string
  97637. */
  97638. getClassName(): string;
  97639. private _defaultMeshCandidates;
  97640. /**
  97641. * @hidden
  97642. */
  97643. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97644. private _defaultSubMeshCandidates;
  97645. /**
  97646. * @hidden
  97647. */
  97648. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97649. /**
  97650. * Sets the default candidate providers for the scene.
  97651. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97652. * and getCollidingSubMeshCandidates to their default function
  97653. */
  97654. setDefaultCandidateProviders(): void;
  97655. /**
  97656. * Gets the mesh that is currently under the pointer
  97657. */
  97658. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97659. /**
  97660. * Gets or sets the current on-screen X position of the pointer
  97661. */
  97662. pointerX: number;
  97663. /**
  97664. * Gets or sets the current on-screen Y position of the pointer
  97665. */
  97666. pointerY: number;
  97667. /**
  97668. * Gets the cached material (ie. the latest rendered one)
  97669. * @returns the cached material
  97670. */
  97671. getCachedMaterial(): Nullable<Material>;
  97672. /**
  97673. * Gets the cached effect (ie. the latest rendered one)
  97674. * @returns the cached effect
  97675. */
  97676. getCachedEffect(): Nullable<Effect>;
  97677. /**
  97678. * Gets the cached visibility state (ie. the latest rendered one)
  97679. * @returns the cached visibility state
  97680. */
  97681. getCachedVisibility(): Nullable<number>;
  97682. /**
  97683. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97684. * @param material defines the current material
  97685. * @param effect defines the current effect
  97686. * @param visibility defines the current visibility state
  97687. * @returns true if one parameter is not cached
  97688. */
  97689. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97690. /**
  97691. * Gets the engine associated with the scene
  97692. * @returns an Engine
  97693. */
  97694. getEngine(): Engine;
  97695. /**
  97696. * Gets the total number of vertices rendered per frame
  97697. * @returns the total number of vertices rendered per frame
  97698. */
  97699. getTotalVertices(): number;
  97700. /**
  97701. * Gets the performance counter for total vertices
  97702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97703. */
  97704. readonly totalVerticesPerfCounter: PerfCounter;
  97705. /**
  97706. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97707. * @returns the total number of active indices rendered per frame
  97708. */
  97709. getActiveIndices(): number;
  97710. /**
  97711. * Gets the performance counter for active indices
  97712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97713. */
  97714. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97715. /**
  97716. * Gets the total number of active particles rendered per frame
  97717. * @returns the total number of active particles rendered per frame
  97718. */
  97719. getActiveParticles(): number;
  97720. /**
  97721. * Gets the performance counter for active particles
  97722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97723. */
  97724. readonly activeParticlesPerfCounter: PerfCounter;
  97725. /**
  97726. * Gets the total number of active bones rendered per frame
  97727. * @returns the total number of active bones rendered per frame
  97728. */
  97729. getActiveBones(): number;
  97730. /**
  97731. * Gets the performance counter for active bones
  97732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97733. */
  97734. readonly activeBonesPerfCounter: PerfCounter;
  97735. /**
  97736. * Gets the array of active meshes
  97737. * @returns an array of AbstractMesh
  97738. */
  97739. getActiveMeshes(): SmartArray<AbstractMesh>;
  97740. /**
  97741. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97742. * @returns a number
  97743. */
  97744. getAnimationRatio(): number;
  97745. /**
  97746. * Gets an unique Id for the current render phase
  97747. * @returns a number
  97748. */
  97749. getRenderId(): number;
  97750. /**
  97751. * Gets an unique Id for the current frame
  97752. * @returns a number
  97753. */
  97754. getFrameId(): number;
  97755. /** Call this function if you want to manually increment the render Id*/
  97756. incrementRenderId(): void;
  97757. private _createUbo;
  97758. /**
  97759. * Use this method to simulate a pointer move on a mesh
  97760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97763. * @returns the current scene
  97764. */
  97765. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97766. /**
  97767. * Use this method to simulate a pointer down on a mesh
  97768. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97769. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97770. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97771. * @returns the current scene
  97772. */
  97773. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97774. /**
  97775. * Use this method to simulate a pointer up on a mesh
  97776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97779. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97780. * @returns the current scene
  97781. */
  97782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97783. /**
  97784. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97785. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97786. * @returns true if the pointer was captured
  97787. */
  97788. isPointerCaptured(pointerId?: number): boolean;
  97789. /**
  97790. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97791. * @param attachUp defines if you want to attach events to pointerup
  97792. * @param attachDown defines if you want to attach events to pointerdown
  97793. * @param attachMove defines if you want to attach events to pointermove
  97794. */
  97795. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97796. /** Detaches all event handlers*/
  97797. detachControl(): void;
  97798. /**
  97799. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97800. * Delay loaded resources are not taking in account
  97801. * @return true if all required resources are ready
  97802. */
  97803. isReady(): boolean;
  97804. /** Resets all cached information relative to material (including effect and visibility) */
  97805. resetCachedMaterial(): void;
  97806. /**
  97807. * Registers a function to be called before every frame render
  97808. * @param func defines the function to register
  97809. */
  97810. registerBeforeRender(func: () => void): void;
  97811. /**
  97812. * Unregisters a function called before every frame render
  97813. * @param func defines the function to unregister
  97814. */
  97815. unregisterBeforeRender(func: () => void): void;
  97816. /**
  97817. * Registers a function to be called after every frame render
  97818. * @param func defines the function to register
  97819. */
  97820. registerAfterRender(func: () => void): void;
  97821. /**
  97822. * Unregisters a function called after every frame render
  97823. * @param func defines the function to unregister
  97824. */
  97825. unregisterAfterRender(func: () => void): void;
  97826. private _executeOnceBeforeRender;
  97827. /**
  97828. * The provided function will run before render once and will be disposed afterwards.
  97829. * A timeout delay can be provided so that the function will be executed in N ms.
  97830. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97831. * @param func The function to be executed.
  97832. * @param timeout optional delay in ms
  97833. */
  97834. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97835. /** @hidden */
  97836. _addPendingData(data: any): void;
  97837. /** @hidden */
  97838. _removePendingData(data: any): void;
  97839. /**
  97840. * Returns the number of items waiting to be loaded
  97841. * @returns the number of items waiting to be loaded
  97842. */
  97843. getWaitingItemsCount(): number;
  97844. /**
  97845. * Returns a boolean indicating if the scene is still loading data
  97846. */
  97847. readonly isLoading: boolean;
  97848. /**
  97849. * Registers a function to be executed when the scene is ready
  97850. * @param {Function} func - the function to be executed
  97851. */
  97852. executeWhenReady(func: () => void): void;
  97853. /**
  97854. * Returns a promise that resolves when the scene is ready
  97855. * @returns A promise that resolves when the scene is ready
  97856. */
  97857. whenReadyAsync(): Promise<void>;
  97858. /** @hidden */
  97859. _checkIsReady(): void;
  97860. /**
  97861. * Gets all animatable attached to the scene
  97862. */
  97863. readonly animatables: Animatable[];
  97864. /**
  97865. * Resets the last animation time frame.
  97866. * Useful to override when animations start running when loading a scene for the first time.
  97867. */
  97868. resetLastAnimationTimeFrame(): void;
  97869. /**
  97870. * Gets the current view matrix
  97871. * @returns a Matrix
  97872. */
  97873. getViewMatrix(): Matrix;
  97874. /**
  97875. * Gets the current projection matrix
  97876. * @returns a Matrix
  97877. */
  97878. getProjectionMatrix(): Matrix;
  97879. /**
  97880. * Gets the current transform matrix
  97881. * @returns a Matrix made of View * Projection
  97882. */
  97883. getTransformMatrix(): Matrix;
  97884. /**
  97885. * Sets the current transform matrix
  97886. * @param viewL defines the View matrix to use
  97887. * @param projectionL defines the Projection matrix to use
  97888. * @param viewR defines the right View matrix to use (if provided)
  97889. * @param projectionR defines the right Projection matrix to use (if provided)
  97890. */
  97891. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97892. /**
  97893. * Gets the uniform buffer used to store scene data
  97894. * @returns a UniformBuffer
  97895. */
  97896. getSceneUniformBuffer(): UniformBuffer;
  97897. /**
  97898. * Gets an unique (relatively to the current scene) Id
  97899. * @returns an unique number for the scene
  97900. */
  97901. getUniqueId(): number;
  97902. /**
  97903. * Add a mesh to the list of scene's meshes
  97904. * @param newMesh defines the mesh to add
  97905. * @param recursive if all child meshes should also be added to the scene
  97906. */
  97907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97908. /**
  97909. * Remove a mesh for the list of scene's meshes
  97910. * @param toRemove defines the mesh to remove
  97911. * @param recursive if all child meshes should also be removed from the scene
  97912. * @returns the index where the mesh was in the mesh list
  97913. */
  97914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97915. /**
  97916. * Add a transform node to the list of scene's transform nodes
  97917. * @param newTransformNode defines the transform node to add
  97918. */
  97919. addTransformNode(newTransformNode: TransformNode): void;
  97920. /**
  97921. * Remove a transform node for the list of scene's transform nodes
  97922. * @param toRemove defines the transform node to remove
  97923. * @returns the index where the transform node was in the transform node list
  97924. */
  97925. removeTransformNode(toRemove: TransformNode): number;
  97926. /**
  97927. * Remove a skeleton for the list of scene's skeletons
  97928. * @param toRemove defines the skeleton to remove
  97929. * @returns the index where the skeleton was in the skeleton list
  97930. */
  97931. removeSkeleton(toRemove: Skeleton): number;
  97932. /**
  97933. * Remove a morph target for the list of scene's morph targets
  97934. * @param toRemove defines the morph target to remove
  97935. * @returns the index where the morph target was in the morph target list
  97936. */
  97937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97938. /**
  97939. * Remove a light for the list of scene's lights
  97940. * @param toRemove defines the light to remove
  97941. * @returns the index where the light was in the light list
  97942. */
  97943. removeLight(toRemove: Light): number;
  97944. /**
  97945. * Remove a camera for the list of scene's cameras
  97946. * @param toRemove defines the camera to remove
  97947. * @returns the index where the camera was in the camera list
  97948. */
  97949. removeCamera(toRemove: Camera): number;
  97950. /**
  97951. * Remove a particle system for the list of scene's particle systems
  97952. * @param toRemove defines the particle system to remove
  97953. * @returns the index where the particle system was in the particle system list
  97954. */
  97955. removeParticleSystem(toRemove: IParticleSystem): number;
  97956. /**
  97957. * Remove a animation for the list of scene's animations
  97958. * @param toRemove defines the animation to remove
  97959. * @returns the index where the animation was in the animation list
  97960. */
  97961. removeAnimation(toRemove: Animation): number;
  97962. /**
  97963. * Will stop the animation of the given target
  97964. * @param target - the target
  97965. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97966. * @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)
  97967. */
  97968. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97969. /**
  97970. * Removes the given animation group from this scene.
  97971. * @param toRemove The animation group to remove
  97972. * @returns The index of the removed animation group
  97973. */
  97974. removeAnimationGroup(toRemove: AnimationGroup): number;
  97975. /**
  97976. * Removes the given multi-material from this scene.
  97977. * @param toRemove The multi-material to remove
  97978. * @returns The index of the removed multi-material
  97979. */
  97980. removeMultiMaterial(toRemove: MultiMaterial): number;
  97981. /**
  97982. * Removes the given material from this scene.
  97983. * @param toRemove The material to remove
  97984. * @returns The index of the removed material
  97985. */
  97986. removeMaterial(toRemove: Material): number;
  97987. /**
  97988. * Removes the given action manager from this scene.
  97989. * @param toRemove The action manager to remove
  97990. * @returns The index of the removed action manager
  97991. */
  97992. removeActionManager(toRemove: AbstractActionManager): number;
  97993. /**
  97994. * Removes the given texture from this scene.
  97995. * @param toRemove The texture to remove
  97996. * @returns The index of the removed texture
  97997. */
  97998. removeTexture(toRemove: BaseTexture): number;
  97999. /**
  98000. * Adds the given light to this scene
  98001. * @param newLight The light to add
  98002. */
  98003. addLight(newLight: Light): void;
  98004. /**
  98005. * Sorts the list list based on light priorities
  98006. */
  98007. sortLightsByPriority(): void;
  98008. /**
  98009. * Adds the given camera to this scene
  98010. * @param newCamera The camera to add
  98011. */
  98012. addCamera(newCamera: Camera): void;
  98013. /**
  98014. * Adds the given skeleton to this scene
  98015. * @param newSkeleton The skeleton to add
  98016. */
  98017. addSkeleton(newSkeleton: Skeleton): void;
  98018. /**
  98019. * Adds the given particle system to this scene
  98020. * @param newParticleSystem The particle system to add
  98021. */
  98022. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98023. /**
  98024. * Adds the given animation to this scene
  98025. * @param newAnimation The animation to add
  98026. */
  98027. addAnimation(newAnimation: Animation): void;
  98028. /**
  98029. * Adds the given animation group to this scene.
  98030. * @param newAnimationGroup The animation group to add
  98031. */
  98032. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98033. /**
  98034. * Adds the given multi-material to this scene
  98035. * @param newMultiMaterial The multi-material to add
  98036. */
  98037. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98038. /**
  98039. * Adds the given material to this scene
  98040. * @param newMaterial The material to add
  98041. */
  98042. addMaterial(newMaterial: Material): void;
  98043. /**
  98044. * Adds the given morph target to this scene
  98045. * @param newMorphTargetManager The morph target to add
  98046. */
  98047. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98048. /**
  98049. * Adds the given geometry to this scene
  98050. * @param newGeometry The geometry to add
  98051. */
  98052. addGeometry(newGeometry: Geometry): void;
  98053. /**
  98054. * Adds the given action manager to this scene
  98055. * @param newActionManager The action manager to add
  98056. */
  98057. addActionManager(newActionManager: AbstractActionManager): void;
  98058. /**
  98059. * Adds the given texture to this scene.
  98060. * @param newTexture The texture to add
  98061. */
  98062. addTexture(newTexture: BaseTexture): void;
  98063. /**
  98064. * Switch active camera
  98065. * @param newCamera defines the new active camera
  98066. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98067. */
  98068. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98069. /**
  98070. * sets the active camera of the scene using its ID
  98071. * @param id defines the camera's ID
  98072. * @return the new active camera or null if none found.
  98073. */
  98074. setActiveCameraByID(id: string): Nullable<Camera>;
  98075. /**
  98076. * sets the active camera of the scene using its name
  98077. * @param name defines the camera's name
  98078. * @returns the new active camera or null if none found.
  98079. */
  98080. setActiveCameraByName(name: string): Nullable<Camera>;
  98081. /**
  98082. * get an animation group using its name
  98083. * @param name defines the material's name
  98084. * @return the animation group or null if none found.
  98085. */
  98086. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98087. /**
  98088. * Get a material using its unique id
  98089. * @param uniqueId defines the material's unique id
  98090. * @return the material or null if none found.
  98091. */
  98092. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98093. /**
  98094. * get a material using its id
  98095. * @param id defines the material's ID
  98096. * @return the material or null if none found.
  98097. */
  98098. getMaterialByID(id: string): Nullable<Material>;
  98099. /**
  98100. * Gets a the last added material using a given id
  98101. * @param id defines the material's ID
  98102. * @return the last material with the given id or null if none found.
  98103. */
  98104. getLastMaterialByID(id: string): Nullable<Material>;
  98105. /**
  98106. * Gets a material using its name
  98107. * @param name defines the material's name
  98108. * @return the material or null if none found.
  98109. */
  98110. getMaterialByName(name: string): Nullable<Material>;
  98111. /**
  98112. * Get a texture using its unique id
  98113. * @param uniqueId defines the texture's unique id
  98114. * @return the texture or null if none found.
  98115. */
  98116. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98117. /**
  98118. * Gets a camera using its id
  98119. * @param id defines the id to look for
  98120. * @returns the camera or null if not found
  98121. */
  98122. getCameraByID(id: string): Nullable<Camera>;
  98123. /**
  98124. * Gets a camera using its unique id
  98125. * @param uniqueId defines the unique id to look for
  98126. * @returns the camera or null if not found
  98127. */
  98128. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98129. /**
  98130. * Gets a camera using its name
  98131. * @param name defines the camera's name
  98132. * @return the camera or null if none found.
  98133. */
  98134. getCameraByName(name: string): Nullable<Camera>;
  98135. /**
  98136. * Gets a bone using its id
  98137. * @param id defines the bone's id
  98138. * @return the bone or null if not found
  98139. */
  98140. getBoneByID(id: string): Nullable<Bone>;
  98141. /**
  98142. * Gets a bone using its id
  98143. * @param name defines the bone's name
  98144. * @return the bone or null if not found
  98145. */
  98146. getBoneByName(name: string): Nullable<Bone>;
  98147. /**
  98148. * Gets a light node using its name
  98149. * @param name defines the the light's name
  98150. * @return the light or null if none found.
  98151. */
  98152. getLightByName(name: string): Nullable<Light>;
  98153. /**
  98154. * Gets a light node using its id
  98155. * @param id defines the light's id
  98156. * @return the light or null if none found.
  98157. */
  98158. getLightByID(id: string): Nullable<Light>;
  98159. /**
  98160. * Gets a light node using its scene-generated unique ID
  98161. * @param uniqueId defines the light's unique id
  98162. * @return the light or null if none found.
  98163. */
  98164. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98165. /**
  98166. * Gets a particle system by id
  98167. * @param id defines the particle system id
  98168. * @return the corresponding system or null if none found
  98169. */
  98170. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98171. /**
  98172. * Gets a geometry using its ID
  98173. * @param id defines the geometry's id
  98174. * @return the geometry or null if none found.
  98175. */
  98176. getGeometryByID(id: string): Nullable<Geometry>;
  98177. private _getGeometryByUniqueID;
  98178. /**
  98179. * Add a new geometry to this scene
  98180. * @param geometry defines the geometry to be added to the scene.
  98181. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98182. * @return a boolean defining if the geometry was added or not
  98183. */
  98184. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98185. /**
  98186. * Removes an existing geometry
  98187. * @param geometry defines the geometry to be removed from the scene
  98188. * @return a boolean defining if the geometry was removed or not
  98189. */
  98190. removeGeometry(geometry: Geometry): boolean;
  98191. /**
  98192. * Gets the list of geometries attached to the scene
  98193. * @returns an array of Geometry
  98194. */
  98195. getGeometries(): Geometry[];
  98196. /**
  98197. * Gets the first added mesh found of a given ID
  98198. * @param id defines the id to search for
  98199. * @return the mesh found or null if not found at all
  98200. */
  98201. getMeshByID(id: string): Nullable<AbstractMesh>;
  98202. /**
  98203. * Gets a list of meshes using their id
  98204. * @param id defines the id to search for
  98205. * @returns a list of meshes
  98206. */
  98207. getMeshesByID(id: string): Array<AbstractMesh>;
  98208. /**
  98209. * Gets the first added transform node found of a given ID
  98210. * @param id defines the id to search for
  98211. * @return the found transform node or null if not found at all.
  98212. */
  98213. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98214. /**
  98215. * Gets a transform node with its auto-generated unique id
  98216. * @param uniqueId efines the unique id to search for
  98217. * @return the found transform node or null if not found at all.
  98218. */
  98219. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98220. /**
  98221. * Gets a list of transform nodes using their id
  98222. * @param id defines the id to search for
  98223. * @returns a list of transform nodes
  98224. */
  98225. getTransformNodesByID(id: string): Array<TransformNode>;
  98226. /**
  98227. * Gets a mesh with its auto-generated unique id
  98228. * @param uniqueId defines the unique id to search for
  98229. * @return the found mesh or null if not found at all.
  98230. */
  98231. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98232. /**
  98233. * Gets a the last added mesh using a given id
  98234. * @param id defines the id to search for
  98235. * @return the found mesh or null if not found at all.
  98236. */
  98237. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98238. /**
  98239. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98240. * @param id defines the id to search for
  98241. * @return the found node or null if not found at all
  98242. */
  98243. getLastEntryByID(id: string): Nullable<Node>;
  98244. /**
  98245. * Gets a node (Mesh, Camera, Light) using a given id
  98246. * @param id defines the id to search for
  98247. * @return the found node or null if not found at all
  98248. */
  98249. getNodeByID(id: string): Nullable<Node>;
  98250. /**
  98251. * Gets a node (Mesh, Camera, Light) using a given name
  98252. * @param name defines the name to search for
  98253. * @return the found node or null if not found at all.
  98254. */
  98255. getNodeByName(name: string): Nullable<Node>;
  98256. /**
  98257. * Gets a mesh using a given name
  98258. * @param name defines the name to search for
  98259. * @return the found mesh or null if not found at all.
  98260. */
  98261. getMeshByName(name: string): Nullable<AbstractMesh>;
  98262. /**
  98263. * Gets a transform node using a given name
  98264. * @param name defines the name to search for
  98265. * @return the found transform node or null if not found at all.
  98266. */
  98267. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98268. /**
  98269. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98270. * @param id defines the id to search for
  98271. * @return the found skeleton or null if not found at all.
  98272. */
  98273. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98274. /**
  98275. * Gets a skeleton using a given auto generated unique id
  98276. * @param uniqueId defines the unique id to search for
  98277. * @return the found skeleton or null if not found at all.
  98278. */
  98279. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98280. /**
  98281. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98282. * @param id defines the id to search for
  98283. * @return the found skeleton or null if not found at all.
  98284. */
  98285. getSkeletonById(id: string): Nullable<Skeleton>;
  98286. /**
  98287. * Gets a skeleton using a given name
  98288. * @param name defines the name to search for
  98289. * @return the found skeleton or null if not found at all.
  98290. */
  98291. getSkeletonByName(name: string): Nullable<Skeleton>;
  98292. /**
  98293. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98294. * @param id defines the id to search for
  98295. * @return the found morph target manager or null if not found at all.
  98296. */
  98297. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98298. /**
  98299. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98300. * @param id defines the id to search for
  98301. * @return the found morph target or null if not found at all.
  98302. */
  98303. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98304. /**
  98305. * Gets a boolean indicating if the given mesh is active
  98306. * @param mesh defines the mesh to look for
  98307. * @returns true if the mesh is in the active list
  98308. */
  98309. isActiveMesh(mesh: AbstractMesh): boolean;
  98310. /**
  98311. * Return a unique id as a string which can serve as an identifier for the scene
  98312. */
  98313. readonly uid: string;
  98314. /**
  98315. * Add an externaly attached data from its key.
  98316. * This method call will fail and return false, if such key already exists.
  98317. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98318. * @param key the unique key that identifies the data
  98319. * @param data the data object to associate to the key for this Engine instance
  98320. * @return true if no such key were already present and the data was added successfully, false otherwise
  98321. */
  98322. addExternalData<T>(key: string, data: T): boolean;
  98323. /**
  98324. * Get an externaly attached data from its key
  98325. * @param key the unique key that identifies the data
  98326. * @return the associated data, if present (can be null), or undefined if not present
  98327. */
  98328. getExternalData<T>(key: string): Nullable<T>;
  98329. /**
  98330. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98331. * @param key the unique key that identifies the data
  98332. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98333. * @return the associated data, can be null if the factory returned null.
  98334. */
  98335. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98336. /**
  98337. * Remove an externaly attached data from the Engine instance
  98338. * @param key the unique key that identifies the data
  98339. * @return true if the data was successfully removed, false if it doesn't exist
  98340. */
  98341. removeExternalData(key: string): boolean;
  98342. private _evaluateSubMesh;
  98343. /**
  98344. * Clear the processed materials smart array preventing retention point in material dispose.
  98345. */
  98346. freeProcessedMaterials(): void;
  98347. private _preventFreeActiveMeshesAndRenderingGroups;
  98348. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98349. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98350. * when disposing several meshes in a row or a hierarchy of meshes.
  98351. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98352. */
  98353. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98354. /**
  98355. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98356. */
  98357. freeActiveMeshes(): void;
  98358. /**
  98359. * Clear the info related to rendering groups preventing retention points during dispose.
  98360. */
  98361. freeRenderingGroups(): void;
  98362. /** @hidden */
  98363. _isInIntermediateRendering(): boolean;
  98364. /**
  98365. * Lambda returning the list of potentially active meshes.
  98366. */
  98367. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98368. /**
  98369. * Lambda returning the list of potentially active sub meshes.
  98370. */
  98371. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98372. /**
  98373. * Lambda returning the list of potentially intersecting sub meshes.
  98374. */
  98375. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98376. /**
  98377. * Lambda returning the list of potentially colliding sub meshes.
  98378. */
  98379. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98380. private _activeMeshesFrozen;
  98381. /**
  98382. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98383. * @returns the current scene
  98384. */
  98385. freezeActiveMeshes(): Scene;
  98386. /**
  98387. * Use this function to restart evaluating active meshes on every frame
  98388. * @returns the current scene
  98389. */
  98390. unfreezeActiveMeshes(): Scene;
  98391. private _evaluateActiveMeshes;
  98392. private _activeMesh;
  98393. /**
  98394. * Update the transform matrix to update from the current active camera
  98395. * @param force defines a boolean used to force the update even if cache is up to date
  98396. */
  98397. updateTransformMatrix(force?: boolean): void;
  98398. private _bindFrameBuffer;
  98399. /** @hidden */
  98400. _allowPostProcessClearColor: boolean;
  98401. /** @hidden */
  98402. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98403. private _processSubCameras;
  98404. private _checkIntersections;
  98405. /** @hidden */
  98406. _advancePhysicsEngineStep(step: number): void;
  98407. /**
  98408. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98409. */
  98410. getDeterministicFrameTime: () => number;
  98411. /** @hidden */
  98412. _animate(): void;
  98413. /** Execute all animations (for a frame) */
  98414. animate(): void;
  98415. /**
  98416. * Render the scene
  98417. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98418. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98419. */
  98420. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98421. /**
  98422. * Freeze all materials
  98423. * A frozen material will not be updatable but should be faster to render
  98424. */
  98425. freezeMaterials(): void;
  98426. /**
  98427. * Unfreeze all materials
  98428. * A frozen material will not be updatable but should be faster to render
  98429. */
  98430. unfreezeMaterials(): void;
  98431. /**
  98432. * Releases all held ressources
  98433. */
  98434. dispose(): void;
  98435. /**
  98436. * Gets if the scene is already disposed
  98437. */
  98438. readonly isDisposed: boolean;
  98439. /**
  98440. * Call this function to reduce memory footprint of the scene.
  98441. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98442. */
  98443. clearCachedVertexData(): void;
  98444. /**
  98445. * This function will remove the local cached buffer data from texture.
  98446. * It will save memory but will prevent the texture from being rebuilt
  98447. */
  98448. cleanCachedTextureBuffer(): void;
  98449. /**
  98450. * Get the world extend vectors with an optional filter
  98451. *
  98452. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98453. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98454. */
  98455. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98456. min: Vector3;
  98457. max: Vector3;
  98458. };
  98459. /**
  98460. * Creates a ray that can be used to pick in the scene
  98461. * @param x defines the x coordinate of the origin (on-screen)
  98462. * @param y defines the y coordinate of the origin (on-screen)
  98463. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98464. * @param camera defines the camera to use for the picking
  98465. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98466. * @returns a Ray
  98467. */
  98468. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98469. /**
  98470. * Creates a ray that can be used to pick in the scene
  98471. * @param x defines the x coordinate of the origin (on-screen)
  98472. * @param y defines the y coordinate of the origin (on-screen)
  98473. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98474. * @param result defines the ray where to store the picking ray
  98475. * @param camera defines the camera to use for the picking
  98476. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98477. * @returns the current scene
  98478. */
  98479. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98480. /**
  98481. * Creates a ray that can be used to pick in the scene
  98482. * @param x defines the x coordinate of the origin (on-screen)
  98483. * @param y defines the y coordinate of the origin (on-screen)
  98484. * @param camera defines the camera to use for the picking
  98485. * @returns a Ray
  98486. */
  98487. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98488. /**
  98489. * Creates a ray that can be used to pick in the scene
  98490. * @param x defines the x coordinate of the origin (on-screen)
  98491. * @param y defines the y coordinate of the origin (on-screen)
  98492. * @param result defines the ray where to store the picking ray
  98493. * @param camera defines the camera to use for the picking
  98494. * @returns the current scene
  98495. */
  98496. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98497. /** Launch a ray to try to pick a mesh in the scene
  98498. * @param x position on screen
  98499. * @param y position on screen
  98500. * @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
  98501. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98502. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98504. * @returns a PickingInfo
  98505. */
  98506. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98507. /** Use the given ray to pick a mesh in the scene
  98508. * @param ray The ray to use to pick meshes
  98509. * @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
  98510. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98511. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98512. * @returns a PickingInfo
  98513. */
  98514. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98515. /**
  98516. * Launch a ray to try to pick a mesh in the scene
  98517. * @param x X position on screen
  98518. * @param y Y position on screen
  98519. * @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
  98520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98521. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98522. * @returns an array of PickingInfo
  98523. */
  98524. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98525. /**
  98526. * Launch a ray to try to pick a mesh in the scene
  98527. * @param ray Ray to use
  98528. * @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
  98529. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98530. * @returns an array of PickingInfo
  98531. */
  98532. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98533. /**
  98534. * Force the value of meshUnderPointer
  98535. * @param mesh defines the mesh to use
  98536. */
  98537. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98538. /**
  98539. * Gets the mesh under the pointer
  98540. * @returns a Mesh or null if no mesh is under the pointer
  98541. */
  98542. getPointerOverMesh(): Nullable<AbstractMesh>;
  98543. /** @hidden */
  98544. _rebuildGeometries(): void;
  98545. /** @hidden */
  98546. _rebuildTextures(): void;
  98547. private _getByTags;
  98548. /**
  98549. * Get a list of meshes by tags
  98550. * @param tagsQuery defines the tags query to use
  98551. * @param forEach defines a predicate used to filter results
  98552. * @returns an array of Mesh
  98553. */
  98554. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98555. /**
  98556. * Get a list of cameras by tags
  98557. * @param tagsQuery defines the tags query to use
  98558. * @param forEach defines a predicate used to filter results
  98559. * @returns an array of Camera
  98560. */
  98561. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98562. /**
  98563. * Get a list of lights by tags
  98564. * @param tagsQuery defines the tags query to use
  98565. * @param forEach defines a predicate used to filter results
  98566. * @returns an array of Light
  98567. */
  98568. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98569. /**
  98570. * Get a list of materials by tags
  98571. * @param tagsQuery defines the tags query to use
  98572. * @param forEach defines a predicate used to filter results
  98573. * @returns an array of Material
  98574. */
  98575. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98576. /**
  98577. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98578. * This allowed control for front to back rendering or reversly depending of the special needs.
  98579. *
  98580. * @param renderingGroupId The rendering group id corresponding to its index
  98581. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98582. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98583. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98584. */
  98585. 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;
  98586. /**
  98587. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98588. *
  98589. * @param renderingGroupId The rendering group id corresponding to its index
  98590. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98591. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98592. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98593. */
  98594. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98595. /**
  98596. * Gets the current auto clear configuration for one rendering group of the rendering
  98597. * manager.
  98598. * @param index the rendering group index to get the information for
  98599. * @returns The auto clear setup for the requested rendering group
  98600. */
  98601. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98602. private _blockMaterialDirtyMechanism;
  98603. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98604. blockMaterialDirtyMechanism: boolean;
  98605. /**
  98606. * Will flag all materials as dirty to trigger new shader compilation
  98607. * @param flag defines the flag used to specify which material part must be marked as dirty
  98608. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98609. */
  98610. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98611. /** @hidden */
  98612. _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;
  98613. /** @hidden */
  98614. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98615. }
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * Set of assets to keep when moving a scene into an asset container.
  98620. */
  98621. export class KeepAssets extends AbstractScene {
  98622. }
  98623. /**
  98624. * Container with a set of assets that can be added or removed from a scene.
  98625. */
  98626. export class AssetContainer extends AbstractScene {
  98627. /**
  98628. * The scene the AssetContainer belongs to.
  98629. */
  98630. scene: Scene;
  98631. /**
  98632. * Instantiates an AssetContainer.
  98633. * @param scene The scene the AssetContainer belongs to.
  98634. */
  98635. constructor(scene: Scene);
  98636. /**
  98637. * Adds all the assets from the container to the scene.
  98638. */
  98639. addAllToScene(): void;
  98640. /**
  98641. * Removes all the assets in the container from the scene
  98642. */
  98643. removeAllFromScene(): void;
  98644. /**
  98645. * Disposes all the assets in the container
  98646. */
  98647. dispose(): void;
  98648. private _moveAssets;
  98649. /**
  98650. * Removes all the assets contained in the scene and adds them to the container.
  98651. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98652. */
  98653. moveAllFromScene(keepAssets?: KeepAssets): void;
  98654. /**
  98655. * 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.
  98656. * @returns the root mesh
  98657. */
  98658. createRootMesh(): Mesh;
  98659. }
  98660. }
  98661. declare module BABYLON {
  98662. /**
  98663. * Defines how the parser contract is defined.
  98664. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98665. */
  98666. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98667. /**
  98668. * Defines how the individual parser contract is defined.
  98669. * These parser can parse an individual asset
  98670. */
  98671. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98672. /**
  98673. * Base class of the scene acting as a container for the different elements composing a scene.
  98674. * This class is dynamically extended by the different components of the scene increasing
  98675. * flexibility and reducing coupling
  98676. */
  98677. export abstract class AbstractScene {
  98678. /**
  98679. * Stores the list of available parsers in the application.
  98680. */
  98681. private static _BabylonFileParsers;
  98682. /**
  98683. * Stores the list of available individual parsers in the application.
  98684. */
  98685. private static _IndividualBabylonFileParsers;
  98686. /**
  98687. * Adds a parser in the list of available ones
  98688. * @param name Defines the name of the parser
  98689. * @param parser Defines the parser to add
  98690. */
  98691. static AddParser(name: string, parser: BabylonFileParser): void;
  98692. /**
  98693. * Gets a general parser from the list of avaialble ones
  98694. * @param name Defines the name of the parser
  98695. * @returns the requested parser or null
  98696. */
  98697. static GetParser(name: string): Nullable<BabylonFileParser>;
  98698. /**
  98699. * Adds n individual parser in the list of available ones
  98700. * @param name Defines the name of the parser
  98701. * @param parser Defines the parser to add
  98702. */
  98703. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98704. /**
  98705. * Gets an individual parser from the list of avaialble ones
  98706. * @param name Defines the name of the parser
  98707. * @returns the requested parser or null
  98708. */
  98709. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98710. /**
  98711. * Parser json data and populate both a scene and its associated container object
  98712. * @param jsonData Defines the data to parse
  98713. * @param scene Defines the scene to parse the data for
  98714. * @param container Defines the container attached to the parsing sequence
  98715. * @param rootUrl Defines the root url of the data
  98716. */
  98717. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98718. /**
  98719. * Gets the list of root nodes (ie. nodes with no parent)
  98720. */
  98721. rootNodes: Node[];
  98722. /** All of the cameras added to this scene
  98723. * @see http://doc.babylonjs.com/babylon101/cameras
  98724. */
  98725. cameras: Camera[];
  98726. /**
  98727. * All of the lights added to this scene
  98728. * @see http://doc.babylonjs.com/babylon101/lights
  98729. */
  98730. lights: Light[];
  98731. /**
  98732. * All of the (abstract) meshes added to this scene
  98733. */
  98734. meshes: AbstractMesh[];
  98735. /**
  98736. * The list of skeletons added to the scene
  98737. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98738. */
  98739. skeletons: Skeleton[];
  98740. /**
  98741. * All of the particle systems added to this scene
  98742. * @see http://doc.babylonjs.com/babylon101/particles
  98743. */
  98744. particleSystems: IParticleSystem[];
  98745. /**
  98746. * Gets a list of Animations associated with the scene
  98747. */
  98748. animations: Animation[];
  98749. /**
  98750. * All of the animation groups added to this scene
  98751. * @see http://doc.babylonjs.com/how_to/group
  98752. */
  98753. animationGroups: AnimationGroup[];
  98754. /**
  98755. * All of the multi-materials added to this scene
  98756. * @see http://doc.babylonjs.com/how_to/multi_materials
  98757. */
  98758. multiMaterials: MultiMaterial[];
  98759. /**
  98760. * All of the materials added to this scene
  98761. * In the context of a Scene, it is not supposed to be modified manually.
  98762. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98763. * Note also that the order of the Material wihin the array is not significant and might change.
  98764. * @see http://doc.babylonjs.com/babylon101/materials
  98765. */
  98766. materials: Material[];
  98767. /**
  98768. * The list of morph target managers added to the scene
  98769. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98770. */
  98771. morphTargetManagers: MorphTargetManager[];
  98772. /**
  98773. * The list of geometries used in the scene.
  98774. */
  98775. geometries: Geometry[];
  98776. /**
  98777. * All of the tranform nodes added to this scene
  98778. * In the context of a Scene, it is not supposed to be modified manually.
  98779. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98780. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98781. * @see http://doc.babylonjs.com/how_to/transformnode
  98782. */
  98783. transformNodes: TransformNode[];
  98784. /**
  98785. * ActionManagers available on the scene.
  98786. */
  98787. actionManagers: AbstractActionManager[];
  98788. /**
  98789. * Textures to keep.
  98790. */
  98791. textures: BaseTexture[];
  98792. /**
  98793. * Environment texture for the scene
  98794. */
  98795. environmentTexture: Nullable<BaseTexture>;
  98796. }
  98797. }
  98798. declare module BABYLON {
  98799. /**
  98800. * Interface used to define options for Sound class
  98801. */
  98802. export interface ISoundOptions {
  98803. /**
  98804. * Does the sound autoplay once loaded.
  98805. */
  98806. autoplay?: boolean;
  98807. /**
  98808. * Does the sound loop after it finishes playing once.
  98809. */
  98810. loop?: boolean;
  98811. /**
  98812. * Sound's volume
  98813. */
  98814. volume?: number;
  98815. /**
  98816. * Is it a spatial sound?
  98817. */
  98818. spatialSound?: boolean;
  98819. /**
  98820. * Maximum distance to hear that sound
  98821. */
  98822. maxDistance?: number;
  98823. /**
  98824. * Uses user defined attenuation function
  98825. */
  98826. useCustomAttenuation?: boolean;
  98827. /**
  98828. * Define the roll off factor of spatial sounds.
  98829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98830. */
  98831. rolloffFactor?: number;
  98832. /**
  98833. * Define the reference distance the sound should be heard perfectly.
  98834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98835. */
  98836. refDistance?: number;
  98837. /**
  98838. * Define the distance attenuation model the sound will follow.
  98839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98840. */
  98841. distanceModel?: string;
  98842. /**
  98843. * Defines the playback speed (1 by default)
  98844. */
  98845. playbackRate?: number;
  98846. /**
  98847. * Defines if the sound is from a streaming source
  98848. */
  98849. streaming?: boolean;
  98850. /**
  98851. * Defines an optional length (in seconds) inside the sound file
  98852. */
  98853. length?: number;
  98854. /**
  98855. * Defines an optional offset (in seconds) inside the sound file
  98856. */
  98857. offset?: number;
  98858. /**
  98859. * If true, URLs will not be required to state the audio file codec to use.
  98860. */
  98861. skipCodecCheck?: boolean;
  98862. }
  98863. /**
  98864. * Defines a sound that can be played in the application.
  98865. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98867. */
  98868. export class Sound {
  98869. /**
  98870. * The name of the sound in the scene.
  98871. */
  98872. name: string;
  98873. /**
  98874. * Does the sound autoplay once loaded.
  98875. */
  98876. autoplay: boolean;
  98877. /**
  98878. * Does the sound loop after it finishes playing once.
  98879. */
  98880. loop: boolean;
  98881. /**
  98882. * Does the sound use a custom attenuation curve to simulate the falloff
  98883. * happening when the source gets further away from the camera.
  98884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98885. */
  98886. useCustomAttenuation: boolean;
  98887. /**
  98888. * The sound track id this sound belongs to.
  98889. */
  98890. soundTrackId: number;
  98891. /**
  98892. * Is this sound currently played.
  98893. */
  98894. isPlaying: boolean;
  98895. /**
  98896. * Is this sound currently paused.
  98897. */
  98898. isPaused: boolean;
  98899. /**
  98900. * Does this sound enables spatial sound.
  98901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98902. */
  98903. spatialSound: boolean;
  98904. /**
  98905. * Define the reference distance the sound should be heard perfectly.
  98906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98907. */
  98908. refDistance: number;
  98909. /**
  98910. * Define the roll off factor of spatial sounds.
  98911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98912. */
  98913. rolloffFactor: number;
  98914. /**
  98915. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98917. */
  98918. maxDistance: number;
  98919. /**
  98920. * Define the distance attenuation model the sound will follow.
  98921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98922. */
  98923. distanceModel: string;
  98924. /**
  98925. * @hidden
  98926. * Back Compat
  98927. **/
  98928. onended: () => any;
  98929. /**
  98930. * Observable event when the current playing sound finishes.
  98931. */
  98932. onEndedObservable: Observable<Sound>;
  98933. private _panningModel;
  98934. private _playbackRate;
  98935. private _streaming;
  98936. private _startTime;
  98937. private _startOffset;
  98938. private _position;
  98939. /** @hidden */
  98940. _positionInEmitterSpace: boolean;
  98941. private _localDirection;
  98942. private _volume;
  98943. private _isReadyToPlay;
  98944. private _isDirectional;
  98945. private _readyToPlayCallback;
  98946. private _audioBuffer;
  98947. private _soundSource;
  98948. private _streamingSource;
  98949. private _soundPanner;
  98950. private _soundGain;
  98951. private _inputAudioNode;
  98952. private _outputAudioNode;
  98953. private _coneInnerAngle;
  98954. private _coneOuterAngle;
  98955. private _coneOuterGain;
  98956. private _scene;
  98957. private _connectedTransformNode;
  98958. private _customAttenuationFunction;
  98959. private _registerFunc;
  98960. private _isOutputConnected;
  98961. private _htmlAudioElement;
  98962. private _urlType;
  98963. private _length?;
  98964. private _offset?;
  98965. /** @hidden */
  98966. static _SceneComponentInitialization: (scene: Scene) => void;
  98967. /**
  98968. * Create a sound and attach it to a scene
  98969. * @param name Name of your sound
  98970. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98971. * @param scene defines the scene the sound belongs to
  98972. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98973. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98974. */
  98975. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98976. /**
  98977. * Release the sound and its associated resources
  98978. */
  98979. dispose(): void;
  98980. /**
  98981. * Gets if the sounds is ready to be played or not.
  98982. * @returns true if ready, otherwise false
  98983. */
  98984. isReady(): boolean;
  98985. private _soundLoaded;
  98986. /**
  98987. * Sets the data of the sound from an audiobuffer
  98988. * @param audioBuffer The audioBuffer containing the data
  98989. */
  98990. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98991. /**
  98992. * Updates the current sounds options such as maxdistance, loop...
  98993. * @param options A JSON object containing values named as the object properties
  98994. */
  98995. updateOptions(options: ISoundOptions): void;
  98996. private _createSpatialParameters;
  98997. private _updateSpatialParameters;
  98998. /**
  98999. * Switch the panning model to HRTF:
  99000. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99002. */
  99003. switchPanningModelToHRTF(): void;
  99004. /**
  99005. * Switch the panning model to Equal Power:
  99006. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99008. */
  99009. switchPanningModelToEqualPower(): void;
  99010. private _switchPanningModel;
  99011. /**
  99012. * Connect this sound to a sound track audio node like gain...
  99013. * @param soundTrackAudioNode the sound track audio node to connect to
  99014. */
  99015. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99016. /**
  99017. * Transform this sound into a directional source
  99018. * @param coneInnerAngle Size of the inner cone in degree
  99019. * @param coneOuterAngle Size of the outer cone in degree
  99020. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99021. */
  99022. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99023. /**
  99024. * Gets or sets the inner angle for the directional cone.
  99025. */
  99026. /**
  99027. * Gets or sets the inner angle for the directional cone.
  99028. */
  99029. directionalConeInnerAngle: number;
  99030. /**
  99031. * Gets or sets the outer angle for the directional cone.
  99032. */
  99033. /**
  99034. * Gets or sets the outer angle for the directional cone.
  99035. */
  99036. directionalConeOuterAngle: number;
  99037. /**
  99038. * Sets the position of the emitter if spatial sound is enabled
  99039. * @param newPosition Defines the new posisiton
  99040. */
  99041. setPosition(newPosition: Vector3): void;
  99042. /**
  99043. * Sets the local direction of the emitter if spatial sound is enabled
  99044. * @param newLocalDirection Defines the new local direction
  99045. */
  99046. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99047. private _updateDirection;
  99048. /** @hidden */
  99049. updateDistanceFromListener(): void;
  99050. /**
  99051. * Sets a new custom attenuation function for the sound.
  99052. * @param callback Defines the function used for the attenuation
  99053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99054. */
  99055. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99056. /**
  99057. * Play the sound
  99058. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99059. * @param offset (optional) Start the sound at a specific time in seconds
  99060. * @param length (optional) Sound duration (in seconds)
  99061. */
  99062. play(time?: number, offset?: number, length?: number): void;
  99063. private _onended;
  99064. /**
  99065. * Stop the sound
  99066. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99067. */
  99068. stop(time?: number): void;
  99069. /**
  99070. * Put the sound in pause
  99071. */
  99072. pause(): void;
  99073. /**
  99074. * Sets a dedicated volume for this sounds
  99075. * @param newVolume Define the new volume of the sound
  99076. * @param time Define time for gradual change to new volume
  99077. */
  99078. setVolume(newVolume: number, time?: number): void;
  99079. /**
  99080. * Set the sound play back rate
  99081. * @param newPlaybackRate Define the playback rate the sound should be played at
  99082. */
  99083. setPlaybackRate(newPlaybackRate: number): void;
  99084. /**
  99085. * Gets the volume of the sound.
  99086. * @returns the volume of the sound
  99087. */
  99088. getVolume(): number;
  99089. /**
  99090. * Attach the sound to a dedicated mesh
  99091. * @param transformNode The transform node to connect the sound with
  99092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99093. */
  99094. attachToMesh(transformNode: TransformNode): void;
  99095. /**
  99096. * Detach the sound from the previously attached mesh
  99097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99098. */
  99099. detachFromMesh(): void;
  99100. private _onRegisterAfterWorldMatrixUpdate;
  99101. /**
  99102. * Clone the current sound in the scene.
  99103. * @returns the new sound clone
  99104. */
  99105. clone(): Nullable<Sound>;
  99106. /**
  99107. * Gets the current underlying audio buffer containing the data
  99108. * @returns the audio buffer
  99109. */
  99110. getAudioBuffer(): Nullable<AudioBuffer>;
  99111. /**
  99112. * Serializes the Sound in a JSON representation
  99113. * @returns the JSON representation of the sound
  99114. */
  99115. serialize(): any;
  99116. /**
  99117. * Parse a JSON representation of a sound to innstantiate in a given scene
  99118. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99119. * @param scene Define the scene the new parsed sound should be created in
  99120. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99121. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99122. * @returns the newly parsed sound
  99123. */
  99124. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99125. }
  99126. }
  99127. declare module BABYLON {
  99128. /**
  99129. * This defines an action helpful to play a defined sound on a triggered action.
  99130. */
  99131. export class PlaySoundAction extends Action {
  99132. private _sound;
  99133. /**
  99134. * Instantiate the action
  99135. * @param triggerOptions defines the trigger options
  99136. * @param sound defines the sound to play
  99137. * @param condition defines the trigger related conditions
  99138. */
  99139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99140. /** @hidden */
  99141. _prepare(): void;
  99142. /**
  99143. * Execute the action and play the sound.
  99144. */
  99145. execute(): void;
  99146. /**
  99147. * Serializes the actions and its related information.
  99148. * @param parent defines the object to serialize in
  99149. * @returns the serialized object
  99150. */
  99151. serialize(parent: any): any;
  99152. }
  99153. /**
  99154. * This defines an action helpful to stop a defined sound on a triggered action.
  99155. */
  99156. export class StopSoundAction extends Action {
  99157. private _sound;
  99158. /**
  99159. * Instantiate the action
  99160. * @param triggerOptions defines the trigger options
  99161. * @param sound defines the sound to stop
  99162. * @param condition defines the trigger related conditions
  99163. */
  99164. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99165. /** @hidden */
  99166. _prepare(): void;
  99167. /**
  99168. * Execute the action and stop the sound.
  99169. */
  99170. execute(): void;
  99171. /**
  99172. * Serializes the actions and its related information.
  99173. * @param parent defines the object to serialize in
  99174. * @returns the serialized object
  99175. */
  99176. serialize(parent: any): any;
  99177. }
  99178. }
  99179. declare module BABYLON {
  99180. /**
  99181. * This defines an action responsible to change the value of a property
  99182. * by interpolating between its current value and the newly set one once triggered.
  99183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99184. */
  99185. export class InterpolateValueAction extends Action {
  99186. /**
  99187. * Defines the path of the property where the value should be interpolated
  99188. */
  99189. propertyPath: string;
  99190. /**
  99191. * Defines the target value at the end of the interpolation.
  99192. */
  99193. value: any;
  99194. /**
  99195. * Defines the time it will take for the property to interpolate to the value.
  99196. */
  99197. duration: number;
  99198. /**
  99199. * Defines if the other scene animations should be stopped when the action has been triggered
  99200. */
  99201. stopOtherAnimations?: boolean;
  99202. /**
  99203. * Defines a callback raised once the interpolation animation has been done.
  99204. */
  99205. onInterpolationDone?: () => void;
  99206. /**
  99207. * Observable triggered once the interpolation animation has been done.
  99208. */
  99209. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99210. private _target;
  99211. private _effectiveTarget;
  99212. private _property;
  99213. /**
  99214. * Instantiate the action
  99215. * @param triggerOptions defines the trigger options
  99216. * @param target defines the object containing the value to interpolate
  99217. * @param propertyPath defines the path to the property in the target object
  99218. * @param value defines the target value at the end of the interpolation
  99219. * @param duration deines the time it will take for the property to interpolate to the value.
  99220. * @param condition defines the trigger related conditions
  99221. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99222. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99223. */
  99224. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99225. /** @hidden */
  99226. _prepare(): void;
  99227. /**
  99228. * Execute the action starts the value interpolation.
  99229. */
  99230. execute(): void;
  99231. /**
  99232. * Serializes the actions and its related information.
  99233. * @param parent defines the object to serialize in
  99234. * @returns the serialized object
  99235. */
  99236. serialize(parent: any): any;
  99237. }
  99238. }
  99239. declare module BABYLON {
  99240. /**
  99241. * Options allowed during the creation of a sound track.
  99242. */
  99243. export interface ISoundTrackOptions {
  99244. /**
  99245. * The volume the sound track should take during creation
  99246. */
  99247. volume?: number;
  99248. /**
  99249. * Define if the sound track is the main sound track of the scene
  99250. */
  99251. mainTrack?: boolean;
  99252. }
  99253. /**
  99254. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99255. * It will be also used in a future release to apply effects on a specific track.
  99256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99257. */
  99258. export class SoundTrack {
  99259. /**
  99260. * The unique identifier of the sound track in the scene.
  99261. */
  99262. id: number;
  99263. /**
  99264. * The list of sounds included in the sound track.
  99265. */
  99266. soundCollection: Array<Sound>;
  99267. private _outputAudioNode;
  99268. private _scene;
  99269. private _isMainTrack;
  99270. private _connectedAnalyser;
  99271. private _options;
  99272. private _isInitialized;
  99273. /**
  99274. * Creates a new sound track.
  99275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99276. * @param scene Define the scene the sound track belongs to
  99277. * @param options
  99278. */
  99279. constructor(scene: Scene, options?: ISoundTrackOptions);
  99280. private _initializeSoundTrackAudioGraph;
  99281. /**
  99282. * Release the sound track and its associated resources
  99283. */
  99284. dispose(): void;
  99285. /**
  99286. * Adds a sound to this sound track
  99287. * @param sound define the cound to add
  99288. * @ignoreNaming
  99289. */
  99290. AddSound(sound: Sound): void;
  99291. /**
  99292. * Removes a sound to this sound track
  99293. * @param sound define the cound to remove
  99294. * @ignoreNaming
  99295. */
  99296. RemoveSound(sound: Sound): void;
  99297. /**
  99298. * Set a global volume for the full sound track.
  99299. * @param newVolume Define the new volume of the sound track
  99300. */
  99301. setVolume(newVolume: number): void;
  99302. /**
  99303. * Switch the panning model to HRTF:
  99304. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99306. */
  99307. switchPanningModelToHRTF(): void;
  99308. /**
  99309. * Switch the panning model to Equal Power:
  99310. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99312. */
  99313. switchPanningModelToEqualPower(): void;
  99314. /**
  99315. * Connect the sound track to an audio analyser allowing some amazing
  99316. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99318. * @param analyser The analyser to connect to the engine
  99319. */
  99320. connectToAnalyser(analyser: Analyser): void;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. interface AbstractScene {
  99325. /**
  99326. * The list of sounds used in the scene.
  99327. */
  99328. sounds: Nullable<Array<Sound>>;
  99329. }
  99330. interface Scene {
  99331. /**
  99332. * @hidden
  99333. * Backing field
  99334. */
  99335. _mainSoundTrack: SoundTrack;
  99336. /**
  99337. * The main sound track played by the scene.
  99338. * It cotains your primary collection of sounds.
  99339. */
  99340. mainSoundTrack: SoundTrack;
  99341. /**
  99342. * The list of sound tracks added to the scene
  99343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99344. */
  99345. soundTracks: Nullable<Array<SoundTrack>>;
  99346. /**
  99347. * Gets a sound using a given name
  99348. * @param name defines the name to search for
  99349. * @return the found sound or null if not found at all.
  99350. */
  99351. getSoundByName(name: string): Nullable<Sound>;
  99352. /**
  99353. * Gets or sets if audio support is enabled
  99354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99355. */
  99356. audioEnabled: boolean;
  99357. /**
  99358. * Gets or sets if audio will be output to headphones
  99359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99360. */
  99361. headphone: boolean;
  99362. }
  99363. /**
  99364. * Defines the sound scene component responsible to manage any sounds
  99365. * in a given scene.
  99366. */
  99367. export class AudioSceneComponent implements ISceneSerializableComponent {
  99368. /**
  99369. * The component name helpfull to identify the component in the list of scene components.
  99370. */
  99371. readonly name: string;
  99372. /**
  99373. * The scene the component belongs to.
  99374. */
  99375. scene: Scene;
  99376. private _audioEnabled;
  99377. /**
  99378. * Gets whether audio is enabled or not.
  99379. * Please use related enable/disable method to switch state.
  99380. */
  99381. readonly audioEnabled: boolean;
  99382. private _headphone;
  99383. /**
  99384. * Gets whether audio is outputing to headphone or not.
  99385. * Please use the according Switch methods to change output.
  99386. */
  99387. readonly headphone: boolean;
  99388. /**
  99389. * Creates a new instance of the component for the given scene
  99390. * @param scene Defines the scene to register the component in
  99391. */
  99392. constructor(scene: Scene);
  99393. /**
  99394. * Registers the component in a given scene
  99395. */
  99396. register(): void;
  99397. /**
  99398. * Rebuilds the elements related to this component in case of
  99399. * context lost for instance.
  99400. */
  99401. rebuild(): void;
  99402. /**
  99403. * Serializes the component data to the specified json object
  99404. * @param serializationObject The object to serialize to
  99405. */
  99406. serialize(serializationObject: any): void;
  99407. /**
  99408. * Adds all the elements from the container to the scene
  99409. * @param container the container holding the elements
  99410. */
  99411. addFromContainer(container: AbstractScene): void;
  99412. /**
  99413. * Removes all the elements in the container from the scene
  99414. * @param container contains the elements to remove
  99415. * @param dispose if the removed element should be disposed (default: false)
  99416. */
  99417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99418. /**
  99419. * Disposes the component and the associated ressources.
  99420. */
  99421. dispose(): void;
  99422. /**
  99423. * Disables audio in the associated scene.
  99424. */
  99425. disableAudio(): void;
  99426. /**
  99427. * Enables audio in the associated scene.
  99428. */
  99429. enableAudio(): void;
  99430. /**
  99431. * Switch audio to headphone output.
  99432. */
  99433. switchAudioModeForHeadphones(): void;
  99434. /**
  99435. * Switch audio to normal speakers.
  99436. */
  99437. switchAudioModeForNormalSpeakers(): void;
  99438. private _afterRender;
  99439. }
  99440. }
  99441. declare module BABYLON {
  99442. /**
  99443. * Wraps one or more Sound objects and selects one with random weight for playback.
  99444. */
  99445. export class WeightedSound {
  99446. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99447. loop: boolean;
  99448. private _coneInnerAngle;
  99449. private _coneOuterAngle;
  99450. private _volume;
  99451. /** A Sound is currently playing. */
  99452. isPlaying: boolean;
  99453. /** A Sound is currently paused. */
  99454. isPaused: boolean;
  99455. private _sounds;
  99456. private _weights;
  99457. private _currentIndex?;
  99458. /**
  99459. * Creates a new WeightedSound from the list of sounds given.
  99460. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99461. * @param sounds Array of Sounds that will be selected from.
  99462. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99463. */
  99464. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99465. /**
  99466. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99467. */
  99468. /**
  99469. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99470. */
  99471. directionalConeInnerAngle: number;
  99472. /**
  99473. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99474. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99475. */
  99476. /**
  99477. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99478. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99479. */
  99480. directionalConeOuterAngle: number;
  99481. /**
  99482. * Playback volume.
  99483. */
  99484. /**
  99485. * Playback volume.
  99486. */
  99487. volume: number;
  99488. private _onended;
  99489. /**
  99490. * Suspend playback
  99491. */
  99492. pause(): void;
  99493. /**
  99494. * Stop playback
  99495. */
  99496. stop(): void;
  99497. /**
  99498. * Start playback.
  99499. * @param startOffset Position the clip head at a specific time in seconds.
  99500. */
  99501. play(startOffset?: number): void;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. /**
  99506. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99507. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99508. */
  99509. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99510. /**
  99511. * Gets the name of the behavior.
  99512. */
  99513. readonly name: string;
  99514. /**
  99515. * The easing function used by animations
  99516. */
  99517. static EasingFunction: BackEase;
  99518. /**
  99519. * The easing mode used by animations
  99520. */
  99521. static EasingMode: number;
  99522. /**
  99523. * The duration of the animation, in milliseconds
  99524. */
  99525. transitionDuration: number;
  99526. /**
  99527. * Length of the distance animated by the transition when lower radius is reached
  99528. */
  99529. lowerRadiusTransitionRange: number;
  99530. /**
  99531. * Length of the distance animated by the transition when upper radius is reached
  99532. */
  99533. upperRadiusTransitionRange: number;
  99534. private _autoTransitionRange;
  99535. /**
  99536. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99537. */
  99538. /**
  99539. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99540. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99541. */
  99542. autoTransitionRange: boolean;
  99543. private _attachedCamera;
  99544. private _onAfterCheckInputsObserver;
  99545. private _onMeshTargetChangedObserver;
  99546. /**
  99547. * Initializes the behavior.
  99548. */
  99549. init(): void;
  99550. /**
  99551. * Attaches the behavior to its arc rotate camera.
  99552. * @param camera Defines the camera to attach the behavior to
  99553. */
  99554. attach(camera: ArcRotateCamera): void;
  99555. /**
  99556. * Detaches the behavior from its current arc rotate camera.
  99557. */
  99558. detach(): void;
  99559. private _radiusIsAnimating;
  99560. private _radiusBounceTransition;
  99561. private _animatables;
  99562. private _cachedWheelPrecision;
  99563. /**
  99564. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99565. * @param radiusLimit The limit to check against.
  99566. * @return Bool to indicate if at limit.
  99567. */
  99568. private _isRadiusAtLimit;
  99569. /**
  99570. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99571. * @param radiusDelta The delta by which to animate to. Can be negative.
  99572. */
  99573. private _applyBoundRadiusAnimation;
  99574. /**
  99575. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99576. */
  99577. protected _clearAnimationLocks(): void;
  99578. /**
  99579. * Stops and removes all animations that have been applied to the camera
  99580. */
  99581. stopAllAnimations(): void;
  99582. }
  99583. }
  99584. declare module BABYLON {
  99585. /**
  99586. * 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.
  99587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99588. */
  99589. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99590. /**
  99591. * Gets the name of the behavior.
  99592. */
  99593. readonly name: string;
  99594. private _mode;
  99595. private _radiusScale;
  99596. private _positionScale;
  99597. private _defaultElevation;
  99598. private _elevationReturnTime;
  99599. private _elevationReturnWaitTime;
  99600. private _zoomStopsAnimation;
  99601. private _framingTime;
  99602. /**
  99603. * The easing function used by animations
  99604. */
  99605. static EasingFunction: ExponentialEase;
  99606. /**
  99607. * The easing mode used by animations
  99608. */
  99609. static EasingMode: number;
  99610. /**
  99611. * Sets the current mode used by the behavior
  99612. */
  99613. /**
  99614. * Gets current mode used by the behavior.
  99615. */
  99616. mode: number;
  99617. /**
  99618. * Sets the scale applied to the radius (1 by default)
  99619. */
  99620. /**
  99621. * Gets the scale applied to the radius
  99622. */
  99623. radiusScale: number;
  99624. /**
  99625. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99626. */
  99627. /**
  99628. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99629. */
  99630. positionScale: number;
  99631. /**
  99632. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99633. * behaviour is triggered, in radians.
  99634. */
  99635. /**
  99636. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99637. * behaviour is triggered, in radians.
  99638. */
  99639. defaultElevation: number;
  99640. /**
  99641. * Sets the time (in milliseconds) taken to return to the default beta position.
  99642. * Negative value indicates camera should not return to default.
  99643. */
  99644. /**
  99645. * Gets the time (in milliseconds) taken to return to the default beta position.
  99646. * Negative value indicates camera should not return to default.
  99647. */
  99648. elevationReturnTime: number;
  99649. /**
  99650. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99651. */
  99652. /**
  99653. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99654. */
  99655. elevationReturnWaitTime: number;
  99656. /**
  99657. * Sets the flag that indicates if user zooming should stop animation.
  99658. */
  99659. /**
  99660. * Gets the flag that indicates if user zooming should stop animation.
  99661. */
  99662. zoomStopsAnimation: boolean;
  99663. /**
  99664. * Sets the transition time when framing the mesh, in milliseconds
  99665. */
  99666. /**
  99667. * Gets the transition time when framing the mesh, in milliseconds
  99668. */
  99669. framingTime: number;
  99670. /**
  99671. * Define if the behavior should automatically change the configured
  99672. * camera limits and sensibilities.
  99673. */
  99674. autoCorrectCameraLimitsAndSensibility: boolean;
  99675. private _onPrePointerObservableObserver;
  99676. private _onAfterCheckInputsObserver;
  99677. private _onMeshTargetChangedObserver;
  99678. private _attachedCamera;
  99679. private _isPointerDown;
  99680. private _lastInteractionTime;
  99681. /**
  99682. * Initializes the behavior.
  99683. */
  99684. init(): void;
  99685. /**
  99686. * Attaches the behavior to its arc rotate camera.
  99687. * @param camera Defines the camera to attach the behavior to
  99688. */
  99689. attach(camera: ArcRotateCamera): void;
  99690. /**
  99691. * Detaches the behavior from its current arc rotate camera.
  99692. */
  99693. detach(): void;
  99694. private _animatables;
  99695. private _betaIsAnimating;
  99696. private _betaTransition;
  99697. private _radiusTransition;
  99698. private _vectorTransition;
  99699. /**
  99700. * Targets the given mesh and updates zoom level accordingly.
  99701. * @param mesh The mesh to target.
  99702. * @param radius Optional. If a cached radius position already exists, overrides default.
  99703. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99704. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99705. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99706. */
  99707. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99708. /**
  99709. * Targets the given mesh with its children and updates zoom level accordingly.
  99710. * @param mesh The mesh to target.
  99711. * @param radius Optional. If a cached radius position already exists, overrides default.
  99712. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99713. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99714. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99715. */
  99716. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99717. /**
  99718. * Targets the given meshes with their children and updates zoom level accordingly.
  99719. * @param meshes The mesh to target.
  99720. * @param radius Optional. If a cached radius position already exists, overrides default.
  99721. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99722. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99723. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99724. */
  99725. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99726. /**
  99727. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99728. * @param minimumWorld Determines the smaller position of the bounding box extend
  99729. * @param maximumWorld Determines the bigger position of the bounding box extend
  99730. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99731. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99732. */
  99733. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99734. /**
  99735. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99736. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99737. * frustum width.
  99738. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99739. * to fully enclose the mesh in the viewing frustum.
  99740. */
  99741. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99742. /**
  99743. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99744. * is automatically returned to its default position (expected to be above ground plane).
  99745. */
  99746. private _maintainCameraAboveGround;
  99747. /**
  99748. * Returns the frustum slope based on the canvas ratio and camera FOV
  99749. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99750. */
  99751. private _getFrustumSlope;
  99752. /**
  99753. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99754. */
  99755. private _clearAnimationLocks;
  99756. /**
  99757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99758. */
  99759. private _applyUserInteraction;
  99760. /**
  99761. * Stops and removes all animations that have been applied to the camera
  99762. */
  99763. stopAllAnimations(): void;
  99764. /**
  99765. * Gets a value indicating if the user is moving the camera
  99766. */
  99767. readonly isUserIsMoving: boolean;
  99768. /**
  99769. * The camera can move all the way towards the mesh.
  99770. */
  99771. static IgnoreBoundsSizeMode: number;
  99772. /**
  99773. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99774. */
  99775. static FitFrustumSidesMode: number;
  99776. }
  99777. }
  99778. declare module BABYLON {
  99779. /**
  99780. * Base class for Camera Pointer Inputs.
  99781. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99782. * for example usage.
  99783. */
  99784. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99785. /**
  99786. * Defines the camera the input is attached to.
  99787. */
  99788. abstract camera: Camera;
  99789. /**
  99790. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99791. */
  99792. protected _altKey: boolean;
  99793. protected _ctrlKey: boolean;
  99794. protected _metaKey: boolean;
  99795. protected _shiftKey: boolean;
  99796. /**
  99797. * Which mouse buttons were pressed at time of last mouse event.
  99798. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99799. */
  99800. protected _buttonsPressed: number;
  99801. /**
  99802. * Defines the buttons associated with the input to handle camera move.
  99803. */
  99804. buttons: number[];
  99805. /**
  99806. * Attach the input controls to a specific dom element to get the input from.
  99807. * @param element Defines the element the controls should be listened from
  99808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99809. */
  99810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99811. /**
  99812. * Detach the current controls from the specified dom element.
  99813. * @param element Defines the element to stop listening the inputs from
  99814. */
  99815. detachControl(element: Nullable<HTMLElement>): void;
  99816. /**
  99817. * Gets the class name of the current input.
  99818. * @returns the class name
  99819. */
  99820. getClassName(): string;
  99821. /**
  99822. * Get the friendly name associated with the input class.
  99823. * @returns the input friendly name
  99824. */
  99825. getSimpleName(): string;
  99826. /**
  99827. * Called on pointer POINTERDOUBLETAP event.
  99828. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99829. */
  99830. protected onDoubleTap(type: string): void;
  99831. /**
  99832. * Called on pointer POINTERMOVE event if only a single touch is active.
  99833. * Override this method to provide functionality.
  99834. */
  99835. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99836. /**
  99837. * Called on pointer POINTERMOVE event if multiple touches are active.
  99838. * Override this method to provide functionality.
  99839. */
  99840. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99841. /**
  99842. * Called on JS contextmenu event.
  99843. * Override this method to provide functionality.
  99844. */
  99845. protected onContextMenu(evt: PointerEvent): void;
  99846. /**
  99847. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99848. * press.
  99849. * Override this method to provide functionality.
  99850. */
  99851. protected onButtonDown(evt: PointerEvent): void;
  99852. /**
  99853. * Called each time a new POINTERUP event occurs. Ie, for each button
  99854. * release.
  99855. * Override this method to provide functionality.
  99856. */
  99857. protected onButtonUp(evt: PointerEvent): void;
  99858. /**
  99859. * Called when window becomes inactive.
  99860. * Override this method to provide functionality.
  99861. */
  99862. protected onLostFocus(): void;
  99863. private _pointerInput;
  99864. private _observer;
  99865. private _onLostFocus;
  99866. private pointA;
  99867. private pointB;
  99868. }
  99869. }
  99870. declare module BABYLON {
  99871. /**
  99872. * Manage the pointers inputs to control an arc rotate camera.
  99873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99874. */
  99875. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99876. /**
  99877. * Defines the camera the input is attached to.
  99878. */
  99879. camera: ArcRotateCamera;
  99880. /**
  99881. * Gets the class name of the current input.
  99882. * @returns the class name
  99883. */
  99884. getClassName(): string;
  99885. /**
  99886. * Defines the buttons associated with the input to handle camera move.
  99887. */
  99888. buttons: number[];
  99889. /**
  99890. * Defines the pointer angular sensibility along the X axis or how fast is
  99891. * the camera rotating.
  99892. */
  99893. angularSensibilityX: number;
  99894. /**
  99895. * Defines the pointer angular sensibility along the Y axis or how fast is
  99896. * the camera rotating.
  99897. */
  99898. angularSensibilityY: number;
  99899. /**
  99900. * Defines the pointer pinch precision or how fast is the camera zooming.
  99901. */
  99902. pinchPrecision: number;
  99903. /**
  99904. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99905. * from 0.
  99906. * It defines the percentage of current camera.radius to use as delta when
  99907. * pinch zoom is used.
  99908. */
  99909. pinchDeltaPercentage: number;
  99910. /**
  99911. * Defines the pointer panning sensibility or how fast is the camera moving.
  99912. */
  99913. panningSensibility: number;
  99914. /**
  99915. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99916. */
  99917. multiTouchPanning: boolean;
  99918. /**
  99919. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99920. * zoom (pinch) through multitouch.
  99921. */
  99922. multiTouchPanAndZoom: boolean;
  99923. /**
  99924. * Revers pinch action direction.
  99925. */
  99926. pinchInwards: boolean;
  99927. private _isPanClick;
  99928. private _twoFingerActivityCount;
  99929. private _isPinching;
  99930. /**
  99931. * Called on pointer POINTERMOVE event if only a single touch is active.
  99932. */
  99933. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99934. /**
  99935. * Called on pointer POINTERDOUBLETAP event.
  99936. */
  99937. protected onDoubleTap(type: string): void;
  99938. /**
  99939. * Called on pointer POINTERMOVE event if multiple touches are active.
  99940. */
  99941. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99942. /**
  99943. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99944. * press.
  99945. */
  99946. protected onButtonDown(evt: PointerEvent): void;
  99947. /**
  99948. * Called each time a new POINTERUP event occurs. Ie, for each button
  99949. * release.
  99950. */
  99951. protected onButtonUp(evt: PointerEvent): void;
  99952. /**
  99953. * Called when window becomes inactive.
  99954. */
  99955. protected onLostFocus(): void;
  99956. }
  99957. }
  99958. declare module BABYLON {
  99959. /**
  99960. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99962. */
  99963. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99964. /**
  99965. * Defines the camera the input is attached to.
  99966. */
  99967. camera: ArcRotateCamera;
  99968. /**
  99969. * Defines the list of key codes associated with the up action (increase alpha)
  99970. */
  99971. keysUp: number[];
  99972. /**
  99973. * Defines the list of key codes associated with the down action (decrease alpha)
  99974. */
  99975. keysDown: number[];
  99976. /**
  99977. * Defines the list of key codes associated with the left action (increase beta)
  99978. */
  99979. keysLeft: number[];
  99980. /**
  99981. * Defines the list of key codes associated with the right action (decrease beta)
  99982. */
  99983. keysRight: number[];
  99984. /**
  99985. * Defines the list of key codes associated with the reset action.
  99986. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99987. */
  99988. keysReset: number[];
  99989. /**
  99990. * Defines the panning sensibility of the inputs.
  99991. * (How fast is the camera paning)
  99992. */
  99993. panningSensibility: number;
  99994. /**
  99995. * Defines the zooming sensibility of the inputs.
  99996. * (How fast is the camera zooming)
  99997. */
  99998. zoomingSensibility: number;
  99999. /**
  100000. * Defines wether maintaining the alt key down switch the movement mode from
  100001. * orientation to zoom.
  100002. */
  100003. useAltToZoom: boolean;
  100004. /**
  100005. * Rotation speed of the camera
  100006. */
  100007. angularSpeed: number;
  100008. private _keys;
  100009. private _ctrlPressed;
  100010. private _altPressed;
  100011. private _onCanvasBlurObserver;
  100012. private _onKeyboardObserver;
  100013. private _engine;
  100014. private _scene;
  100015. /**
  100016. * Attach the input controls to a specific dom element to get the input from.
  100017. * @param element Defines the element the controls should be listened from
  100018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100019. */
  100020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100021. /**
  100022. * Detach the current controls from the specified dom element.
  100023. * @param element Defines the element to stop listening the inputs from
  100024. */
  100025. detachControl(element: Nullable<HTMLElement>): void;
  100026. /**
  100027. * Update the current camera state depending on the inputs that have been used this frame.
  100028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100029. */
  100030. checkInputs(): void;
  100031. /**
  100032. * Gets the class name of the current intput.
  100033. * @returns the class name
  100034. */
  100035. getClassName(): string;
  100036. /**
  100037. * Get the friendly name associated with the input class.
  100038. * @returns the input friendly name
  100039. */
  100040. getSimpleName(): string;
  100041. }
  100042. }
  100043. declare module BABYLON {
  100044. /**
  100045. * Manage the mouse wheel inputs to control an arc rotate camera.
  100046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100047. */
  100048. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100049. /**
  100050. * Defines the camera the input is attached to.
  100051. */
  100052. camera: ArcRotateCamera;
  100053. /**
  100054. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100055. */
  100056. wheelPrecision: number;
  100057. /**
  100058. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100059. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100060. */
  100061. wheelDeltaPercentage: number;
  100062. private _wheel;
  100063. private _observer;
  100064. private computeDeltaFromMouseWheelLegacyEvent;
  100065. /**
  100066. * Attach the input controls to a specific dom element to get the input from.
  100067. * @param element Defines the element the controls should be listened from
  100068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100069. */
  100070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100071. /**
  100072. * Detach the current controls from the specified dom element.
  100073. * @param element Defines the element to stop listening the inputs from
  100074. */
  100075. detachControl(element: Nullable<HTMLElement>): void;
  100076. /**
  100077. * Gets the class name of the current intput.
  100078. * @returns the class name
  100079. */
  100080. getClassName(): string;
  100081. /**
  100082. * Get the friendly name associated with the input class.
  100083. * @returns the input friendly name
  100084. */
  100085. getSimpleName(): string;
  100086. }
  100087. }
  100088. declare module BABYLON {
  100089. /**
  100090. * Default Inputs manager for the ArcRotateCamera.
  100091. * It groups all the default supported inputs for ease of use.
  100092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100093. */
  100094. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100095. /**
  100096. * Instantiates a new ArcRotateCameraInputsManager.
  100097. * @param camera Defines the camera the inputs belong to
  100098. */
  100099. constructor(camera: ArcRotateCamera);
  100100. /**
  100101. * Add mouse wheel input support to the input manager.
  100102. * @returns the current input manager
  100103. */
  100104. addMouseWheel(): ArcRotateCameraInputsManager;
  100105. /**
  100106. * Add pointers input support to the input manager.
  100107. * @returns the current input manager
  100108. */
  100109. addPointers(): ArcRotateCameraInputsManager;
  100110. /**
  100111. * Add keyboard input support to the input manager.
  100112. * @returns the current input manager
  100113. */
  100114. addKeyboard(): ArcRotateCameraInputsManager;
  100115. }
  100116. }
  100117. declare module BABYLON {
  100118. /**
  100119. * This represents an orbital type of camera.
  100120. *
  100121. * 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.
  100122. * 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.
  100123. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100124. */
  100125. export class ArcRotateCamera extends TargetCamera {
  100126. /**
  100127. * Defines the rotation angle of the camera along the longitudinal axis.
  100128. */
  100129. alpha: number;
  100130. /**
  100131. * Defines the rotation angle of the camera along the latitudinal axis.
  100132. */
  100133. beta: number;
  100134. /**
  100135. * Defines the radius of the camera from it s target point.
  100136. */
  100137. radius: number;
  100138. protected _target: Vector3;
  100139. protected _targetHost: Nullable<AbstractMesh>;
  100140. /**
  100141. * Defines the target point of the camera.
  100142. * The camera looks towards it form the radius distance.
  100143. */
  100144. target: Vector3;
  100145. /**
  100146. * Define the current local position of the camera in the scene
  100147. */
  100148. position: Vector3;
  100149. protected _upVector: Vector3;
  100150. protected _upToYMatrix: Matrix;
  100151. protected _YToUpMatrix: Matrix;
  100152. /**
  100153. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100154. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100155. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100156. */
  100157. upVector: Vector3;
  100158. /**
  100159. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100160. */
  100161. setMatUp(): void;
  100162. /**
  100163. * Current inertia value on the longitudinal axis.
  100164. * The bigger this number the longer it will take for the camera to stop.
  100165. */
  100166. inertialAlphaOffset: number;
  100167. /**
  100168. * Current inertia value on the latitudinal axis.
  100169. * The bigger this number the longer it will take for the camera to stop.
  100170. */
  100171. inertialBetaOffset: number;
  100172. /**
  100173. * Current inertia value on the radius axis.
  100174. * The bigger this number the longer it will take for the camera to stop.
  100175. */
  100176. inertialRadiusOffset: number;
  100177. /**
  100178. * Minimum allowed angle on the longitudinal axis.
  100179. * This can help limiting how the Camera is able to move in the scene.
  100180. */
  100181. lowerAlphaLimit: Nullable<number>;
  100182. /**
  100183. * Maximum allowed angle on the longitudinal axis.
  100184. * This can help limiting how the Camera is able to move in the scene.
  100185. */
  100186. upperAlphaLimit: Nullable<number>;
  100187. /**
  100188. * Minimum allowed angle on the latitudinal axis.
  100189. * This can help limiting how the Camera is able to move in the scene.
  100190. */
  100191. lowerBetaLimit: number;
  100192. /**
  100193. * Maximum allowed angle on the latitudinal axis.
  100194. * This can help limiting how the Camera is able to move in the scene.
  100195. */
  100196. upperBetaLimit: number;
  100197. /**
  100198. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100199. * This can help limiting how the Camera is able to move in the scene.
  100200. */
  100201. lowerRadiusLimit: Nullable<number>;
  100202. /**
  100203. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100204. * This can help limiting how the Camera is able to move in the scene.
  100205. */
  100206. upperRadiusLimit: Nullable<number>;
  100207. /**
  100208. * Defines the current inertia value used during panning of the camera along the X axis.
  100209. */
  100210. inertialPanningX: number;
  100211. /**
  100212. * Defines the current inertia value used during panning of the camera along the Y axis.
  100213. */
  100214. inertialPanningY: number;
  100215. /**
  100216. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100217. * Basically if your fingers moves away from more than this distance you will be considered
  100218. * in pinch mode.
  100219. */
  100220. pinchToPanMaxDistance: number;
  100221. /**
  100222. * Defines the maximum distance the camera can pan.
  100223. * This could help keeping the cammera always in your scene.
  100224. */
  100225. panningDistanceLimit: Nullable<number>;
  100226. /**
  100227. * Defines the target of the camera before paning.
  100228. */
  100229. panningOriginTarget: Vector3;
  100230. /**
  100231. * Defines the value of the inertia used during panning.
  100232. * 0 would mean stop inertia and one would mean no decelleration at all.
  100233. */
  100234. panningInertia: number;
  100235. /**
  100236. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100237. */
  100238. angularSensibilityX: number;
  100239. /**
  100240. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100241. */
  100242. angularSensibilityY: number;
  100243. /**
  100244. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100245. */
  100246. pinchPrecision: number;
  100247. /**
  100248. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100249. * It will be used instead of pinchDeltaPrecision if different from 0.
  100250. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100251. */
  100252. pinchDeltaPercentage: number;
  100253. /**
  100254. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100255. */
  100256. panningSensibility: number;
  100257. /**
  100258. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100259. */
  100260. keysUp: number[];
  100261. /**
  100262. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100263. */
  100264. keysDown: number[];
  100265. /**
  100266. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100267. */
  100268. keysLeft: number[];
  100269. /**
  100270. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100271. */
  100272. keysRight: number[];
  100273. /**
  100274. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100275. */
  100276. wheelPrecision: number;
  100277. /**
  100278. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100279. * It will be used instead of pinchDeltaPrecision if different from 0.
  100280. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100281. */
  100282. wheelDeltaPercentage: number;
  100283. /**
  100284. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100285. */
  100286. zoomOnFactor: number;
  100287. /**
  100288. * Defines a screen offset for the camera position.
  100289. */
  100290. targetScreenOffset: Vector2;
  100291. /**
  100292. * Allows the camera to be completely reversed.
  100293. * If false the camera can not arrive upside down.
  100294. */
  100295. allowUpsideDown: boolean;
  100296. /**
  100297. * Define if double tap/click is used to restore the previously saved state of the camera.
  100298. */
  100299. useInputToRestoreState: boolean;
  100300. /** @hidden */
  100301. _viewMatrix: Matrix;
  100302. /** @hidden */
  100303. _useCtrlForPanning: boolean;
  100304. /** @hidden */
  100305. _panningMouseButton: number;
  100306. /**
  100307. * Defines the input associated to the camera.
  100308. */
  100309. inputs: ArcRotateCameraInputsManager;
  100310. /** @hidden */
  100311. _reset: () => void;
  100312. /**
  100313. * Defines the allowed panning axis.
  100314. */
  100315. panningAxis: Vector3;
  100316. protected _localDirection: Vector3;
  100317. protected _transformedDirection: Vector3;
  100318. private _bouncingBehavior;
  100319. /**
  100320. * Gets the bouncing behavior of the camera if it has been enabled.
  100321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100322. */
  100323. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100324. /**
  100325. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100326. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100327. */
  100328. useBouncingBehavior: boolean;
  100329. private _framingBehavior;
  100330. /**
  100331. * Gets the framing behavior of the camera if it has been enabled.
  100332. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100333. */
  100334. readonly framingBehavior: Nullable<FramingBehavior>;
  100335. /**
  100336. * Defines if the framing behavior of the camera is enabled on the camera.
  100337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100338. */
  100339. useFramingBehavior: boolean;
  100340. private _autoRotationBehavior;
  100341. /**
  100342. * Gets the auto rotation behavior of the camera if it has been enabled.
  100343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100344. */
  100345. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100346. /**
  100347. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100349. */
  100350. useAutoRotationBehavior: boolean;
  100351. /**
  100352. * Observable triggered when the mesh target has been changed on the camera.
  100353. */
  100354. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100355. /**
  100356. * Event raised when the camera is colliding with a mesh.
  100357. */
  100358. onCollide: (collidedMesh: AbstractMesh) => void;
  100359. /**
  100360. * Defines whether the camera should check collision with the objects oh the scene.
  100361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100362. */
  100363. checkCollisions: boolean;
  100364. /**
  100365. * Defines the collision radius of the camera.
  100366. * This simulates a sphere around the camera.
  100367. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100368. */
  100369. collisionRadius: Vector3;
  100370. protected _collider: Collider;
  100371. protected _previousPosition: Vector3;
  100372. protected _collisionVelocity: Vector3;
  100373. protected _newPosition: Vector3;
  100374. protected _previousAlpha: number;
  100375. protected _previousBeta: number;
  100376. protected _previousRadius: number;
  100377. protected _collisionTriggered: boolean;
  100378. protected _targetBoundingCenter: Nullable<Vector3>;
  100379. private _computationVector;
  100380. /**
  100381. * Instantiates a new ArcRotateCamera in a given scene
  100382. * @param name Defines the name of the camera
  100383. * @param alpha Defines the camera rotation along the logitudinal axis
  100384. * @param beta Defines the camera rotation along the latitudinal axis
  100385. * @param radius Defines the camera distance from its target
  100386. * @param target Defines the camera target
  100387. * @param scene Defines the scene the camera belongs to
  100388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100389. */
  100390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100391. /** @hidden */
  100392. _initCache(): void;
  100393. /** @hidden */
  100394. _updateCache(ignoreParentClass?: boolean): void;
  100395. protected _getTargetPosition(): Vector3;
  100396. private _storedAlpha;
  100397. private _storedBeta;
  100398. private _storedRadius;
  100399. private _storedTarget;
  100400. /**
  100401. * Stores the current state of the camera (alpha, beta, radius and target)
  100402. * @returns the camera itself
  100403. */
  100404. storeState(): Camera;
  100405. /**
  100406. * @hidden
  100407. * Restored camera state. You must call storeState() first
  100408. */
  100409. _restoreStateValues(): boolean;
  100410. /** @hidden */
  100411. _isSynchronizedViewMatrix(): boolean;
  100412. /**
  100413. * Attached controls to the current camera.
  100414. * @param element Defines the element the controls should be listened from
  100415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100416. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100417. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100418. */
  100419. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100420. /**
  100421. * Detach the current controls from the camera.
  100422. * The camera will stop reacting to inputs.
  100423. * @param element Defines the element to stop listening the inputs from
  100424. */
  100425. detachControl(element: HTMLElement): void;
  100426. /** @hidden */
  100427. _checkInputs(): void;
  100428. protected _checkLimits(): void;
  100429. /**
  100430. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100431. */
  100432. rebuildAnglesAndRadius(): void;
  100433. /**
  100434. * Use a position to define the current camera related information like aplha, beta and radius
  100435. * @param position Defines the position to set the camera at
  100436. */
  100437. setPosition(position: Vector3): void;
  100438. /**
  100439. * Defines the target the camera should look at.
  100440. * This will automatically adapt alpha beta and radius to fit within the new target.
  100441. * @param target Defines the new target as a Vector or a mesh
  100442. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100443. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100444. */
  100445. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100446. /** @hidden */
  100447. _getViewMatrix(): Matrix;
  100448. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100449. /**
  100450. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100451. * @param meshes Defines the mesh to zoom on
  100452. * @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)
  100453. */
  100454. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100455. /**
  100456. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100457. * The target will be changed but the radius
  100458. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100459. * @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)
  100460. */
  100461. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100462. min: Vector3;
  100463. max: Vector3;
  100464. distance: number;
  100465. }, doNotUpdateMaxZ?: boolean): void;
  100466. /**
  100467. * @override
  100468. * Override Camera.createRigCamera
  100469. */
  100470. createRigCamera(name: string, cameraIndex: number): Camera;
  100471. /**
  100472. * @hidden
  100473. * @override
  100474. * Override Camera._updateRigCameras
  100475. */
  100476. _updateRigCameras(): void;
  100477. /**
  100478. * Destroy the camera and release the current resources hold by it.
  100479. */
  100480. dispose(): void;
  100481. /**
  100482. * Gets the current object class name.
  100483. * @return the class name
  100484. */
  100485. getClassName(): string;
  100486. }
  100487. }
  100488. declare module BABYLON {
  100489. /**
  100490. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100492. */
  100493. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100494. /**
  100495. * Gets the name of the behavior.
  100496. */
  100497. readonly name: string;
  100498. private _zoomStopsAnimation;
  100499. private _idleRotationSpeed;
  100500. private _idleRotationWaitTime;
  100501. private _idleRotationSpinupTime;
  100502. /**
  100503. * Sets the flag that indicates if user zooming should stop animation.
  100504. */
  100505. /**
  100506. * Gets the flag that indicates if user zooming should stop animation.
  100507. */
  100508. zoomStopsAnimation: boolean;
  100509. /**
  100510. * Sets the default speed at which the camera rotates around the model.
  100511. */
  100512. /**
  100513. * Gets the default speed at which the camera rotates around the model.
  100514. */
  100515. idleRotationSpeed: number;
  100516. /**
  100517. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100518. */
  100519. /**
  100520. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100521. */
  100522. idleRotationWaitTime: number;
  100523. /**
  100524. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100525. */
  100526. /**
  100527. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100528. */
  100529. idleRotationSpinupTime: number;
  100530. /**
  100531. * Gets a value indicating if the camera is currently rotating because of this behavior
  100532. */
  100533. readonly rotationInProgress: boolean;
  100534. private _onPrePointerObservableObserver;
  100535. private _onAfterCheckInputsObserver;
  100536. private _attachedCamera;
  100537. private _isPointerDown;
  100538. private _lastFrameTime;
  100539. private _lastInteractionTime;
  100540. private _cameraRotationSpeed;
  100541. /**
  100542. * Initializes the behavior.
  100543. */
  100544. init(): void;
  100545. /**
  100546. * Attaches the behavior to its arc rotate camera.
  100547. * @param camera Defines the camera to attach the behavior to
  100548. */
  100549. attach(camera: ArcRotateCamera): void;
  100550. /**
  100551. * Detaches the behavior from its current arc rotate camera.
  100552. */
  100553. detach(): void;
  100554. /**
  100555. * Returns true if user is scrolling.
  100556. * @return true if user is scrolling.
  100557. */
  100558. private _userIsZooming;
  100559. private _lastFrameRadius;
  100560. private _shouldAnimationStopForInteraction;
  100561. /**
  100562. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100563. */
  100564. private _applyUserInteraction;
  100565. private _userIsMoving;
  100566. }
  100567. }
  100568. declare module BABYLON {
  100569. /**
  100570. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100571. */
  100572. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100573. private ui;
  100574. /**
  100575. * The name of the behavior
  100576. */
  100577. name: string;
  100578. /**
  100579. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100580. */
  100581. distanceAwayFromFace: number;
  100582. /**
  100583. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100584. */
  100585. distanceAwayFromBottomOfFace: number;
  100586. private _faceVectors;
  100587. private _target;
  100588. private _scene;
  100589. private _onRenderObserver;
  100590. private _tmpMatrix;
  100591. private _tmpVector;
  100592. /**
  100593. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100594. * @param ui The transform node that should be attched to the mesh
  100595. */
  100596. constructor(ui: TransformNode);
  100597. /**
  100598. * Initializes the behavior
  100599. */
  100600. init(): void;
  100601. private _closestFace;
  100602. private _zeroVector;
  100603. private _lookAtTmpMatrix;
  100604. private _lookAtToRef;
  100605. /**
  100606. * Attaches the AttachToBoxBehavior to the passed in mesh
  100607. * @param target The mesh that the specified node will be attached to
  100608. */
  100609. attach(target: Mesh): void;
  100610. /**
  100611. * Detaches the behavior from the mesh
  100612. */
  100613. detach(): void;
  100614. }
  100615. }
  100616. declare module BABYLON {
  100617. /**
  100618. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100619. */
  100620. export class FadeInOutBehavior implements Behavior<Mesh> {
  100621. /**
  100622. * Time in milliseconds to delay before fading in (Default: 0)
  100623. */
  100624. delay: number;
  100625. /**
  100626. * Time in milliseconds for the mesh to fade in (Default: 300)
  100627. */
  100628. fadeInTime: number;
  100629. private _millisecondsPerFrame;
  100630. private _hovered;
  100631. private _hoverValue;
  100632. private _ownerNode;
  100633. /**
  100634. * Instatiates the FadeInOutBehavior
  100635. */
  100636. constructor();
  100637. /**
  100638. * The name of the behavior
  100639. */
  100640. readonly name: string;
  100641. /**
  100642. * Initializes the behavior
  100643. */
  100644. init(): void;
  100645. /**
  100646. * Attaches the fade behavior on the passed in mesh
  100647. * @param ownerNode The mesh that will be faded in/out once attached
  100648. */
  100649. attach(ownerNode: Mesh): void;
  100650. /**
  100651. * Detaches the behavior from the mesh
  100652. */
  100653. detach(): void;
  100654. /**
  100655. * Triggers the mesh to begin fading in or out
  100656. * @param value if the object should fade in or out (true to fade in)
  100657. */
  100658. fadeIn(value: boolean): void;
  100659. private _update;
  100660. private _setAllVisibility;
  100661. }
  100662. }
  100663. declare module BABYLON {
  100664. /**
  100665. * Class containing a set of static utilities functions for managing Pivots
  100666. * @hidden
  100667. */
  100668. export class PivotTools {
  100669. private static _PivotCached;
  100670. private static _OldPivotPoint;
  100671. private static _PivotTranslation;
  100672. private static _PivotTmpVector;
  100673. /** @hidden */
  100674. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100675. /** @hidden */
  100676. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100677. }
  100678. }
  100679. declare module BABYLON {
  100680. /**
  100681. * Class containing static functions to help procedurally build meshes
  100682. */
  100683. export class PlaneBuilder {
  100684. /**
  100685. * Creates a plane mesh
  100686. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100687. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100688. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100692. * @param name defines the name of the mesh
  100693. * @param options defines the options used to create the mesh
  100694. * @param scene defines the hosting scene
  100695. * @returns the plane mesh
  100696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100697. */
  100698. static CreatePlane(name: string, options: {
  100699. size?: number;
  100700. width?: number;
  100701. height?: number;
  100702. sideOrientation?: number;
  100703. frontUVs?: Vector4;
  100704. backUVs?: Vector4;
  100705. updatable?: boolean;
  100706. sourcePlane?: Plane;
  100707. }, scene?: Nullable<Scene>): Mesh;
  100708. }
  100709. }
  100710. declare module BABYLON {
  100711. /**
  100712. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100713. */
  100714. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100715. private static _AnyMouseID;
  100716. /**
  100717. * Abstract mesh the behavior is set on
  100718. */
  100719. attachedNode: AbstractMesh;
  100720. private _dragPlane;
  100721. private _scene;
  100722. private _pointerObserver;
  100723. private _beforeRenderObserver;
  100724. private static _planeScene;
  100725. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100726. /**
  100727. * 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)
  100728. */
  100729. maxDragAngle: number;
  100730. /**
  100731. * @hidden
  100732. */
  100733. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100734. /**
  100735. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100736. */
  100737. currentDraggingPointerID: number;
  100738. /**
  100739. * The last position where the pointer hit the drag plane in world space
  100740. */
  100741. lastDragPosition: Vector3;
  100742. /**
  100743. * If the behavior is currently in a dragging state
  100744. */
  100745. dragging: boolean;
  100746. /**
  100747. * 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)
  100748. */
  100749. dragDeltaRatio: number;
  100750. /**
  100751. * If the drag plane orientation should be updated during the dragging (Default: true)
  100752. */
  100753. updateDragPlane: boolean;
  100754. private _debugMode;
  100755. private _moving;
  100756. /**
  100757. * Fires each time the attached mesh is dragged with the pointer
  100758. * * delta between last drag position and current drag position in world space
  100759. * * dragDistance along the drag axis
  100760. * * dragPlaneNormal normal of the current drag plane used during the drag
  100761. * * dragPlanePoint in world space where the drag intersects the drag plane
  100762. */
  100763. onDragObservable: Observable<{
  100764. delta: Vector3;
  100765. dragPlanePoint: Vector3;
  100766. dragPlaneNormal: Vector3;
  100767. dragDistance: number;
  100768. pointerId: number;
  100769. }>;
  100770. /**
  100771. * Fires each time a drag begins (eg. mouse down on mesh)
  100772. */
  100773. onDragStartObservable: Observable<{
  100774. dragPlanePoint: Vector3;
  100775. pointerId: number;
  100776. }>;
  100777. /**
  100778. * Fires each time a drag ends (eg. mouse release after drag)
  100779. */
  100780. onDragEndObservable: Observable<{
  100781. dragPlanePoint: Vector3;
  100782. pointerId: number;
  100783. }>;
  100784. /**
  100785. * If the attached mesh should be moved when dragged
  100786. */
  100787. moveAttached: boolean;
  100788. /**
  100789. * If the drag behavior will react to drag events (Default: true)
  100790. */
  100791. enabled: boolean;
  100792. /**
  100793. * If pointer events should start and release the drag (Default: true)
  100794. */
  100795. startAndReleaseDragOnPointerEvents: boolean;
  100796. /**
  100797. * If camera controls should be detached during the drag
  100798. */
  100799. detachCameraControls: boolean;
  100800. /**
  100801. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100802. */
  100803. useObjectOrienationForDragging: boolean;
  100804. private _options;
  100805. /**
  100806. * Creates a pointer drag behavior that can be attached to a mesh
  100807. * @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)
  100808. */
  100809. constructor(options?: {
  100810. dragAxis?: Vector3;
  100811. dragPlaneNormal?: Vector3;
  100812. });
  100813. /**
  100814. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100815. */
  100816. validateDrag: (targetPosition: Vector3) => boolean;
  100817. /**
  100818. * The name of the behavior
  100819. */
  100820. readonly name: string;
  100821. /**
  100822. * Initializes the behavior
  100823. */
  100824. init(): void;
  100825. private _tmpVector;
  100826. private _alternatePickedPoint;
  100827. private _worldDragAxis;
  100828. private _targetPosition;
  100829. private _attachedElement;
  100830. /**
  100831. * Attaches the drag behavior the passed in mesh
  100832. * @param ownerNode The mesh that will be dragged around once attached
  100833. */
  100834. attach(ownerNode: AbstractMesh): void;
  100835. /**
  100836. * Force relase the drag action by code.
  100837. */
  100838. releaseDrag(): void;
  100839. private _startDragRay;
  100840. private _lastPointerRay;
  100841. /**
  100842. * Simulates the start of a pointer drag event on the behavior
  100843. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100844. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100845. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100846. */
  100847. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100848. private _startDrag;
  100849. private _dragDelta;
  100850. private _moveDrag;
  100851. private _pickWithRayOnDragPlane;
  100852. private _pointA;
  100853. private _pointB;
  100854. private _pointC;
  100855. private _lineA;
  100856. private _lineB;
  100857. private _localAxis;
  100858. private _lookAt;
  100859. private _updateDragPlanePosition;
  100860. /**
  100861. * Detaches the behavior from the mesh
  100862. */
  100863. detach(): void;
  100864. }
  100865. }
  100866. declare module BABYLON {
  100867. /**
  100868. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100869. */
  100870. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100871. private _dragBehaviorA;
  100872. private _dragBehaviorB;
  100873. private _startDistance;
  100874. private _initialScale;
  100875. private _targetScale;
  100876. private _ownerNode;
  100877. private _sceneRenderObserver;
  100878. /**
  100879. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100880. */
  100881. constructor();
  100882. /**
  100883. * The name of the behavior
  100884. */
  100885. readonly name: string;
  100886. /**
  100887. * Initializes the behavior
  100888. */
  100889. init(): void;
  100890. private _getCurrentDistance;
  100891. /**
  100892. * Attaches the scale behavior the passed in mesh
  100893. * @param ownerNode The mesh that will be scaled around once attached
  100894. */
  100895. attach(ownerNode: Mesh): void;
  100896. /**
  100897. * Detaches the behavior from the mesh
  100898. */
  100899. detach(): void;
  100900. }
  100901. }
  100902. declare module BABYLON {
  100903. /**
  100904. * 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
  100905. */
  100906. export class SixDofDragBehavior implements Behavior<Mesh> {
  100907. private static _virtualScene;
  100908. private _ownerNode;
  100909. private _sceneRenderObserver;
  100910. private _scene;
  100911. private _targetPosition;
  100912. private _virtualOriginMesh;
  100913. private _virtualDragMesh;
  100914. private _pointerObserver;
  100915. private _moving;
  100916. private _startingOrientation;
  100917. /**
  100918. * 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)
  100919. */
  100920. private zDragFactor;
  100921. /**
  100922. * If the object should rotate to face the drag origin
  100923. */
  100924. rotateDraggedObject: boolean;
  100925. /**
  100926. * If the behavior is currently in a dragging state
  100927. */
  100928. dragging: boolean;
  100929. /**
  100930. * 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)
  100931. */
  100932. dragDeltaRatio: number;
  100933. /**
  100934. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100935. */
  100936. currentDraggingPointerID: number;
  100937. /**
  100938. * If camera controls should be detached during the drag
  100939. */
  100940. detachCameraControls: boolean;
  100941. /**
  100942. * Fires each time a drag starts
  100943. */
  100944. onDragStartObservable: Observable<{}>;
  100945. /**
  100946. * Fires each time a drag ends (eg. mouse release after drag)
  100947. */
  100948. onDragEndObservable: Observable<{}>;
  100949. /**
  100950. * 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
  100951. */
  100952. constructor();
  100953. /**
  100954. * The name of the behavior
  100955. */
  100956. readonly name: string;
  100957. /**
  100958. * Initializes the behavior
  100959. */
  100960. init(): void;
  100961. /**
  100962. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100963. */
  100964. private readonly _pointerCamera;
  100965. /**
  100966. * Attaches the scale behavior the passed in mesh
  100967. * @param ownerNode The mesh that will be scaled around once attached
  100968. */
  100969. attach(ownerNode: Mesh): void;
  100970. /**
  100971. * Detaches the behavior from the mesh
  100972. */
  100973. detach(): void;
  100974. }
  100975. }
  100976. declare module BABYLON {
  100977. /**
  100978. * Class used to apply inverse kinematics to bones
  100979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100980. */
  100981. export class BoneIKController {
  100982. private static _tmpVecs;
  100983. private static _tmpQuat;
  100984. private static _tmpMats;
  100985. /**
  100986. * Gets or sets the target mesh
  100987. */
  100988. targetMesh: AbstractMesh;
  100989. /** Gets or sets the mesh used as pole */
  100990. poleTargetMesh: AbstractMesh;
  100991. /**
  100992. * Gets or sets the bone used as pole
  100993. */
  100994. poleTargetBone: Nullable<Bone>;
  100995. /**
  100996. * Gets or sets the target position
  100997. */
  100998. targetPosition: Vector3;
  100999. /**
  101000. * Gets or sets the pole target position
  101001. */
  101002. poleTargetPosition: Vector3;
  101003. /**
  101004. * Gets or sets the pole target local offset
  101005. */
  101006. poleTargetLocalOffset: Vector3;
  101007. /**
  101008. * Gets or sets the pole angle
  101009. */
  101010. poleAngle: number;
  101011. /**
  101012. * Gets or sets the mesh associated with the controller
  101013. */
  101014. mesh: AbstractMesh;
  101015. /**
  101016. * 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)
  101017. */
  101018. slerpAmount: number;
  101019. private _bone1Quat;
  101020. private _bone1Mat;
  101021. private _bone2Ang;
  101022. private _bone1;
  101023. private _bone2;
  101024. private _bone1Length;
  101025. private _bone2Length;
  101026. private _maxAngle;
  101027. private _maxReach;
  101028. private _rightHandedSystem;
  101029. private _bendAxis;
  101030. private _slerping;
  101031. private _adjustRoll;
  101032. /**
  101033. * Gets or sets maximum allowed angle
  101034. */
  101035. maxAngle: number;
  101036. /**
  101037. * Creates a new BoneIKController
  101038. * @param mesh defines the mesh to control
  101039. * @param bone defines the bone to control
  101040. * @param options defines options to set up the controller
  101041. */
  101042. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101043. targetMesh?: AbstractMesh;
  101044. poleTargetMesh?: AbstractMesh;
  101045. poleTargetBone?: Bone;
  101046. poleTargetLocalOffset?: Vector3;
  101047. poleAngle?: number;
  101048. bendAxis?: Vector3;
  101049. maxAngle?: number;
  101050. slerpAmount?: number;
  101051. });
  101052. private _setMaxAngle;
  101053. /**
  101054. * Force the controller to update the bones
  101055. */
  101056. update(): void;
  101057. }
  101058. }
  101059. declare module BABYLON {
  101060. /**
  101061. * Class used to make a bone look toward a point in space
  101062. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101063. */
  101064. export class BoneLookController {
  101065. private static _tmpVecs;
  101066. private static _tmpQuat;
  101067. private static _tmpMats;
  101068. /**
  101069. * The target Vector3 that the bone will look at
  101070. */
  101071. target: Vector3;
  101072. /**
  101073. * The mesh that the bone is attached to
  101074. */
  101075. mesh: AbstractMesh;
  101076. /**
  101077. * The bone that will be looking to the target
  101078. */
  101079. bone: Bone;
  101080. /**
  101081. * The up axis of the coordinate system that is used when the bone is rotated
  101082. */
  101083. upAxis: Vector3;
  101084. /**
  101085. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101086. */
  101087. upAxisSpace: Space;
  101088. /**
  101089. * Used to make an adjustment to the yaw of the bone
  101090. */
  101091. adjustYaw: number;
  101092. /**
  101093. * Used to make an adjustment to the pitch of the bone
  101094. */
  101095. adjustPitch: number;
  101096. /**
  101097. * Used to make an adjustment to the roll of the bone
  101098. */
  101099. adjustRoll: number;
  101100. /**
  101101. * 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)
  101102. */
  101103. slerpAmount: number;
  101104. private _minYaw;
  101105. private _maxYaw;
  101106. private _minPitch;
  101107. private _maxPitch;
  101108. private _minYawSin;
  101109. private _minYawCos;
  101110. private _maxYawSin;
  101111. private _maxYawCos;
  101112. private _midYawConstraint;
  101113. private _minPitchTan;
  101114. private _maxPitchTan;
  101115. private _boneQuat;
  101116. private _slerping;
  101117. private _transformYawPitch;
  101118. private _transformYawPitchInv;
  101119. private _firstFrameSkipped;
  101120. private _yawRange;
  101121. private _fowardAxis;
  101122. /**
  101123. * Gets or sets the minimum yaw angle that the bone can look to
  101124. */
  101125. minYaw: number;
  101126. /**
  101127. * Gets or sets the maximum yaw angle that the bone can look to
  101128. */
  101129. maxYaw: number;
  101130. /**
  101131. * Gets or sets the minimum pitch angle that the bone can look to
  101132. */
  101133. minPitch: number;
  101134. /**
  101135. * Gets or sets the maximum pitch angle that the bone can look to
  101136. */
  101137. maxPitch: number;
  101138. /**
  101139. * Create a BoneLookController
  101140. * @param mesh the mesh that the bone belongs to
  101141. * @param bone the bone that will be looking to the target
  101142. * @param target the target Vector3 to look at
  101143. * @param options optional settings:
  101144. * * maxYaw: the maximum angle the bone will yaw to
  101145. * * minYaw: the minimum angle the bone will yaw to
  101146. * * maxPitch: the maximum angle the bone will pitch to
  101147. * * minPitch: the minimum angle the bone will yaw to
  101148. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101149. * * upAxis: the up axis of the coordinate system
  101150. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101151. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101152. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101153. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101154. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101155. * * adjustRoll: used to make an adjustment to the roll of the bone
  101156. **/
  101157. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101158. maxYaw?: number;
  101159. minYaw?: number;
  101160. maxPitch?: number;
  101161. minPitch?: number;
  101162. slerpAmount?: number;
  101163. upAxis?: Vector3;
  101164. upAxisSpace?: Space;
  101165. yawAxis?: Vector3;
  101166. pitchAxis?: Vector3;
  101167. adjustYaw?: number;
  101168. adjustPitch?: number;
  101169. adjustRoll?: number;
  101170. });
  101171. /**
  101172. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101173. */
  101174. update(): void;
  101175. private _getAngleDiff;
  101176. private _getAngleBetween;
  101177. private _isAngleBetween;
  101178. }
  101179. }
  101180. declare module BABYLON {
  101181. /**
  101182. * Manage the gamepad inputs to control an arc rotate camera.
  101183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101184. */
  101185. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101186. /**
  101187. * Defines the camera the input is attached to.
  101188. */
  101189. camera: ArcRotateCamera;
  101190. /**
  101191. * Defines the gamepad the input is gathering event from.
  101192. */
  101193. gamepad: Nullable<Gamepad>;
  101194. /**
  101195. * Defines the gamepad rotation sensiblity.
  101196. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101197. */
  101198. gamepadRotationSensibility: number;
  101199. /**
  101200. * Defines the gamepad move sensiblity.
  101201. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101202. */
  101203. gamepadMoveSensibility: number;
  101204. private _onGamepadConnectedObserver;
  101205. private _onGamepadDisconnectedObserver;
  101206. /**
  101207. * Attach the input controls to a specific dom element to get the input from.
  101208. * @param element Defines the element the controls should be listened from
  101209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101210. */
  101211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101212. /**
  101213. * Detach the current controls from the specified dom element.
  101214. * @param element Defines the element to stop listening the inputs from
  101215. */
  101216. detachControl(element: Nullable<HTMLElement>): void;
  101217. /**
  101218. * Update the current camera state depending on the inputs that have been used this frame.
  101219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101220. */
  101221. checkInputs(): void;
  101222. /**
  101223. * Gets the class name of the current intput.
  101224. * @returns the class name
  101225. */
  101226. getClassName(): string;
  101227. /**
  101228. * Get the friendly name associated with the input class.
  101229. * @returns the input friendly name
  101230. */
  101231. getSimpleName(): string;
  101232. }
  101233. }
  101234. declare module BABYLON {
  101235. interface ArcRotateCameraInputsManager {
  101236. /**
  101237. * Add orientation input support to the input manager.
  101238. * @returns the current input manager
  101239. */
  101240. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101241. }
  101242. /**
  101243. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101245. */
  101246. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101247. /**
  101248. * Defines the camera the input is attached to.
  101249. */
  101250. camera: ArcRotateCamera;
  101251. /**
  101252. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101253. */
  101254. alphaCorrection: number;
  101255. /**
  101256. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101257. */
  101258. gammaCorrection: number;
  101259. private _alpha;
  101260. private _gamma;
  101261. private _dirty;
  101262. private _deviceOrientationHandler;
  101263. /**
  101264. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101265. */
  101266. constructor();
  101267. /**
  101268. * Attach the input controls to a specific dom element to get the input from.
  101269. * @param element Defines the element the controls should be listened from
  101270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101271. */
  101272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101273. /** @hidden */
  101274. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101275. /**
  101276. * Update the current camera state depending on the inputs that have been used this frame.
  101277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101278. */
  101279. checkInputs(): void;
  101280. /**
  101281. * Detach the current controls from the specified dom element.
  101282. * @param element Defines the element to stop listening the inputs from
  101283. */
  101284. detachControl(element: Nullable<HTMLElement>): void;
  101285. /**
  101286. * Gets the class name of the current intput.
  101287. * @returns the class name
  101288. */
  101289. getClassName(): string;
  101290. /**
  101291. * Get the friendly name associated with the input class.
  101292. * @returns the input friendly name
  101293. */
  101294. getSimpleName(): string;
  101295. }
  101296. }
  101297. declare module BABYLON {
  101298. /**
  101299. * Listen to mouse events to control the camera.
  101300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101301. */
  101302. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101303. /**
  101304. * Defines the camera the input is attached to.
  101305. */
  101306. camera: FlyCamera;
  101307. /**
  101308. * Defines if touch is enabled. (Default is true.)
  101309. */
  101310. touchEnabled: boolean;
  101311. /**
  101312. * Defines the buttons associated with the input to handle camera rotation.
  101313. */
  101314. buttons: number[];
  101315. /**
  101316. * Assign buttons for Yaw control.
  101317. */
  101318. buttonsYaw: number[];
  101319. /**
  101320. * Assign buttons for Pitch control.
  101321. */
  101322. buttonsPitch: number[];
  101323. /**
  101324. * Assign buttons for Roll control.
  101325. */
  101326. buttonsRoll: number[];
  101327. /**
  101328. * Detect if any button is being pressed while mouse is moved.
  101329. * -1 = Mouse locked.
  101330. * 0 = Left button.
  101331. * 1 = Middle Button.
  101332. * 2 = Right Button.
  101333. */
  101334. activeButton: number;
  101335. /**
  101336. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101337. * Higher values reduce its sensitivity.
  101338. */
  101339. angularSensibility: number;
  101340. private _mousemoveCallback;
  101341. private _observer;
  101342. private _rollObserver;
  101343. private previousPosition;
  101344. private noPreventDefault;
  101345. private element;
  101346. /**
  101347. * Listen to mouse events to control the camera.
  101348. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101350. */
  101351. constructor(touchEnabled?: boolean);
  101352. /**
  101353. * Attach the mouse control to the HTML DOM element.
  101354. * @param element Defines the element that listens to the input events.
  101355. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101356. */
  101357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101358. /**
  101359. * Detach the current controls from the specified dom element.
  101360. * @param element Defines the element to stop listening the inputs from
  101361. */
  101362. detachControl(element: Nullable<HTMLElement>): void;
  101363. /**
  101364. * Gets the class name of the current input.
  101365. * @returns the class name.
  101366. */
  101367. getClassName(): string;
  101368. /**
  101369. * Get the friendly name associated with the input class.
  101370. * @returns the input's friendly name.
  101371. */
  101372. getSimpleName(): string;
  101373. private _pointerInput;
  101374. private _onMouseMove;
  101375. /**
  101376. * Rotate camera by mouse offset.
  101377. */
  101378. private rotateCamera;
  101379. }
  101380. }
  101381. declare module BABYLON {
  101382. /**
  101383. * Default Inputs manager for the FlyCamera.
  101384. * It groups all the default supported inputs for ease of use.
  101385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101386. */
  101387. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101388. /**
  101389. * Instantiates a new FlyCameraInputsManager.
  101390. * @param camera Defines the camera the inputs belong to.
  101391. */
  101392. constructor(camera: FlyCamera);
  101393. /**
  101394. * Add keyboard input support to the input manager.
  101395. * @returns the new FlyCameraKeyboardMoveInput().
  101396. */
  101397. addKeyboard(): FlyCameraInputsManager;
  101398. /**
  101399. * Add mouse input support to the input manager.
  101400. * @param touchEnabled Enable touch screen support.
  101401. * @returns the new FlyCameraMouseInput().
  101402. */
  101403. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101404. }
  101405. }
  101406. declare module BABYLON {
  101407. /**
  101408. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101409. * such as in a 3D Space Shooter or a Flight Simulator.
  101410. */
  101411. export class FlyCamera extends TargetCamera {
  101412. /**
  101413. * Define the collision ellipsoid of the camera.
  101414. * This is helpful for simulating a camera body, like a player's body.
  101415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101416. */
  101417. ellipsoid: Vector3;
  101418. /**
  101419. * Define an offset for the position of the ellipsoid around the camera.
  101420. * This can be helpful if the camera is attached away from the player's body center,
  101421. * such as at its head.
  101422. */
  101423. ellipsoidOffset: Vector3;
  101424. /**
  101425. * Enable or disable collisions of the camera with the rest of the scene objects.
  101426. */
  101427. checkCollisions: boolean;
  101428. /**
  101429. * Enable or disable gravity on the camera.
  101430. */
  101431. applyGravity: boolean;
  101432. /**
  101433. * Define the current direction the camera is moving to.
  101434. */
  101435. cameraDirection: Vector3;
  101436. /**
  101437. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101438. * This overrides and empties cameraRotation.
  101439. */
  101440. rotationQuaternion: Quaternion;
  101441. /**
  101442. * Track Roll to maintain the wanted Rolling when looking around.
  101443. */
  101444. _trackRoll: number;
  101445. /**
  101446. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101447. */
  101448. rollCorrect: number;
  101449. /**
  101450. * Mimic a banked turn, Rolling the camera when Yawing.
  101451. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101452. */
  101453. bankedTurn: boolean;
  101454. /**
  101455. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101456. */
  101457. bankedTurnLimit: number;
  101458. /**
  101459. * Value of 0 disables the banked Roll.
  101460. * Value of 1 is equal to the Yaw angle in radians.
  101461. */
  101462. bankedTurnMultiplier: number;
  101463. /**
  101464. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101465. */
  101466. inputs: FlyCameraInputsManager;
  101467. /**
  101468. * Gets the input sensibility for mouse input.
  101469. * Higher values reduce sensitivity.
  101470. */
  101471. /**
  101472. * Sets the input sensibility for a mouse input.
  101473. * Higher values reduce sensitivity.
  101474. */
  101475. angularSensibility: number;
  101476. /**
  101477. * Get the keys for camera movement forward.
  101478. */
  101479. /**
  101480. * Set the keys for camera movement forward.
  101481. */
  101482. keysForward: number[];
  101483. /**
  101484. * Get the keys for camera movement backward.
  101485. */
  101486. keysBackward: number[];
  101487. /**
  101488. * Get the keys for camera movement up.
  101489. */
  101490. /**
  101491. * Set the keys for camera movement up.
  101492. */
  101493. keysUp: number[];
  101494. /**
  101495. * Get the keys for camera movement down.
  101496. */
  101497. /**
  101498. * Set the keys for camera movement down.
  101499. */
  101500. keysDown: number[];
  101501. /**
  101502. * Get the keys for camera movement left.
  101503. */
  101504. /**
  101505. * Set the keys for camera movement left.
  101506. */
  101507. keysLeft: number[];
  101508. /**
  101509. * Set the keys for camera movement right.
  101510. */
  101511. /**
  101512. * Set the keys for camera movement right.
  101513. */
  101514. keysRight: number[];
  101515. /**
  101516. * Event raised when the camera collides with a mesh in the scene.
  101517. */
  101518. onCollide: (collidedMesh: AbstractMesh) => void;
  101519. private _collider;
  101520. private _needMoveForGravity;
  101521. private _oldPosition;
  101522. private _diffPosition;
  101523. private _newPosition;
  101524. /** @hidden */
  101525. _localDirection: Vector3;
  101526. /** @hidden */
  101527. _transformedDirection: Vector3;
  101528. /**
  101529. * Instantiates a FlyCamera.
  101530. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101531. * such as in a 3D Space Shooter or a Flight Simulator.
  101532. * @param name Define the name of the camera in the scene.
  101533. * @param position Define the starting position of the camera in the scene.
  101534. * @param scene Define the scene the camera belongs to.
  101535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101536. */
  101537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101538. /**
  101539. * Attach a control to the HTML DOM element.
  101540. * @param element Defines the element that listens to the input events.
  101541. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101542. */
  101543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101544. /**
  101545. * Detach a control from the HTML DOM element.
  101546. * The camera will stop reacting to that input.
  101547. * @param element Defines the element that listens to the input events.
  101548. */
  101549. detachControl(element: HTMLElement): void;
  101550. private _collisionMask;
  101551. /**
  101552. * Get the mask that the camera ignores in collision events.
  101553. */
  101554. /**
  101555. * Set the mask that the camera ignores in collision events.
  101556. */
  101557. collisionMask: number;
  101558. /** @hidden */
  101559. _collideWithWorld(displacement: Vector3): void;
  101560. /** @hidden */
  101561. private _onCollisionPositionChange;
  101562. /** @hidden */
  101563. _checkInputs(): void;
  101564. /** @hidden */
  101565. _decideIfNeedsToMove(): boolean;
  101566. /** @hidden */
  101567. _updatePosition(): void;
  101568. /**
  101569. * Restore the Roll to its target value at the rate specified.
  101570. * @param rate - Higher means slower restoring.
  101571. * @hidden
  101572. */
  101573. restoreRoll(rate: number): void;
  101574. /**
  101575. * Destroy the camera and release the current resources held by it.
  101576. */
  101577. dispose(): void;
  101578. /**
  101579. * Get the current object class name.
  101580. * @returns the class name.
  101581. */
  101582. getClassName(): string;
  101583. }
  101584. }
  101585. declare module BABYLON {
  101586. /**
  101587. * Listen to keyboard events to control the camera.
  101588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101589. */
  101590. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101591. /**
  101592. * Defines the camera the input is attached to.
  101593. */
  101594. camera: FlyCamera;
  101595. /**
  101596. * The list of keyboard keys used to control the forward move of the camera.
  101597. */
  101598. keysForward: number[];
  101599. /**
  101600. * The list of keyboard keys used to control the backward move of the camera.
  101601. */
  101602. keysBackward: number[];
  101603. /**
  101604. * The list of keyboard keys used to control the forward move of the camera.
  101605. */
  101606. keysUp: number[];
  101607. /**
  101608. * The list of keyboard keys used to control the backward move of the camera.
  101609. */
  101610. keysDown: number[];
  101611. /**
  101612. * The list of keyboard keys used to control the right strafe move of the camera.
  101613. */
  101614. keysRight: number[];
  101615. /**
  101616. * The list of keyboard keys used to control the left strafe move of the camera.
  101617. */
  101618. keysLeft: number[];
  101619. private _keys;
  101620. private _onCanvasBlurObserver;
  101621. private _onKeyboardObserver;
  101622. private _engine;
  101623. private _scene;
  101624. /**
  101625. * Attach the input controls to a specific dom element to get the input from.
  101626. * @param element Defines the element the controls should be listened from
  101627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101628. */
  101629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101630. /**
  101631. * Detach the current controls from the specified dom element.
  101632. * @param element Defines the element to stop listening the inputs from
  101633. */
  101634. detachControl(element: Nullable<HTMLElement>): void;
  101635. /**
  101636. * Gets the class name of the current intput.
  101637. * @returns the class name
  101638. */
  101639. getClassName(): string;
  101640. /** @hidden */
  101641. _onLostFocus(e: FocusEvent): void;
  101642. /**
  101643. * Get the friendly name associated with the input class.
  101644. * @returns the input friendly name
  101645. */
  101646. getSimpleName(): string;
  101647. /**
  101648. * Update the current camera state depending on the inputs that have been used this frame.
  101649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101650. */
  101651. checkInputs(): void;
  101652. }
  101653. }
  101654. declare module BABYLON {
  101655. /**
  101656. * Manage the mouse wheel inputs to control a follow camera.
  101657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101658. */
  101659. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101660. /**
  101661. * Defines the camera the input is attached to.
  101662. */
  101663. camera: FollowCamera;
  101664. /**
  101665. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101666. */
  101667. axisControlRadius: boolean;
  101668. /**
  101669. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101670. */
  101671. axisControlHeight: boolean;
  101672. /**
  101673. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101674. */
  101675. axisControlRotation: boolean;
  101676. /**
  101677. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101678. * relation to mouseWheel events.
  101679. */
  101680. wheelPrecision: number;
  101681. /**
  101682. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101683. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101684. */
  101685. wheelDeltaPercentage: number;
  101686. private _wheel;
  101687. private _observer;
  101688. /**
  101689. * Attach the input controls to a specific dom element to get the input from.
  101690. * @param element Defines the element the controls should be listened from
  101691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101692. */
  101693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101694. /**
  101695. * Detach the current controls from the specified dom element.
  101696. * @param element Defines the element to stop listening the inputs from
  101697. */
  101698. detachControl(element: Nullable<HTMLElement>): void;
  101699. /**
  101700. * Gets the class name of the current intput.
  101701. * @returns the class name
  101702. */
  101703. getClassName(): string;
  101704. /**
  101705. * Get the friendly name associated with the input class.
  101706. * @returns the input friendly name
  101707. */
  101708. getSimpleName(): string;
  101709. }
  101710. }
  101711. declare module BABYLON {
  101712. /**
  101713. * Manage the pointers inputs to control an follow camera.
  101714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101715. */
  101716. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101717. /**
  101718. * Defines the camera the input is attached to.
  101719. */
  101720. camera: FollowCamera;
  101721. /**
  101722. * Gets the class name of the current input.
  101723. * @returns the class name
  101724. */
  101725. getClassName(): string;
  101726. /**
  101727. * Defines the pointer angular sensibility along the X axis or how fast is
  101728. * the camera rotating.
  101729. * A negative number will reverse the axis direction.
  101730. */
  101731. angularSensibilityX: number;
  101732. /**
  101733. * Defines the pointer angular sensibility along the Y axis or how fast is
  101734. * the camera rotating.
  101735. * A negative number will reverse the axis direction.
  101736. */
  101737. angularSensibilityY: number;
  101738. /**
  101739. * Defines the pointer pinch precision or how fast is the camera zooming.
  101740. * A negative number will reverse the axis direction.
  101741. */
  101742. pinchPrecision: number;
  101743. /**
  101744. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101745. * from 0.
  101746. * It defines the percentage of current camera.radius to use as delta when
  101747. * pinch zoom is used.
  101748. */
  101749. pinchDeltaPercentage: number;
  101750. /**
  101751. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101752. */
  101753. axisXControlRadius: boolean;
  101754. /**
  101755. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101756. */
  101757. axisXControlHeight: boolean;
  101758. /**
  101759. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101760. */
  101761. axisXControlRotation: boolean;
  101762. /**
  101763. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101764. */
  101765. axisYControlRadius: boolean;
  101766. /**
  101767. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101768. */
  101769. axisYControlHeight: boolean;
  101770. /**
  101771. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101772. */
  101773. axisYControlRotation: boolean;
  101774. /**
  101775. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101776. */
  101777. axisPinchControlRadius: boolean;
  101778. /**
  101779. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101780. */
  101781. axisPinchControlHeight: boolean;
  101782. /**
  101783. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101784. */
  101785. axisPinchControlRotation: boolean;
  101786. /**
  101787. * Log error messages if basic misconfiguration has occurred.
  101788. */
  101789. warningEnable: boolean;
  101790. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101791. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101792. private _warningCounter;
  101793. private _warning;
  101794. }
  101795. }
  101796. declare module BABYLON {
  101797. /**
  101798. * Default Inputs manager for the FollowCamera.
  101799. * It groups all the default supported inputs for ease of use.
  101800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101801. */
  101802. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101803. /**
  101804. * Instantiates a new FollowCameraInputsManager.
  101805. * @param camera Defines the camera the inputs belong to
  101806. */
  101807. constructor(camera: FollowCamera);
  101808. /**
  101809. * Add keyboard input support to the input manager.
  101810. * @returns the current input manager
  101811. */
  101812. addKeyboard(): FollowCameraInputsManager;
  101813. /**
  101814. * Add mouse wheel input support to the input manager.
  101815. * @returns the current input manager
  101816. */
  101817. addMouseWheel(): FollowCameraInputsManager;
  101818. /**
  101819. * Add pointers input support to the input manager.
  101820. * @returns the current input manager
  101821. */
  101822. addPointers(): FollowCameraInputsManager;
  101823. /**
  101824. * Add orientation input support to the input manager.
  101825. * @returns the current input manager
  101826. */
  101827. addVRDeviceOrientation(): FollowCameraInputsManager;
  101828. }
  101829. }
  101830. declare module BABYLON {
  101831. /**
  101832. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101833. * an arc rotate version arcFollowCamera are available.
  101834. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101835. */
  101836. export class FollowCamera extends TargetCamera {
  101837. /**
  101838. * Distance the follow camera should follow an object at
  101839. */
  101840. radius: number;
  101841. /**
  101842. * Minimum allowed distance of the camera to the axis of rotation
  101843. * (The camera can not get closer).
  101844. * This can help limiting how the Camera is able to move in the scene.
  101845. */
  101846. lowerRadiusLimit: Nullable<number>;
  101847. /**
  101848. * Maximum allowed distance of the camera to the axis of rotation
  101849. * (The camera can not get further).
  101850. * This can help limiting how the Camera is able to move in the scene.
  101851. */
  101852. upperRadiusLimit: Nullable<number>;
  101853. /**
  101854. * Define a rotation offset between the camera and the object it follows
  101855. */
  101856. rotationOffset: number;
  101857. /**
  101858. * Minimum allowed angle to camera position relative to target object.
  101859. * This can help limiting how the Camera is able to move in the scene.
  101860. */
  101861. lowerRotationOffsetLimit: Nullable<number>;
  101862. /**
  101863. * Maximum allowed angle to camera position relative to target object.
  101864. * This can help limiting how the Camera is able to move in the scene.
  101865. */
  101866. upperRotationOffsetLimit: Nullable<number>;
  101867. /**
  101868. * Define a height offset between the camera and the object it follows.
  101869. * It can help following an object from the top (like a car chaing a plane)
  101870. */
  101871. heightOffset: number;
  101872. /**
  101873. * Minimum allowed height of camera position relative to target object.
  101874. * This can help limiting how the Camera is able to move in the scene.
  101875. */
  101876. lowerHeightOffsetLimit: Nullable<number>;
  101877. /**
  101878. * Maximum allowed height of camera position relative to target object.
  101879. * This can help limiting how the Camera is able to move in the scene.
  101880. */
  101881. upperHeightOffsetLimit: Nullable<number>;
  101882. /**
  101883. * Define how fast the camera can accelerate to follow it s target.
  101884. */
  101885. cameraAcceleration: number;
  101886. /**
  101887. * Define the speed limit of the camera following an object.
  101888. */
  101889. maxCameraSpeed: number;
  101890. /**
  101891. * Define the target of the camera.
  101892. */
  101893. lockedTarget: Nullable<AbstractMesh>;
  101894. /**
  101895. * Defines the input associated with the camera.
  101896. */
  101897. inputs: FollowCameraInputsManager;
  101898. /**
  101899. * Instantiates the follow camera.
  101900. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101901. * @param name Define the name of the camera in the scene
  101902. * @param position Define the position of the camera
  101903. * @param scene Define the scene the camera belong to
  101904. * @param lockedTarget Define the target of the camera
  101905. */
  101906. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101907. private _follow;
  101908. /**
  101909. * Attached controls to the current camera.
  101910. * @param element Defines the element the controls should be listened from
  101911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101912. */
  101913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101914. /**
  101915. * Detach the current controls from the camera.
  101916. * The camera will stop reacting to inputs.
  101917. * @param element Defines the element to stop listening the inputs from
  101918. */
  101919. detachControl(element: HTMLElement): void;
  101920. /** @hidden */
  101921. _checkInputs(): void;
  101922. private _checkLimits;
  101923. /**
  101924. * Gets the camera class name.
  101925. * @returns the class name
  101926. */
  101927. getClassName(): string;
  101928. }
  101929. /**
  101930. * Arc Rotate version of the follow camera.
  101931. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101932. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101933. */
  101934. export class ArcFollowCamera extends TargetCamera {
  101935. /** The longitudinal angle of the camera */
  101936. alpha: number;
  101937. /** The latitudinal angle of the camera */
  101938. beta: number;
  101939. /** The radius of the camera from its target */
  101940. radius: number;
  101941. /** Define the camera target (the messh it should follow) */
  101942. target: Nullable<AbstractMesh>;
  101943. private _cartesianCoordinates;
  101944. /**
  101945. * Instantiates a new ArcFollowCamera
  101946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101947. * @param name Define the name of the camera
  101948. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101949. * @param beta Define the rotation angle of the camera around the elevation axis
  101950. * @param radius Define the radius of the camera from its target point
  101951. * @param target Define the target of the camera
  101952. * @param scene Define the scene the camera belongs to
  101953. */
  101954. constructor(name: string,
  101955. /** The longitudinal angle of the camera */
  101956. alpha: number,
  101957. /** The latitudinal angle of the camera */
  101958. beta: number,
  101959. /** The radius of the camera from its target */
  101960. radius: number,
  101961. /** Define the camera target (the messh it should follow) */
  101962. target: Nullable<AbstractMesh>, scene: Scene);
  101963. private _follow;
  101964. /** @hidden */
  101965. _checkInputs(): void;
  101966. /**
  101967. * Returns the class name of the object.
  101968. * It is mostly used internally for serialization purposes.
  101969. */
  101970. getClassName(): string;
  101971. }
  101972. }
  101973. declare module BABYLON {
  101974. /**
  101975. * Manage the keyboard inputs to control the movement of a follow camera.
  101976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101977. */
  101978. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101979. /**
  101980. * Defines the camera the input is attached to.
  101981. */
  101982. camera: FollowCamera;
  101983. /**
  101984. * Defines the list of key codes associated with the up action (increase heightOffset)
  101985. */
  101986. keysHeightOffsetIncr: number[];
  101987. /**
  101988. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101989. */
  101990. keysHeightOffsetDecr: number[];
  101991. /**
  101992. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101993. */
  101994. keysHeightOffsetModifierAlt: boolean;
  101995. /**
  101996. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101997. */
  101998. keysHeightOffsetModifierCtrl: boolean;
  101999. /**
  102000. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102001. */
  102002. keysHeightOffsetModifierShift: boolean;
  102003. /**
  102004. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102005. */
  102006. keysRotationOffsetIncr: number[];
  102007. /**
  102008. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102009. */
  102010. keysRotationOffsetDecr: number[];
  102011. /**
  102012. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102013. */
  102014. keysRotationOffsetModifierAlt: boolean;
  102015. /**
  102016. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102017. */
  102018. keysRotationOffsetModifierCtrl: boolean;
  102019. /**
  102020. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102021. */
  102022. keysRotationOffsetModifierShift: boolean;
  102023. /**
  102024. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102025. */
  102026. keysRadiusIncr: number[];
  102027. /**
  102028. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102029. */
  102030. keysRadiusDecr: number[];
  102031. /**
  102032. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102033. */
  102034. keysRadiusModifierAlt: boolean;
  102035. /**
  102036. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102037. */
  102038. keysRadiusModifierCtrl: boolean;
  102039. /**
  102040. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102041. */
  102042. keysRadiusModifierShift: boolean;
  102043. /**
  102044. * Defines the rate of change of heightOffset.
  102045. */
  102046. heightSensibility: number;
  102047. /**
  102048. * Defines the rate of change of rotationOffset.
  102049. */
  102050. rotationSensibility: number;
  102051. /**
  102052. * Defines the rate of change of radius.
  102053. */
  102054. radiusSensibility: number;
  102055. private _keys;
  102056. private _ctrlPressed;
  102057. private _altPressed;
  102058. private _shiftPressed;
  102059. private _onCanvasBlurObserver;
  102060. private _onKeyboardObserver;
  102061. private _engine;
  102062. private _scene;
  102063. /**
  102064. * Attach the input controls to a specific dom element to get the input from.
  102065. * @param element Defines the element the controls should be listened from
  102066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102067. */
  102068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102069. /**
  102070. * Detach the current controls from the specified dom element.
  102071. * @param element Defines the element to stop listening the inputs from
  102072. */
  102073. detachControl(element: Nullable<HTMLElement>): void;
  102074. /**
  102075. * Update the current camera state depending on the inputs that have been used this frame.
  102076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102077. */
  102078. checkInputs(): void;
  102079. /**
  102080. * Gets the class name of the current input.
  102081. * @returns the class name
  102082. */
  102083. getClassName(): string;
  102084. /**
  102085. * Get the friendly name associated with the input class.
  102086. * @returns the input friendly name
  102087. */
  102088. getSimpleName(): string;
  102089. /**
  102090. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102091. * allow modification of the heightOffset value.
  102092. */
  102093. private _modifierHeightOffset;
  102094. /**
  102095. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102096. * allow modification of the rotationOffset value.
  102097. */
  102098. private _modifierRotationOffset;
  102099. /**
  102100. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102101. * allow modification of the radius value.
  102102. */
  102103. private _modifierRadius;
  102104. }
  102105. }
  102106. declare module BABYLON {
  102107. interface FreeCameraInputsManager {
  102108. /**
  102109. * @hidden
  102110. */
  102111. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102112. /**
  102113. * Add orientation input support to the input manager.
  102114. * @returns the current input manager
  102115. */
  102116. addDeviceOrientation(): FreeCameraInputsManager;
  102117. }
  102118. /**
  102119. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102120. * Screen rotation is taken into account.
  102121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102122. */
  102123. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102124. private _camera;
  102125. private _screenOrientationAngle;
  102126. private _constantTranform;
  102127. private _screenQuaternion;
  102128. private _alpha;
  102129. private _beta;
  102130. private _gamma;
  102131. /**
  102132. * Can be used to detect if a device orientation sensor is availible on a device
  102133. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102134. * @returns a promise that will resolve on orientation change
  102135. */
  102136. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102137. /**
  102138. * @hidden
  102139. */
  102140. _onDeviceOrientationChangedObservable: Observable<void>;
  102141. /**
  102142. * Instantiates a new input
  102143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102144. */
  102145. constructor();
  102146. /**
  102147. * Define the camera controlled by the input.
  102148. */
  102149. camera: FreeCamera;
  102150. /**
  102151. * Attach the input controls to a specific dom element to get the input from.
  102152. * @param element Defines the element the controls should be listened from
  102153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102154. */
  102155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102156. private _orientationChanged;
  102157. private _deviceOrientation;
  102158. /**
  102159. * Detach the current controls from the specified dom element.
  102160. * @param element Defines the element to stop listening the inputs from
  102161. */
  102162. detachControl(element: Nullable<HTMLElement>): void;
  102163. /**
  102164. * Update the current camera state depending on the inputs that have been used this frame.
  102165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102166. */
  102167. checkInputs(): void;
  102168. /**
  102169. * Gets the class name of the current intput.
  102170. * @returns the class name
  102171. */
  102172. getClassName(): string;
  102173. /**
  102174. * Get the friendly name associated with the input class.
  102175. * @returns the input friendly name
  102176. */
  102177. getSimpleName(): string;
  102178. }
  102179. }
  102180. declare module BABYLON {
  102181. /**
  102182. * Manage the gamepad inputs to control a free camera.
  102183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102184. */
  102185. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102186. /**
  102187. * Define the camera the input is attached to.
  102188. */
  102189. camera: FreeCamera;
  102190. /**
  102191. * Define the Gamepad controlling the input
  102192. */
  102193. gamepad: Nullable<Gamepad>;
  102194. /**
  102195. * Defines the gamepad rotation sensiblity.
  102196. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102197. */
  102198. gamepadAngularSensibility: number;
  102199. /**
  102200. * Defines the gamepad move sensiblity.
  102201. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102202. */
  102203. gamepadMoveSensibility: number;
  102204. private _onGamepadConnectedObserver;
  102205. private _onGamepadDisconnectedObserver;
  102206. private _cameraTransform;
  102207. private _deltaTransform;
  102208. private _vector3;
  102209. private _vector2;
  102210. /**
  102211. * Attach the input controls to a specific dom element to get the input from.
  102212. * @param element Defines the element the controls should be listened from
  102213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102214. */
  102215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102216. /**
  102217. * Detach the current controls from the specified dom element.
  102218. * @param element Defines the element to stop listening the inputs from
  102219. */
  102220. detachControl(element: Nullable<HTMLElement>): void;
  102221. /**
  102222. * Update the current camera state depending on the inputs that have been used this frame.
  102223. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102224. */
  102225. checkInputs(): void;
  102226. /**
  102227. * Gets the class name of the current intput.
  102228. * @returns the class name
  102229. */
  102230. getClassName(): string;
  102231. /**
  102232. * Get the friendly name associated with the input class.
  102233. * @returns the input friendly name
  102234. */
  102235. getSimpleName(): string;
  102236. }
  102237. }
  102238. declare module BABYLON {
  102239. /**
  102240. * Defines the potential axis of a Joystick
  102241. */
  102242. export enum JoystickAxis {
  102243. /** X axis */
  102244. X = 0,
  102245. /** Y axis */
  102246. Y = 1,
  102247. /** Z axis */
  102248. Z = 2
  102249. }
  102250. /**
  102251. * Class used to define virtual joystick (used in touch mode)
  102252. */
  102253. export class VirtualJoystick {
  102254. /**
  102255. * Gets or sets a boolean indicating that left and right values must be inverted
  102256. */
  102257. reverseLeftRight: boolean;
  102258. /**
  102259. * Gets or sets a boolean indicating that up and down values must be inverted
  102260. */
  102261. reverseUpDown: boolean;
  102262. /**
  102263. * Gets the offset value for the position (ie. the change of the position value)
  102264. */
  102265. deltaPosition: Vector3;
  102266. /**
  102267. * Gets a boolean indicating if the virtual joystick was pressed
  102268. */
  102269. pressed: boolean;
  102270. /**
  102271. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102272. */
  102273. static Canvas: Nullable<HTMLCanvasElement>;
  102274. private static _globalJoystickIndex;
  102275. private static vjCanvasContext;
  102276. private static vjCanvasWidth;
  102277. private static vjCanvasHeight;
  102278. private static halfWidth;
  102279. private _action;
  102280. private _axisTargetedByLeftAndRight;
  102281. private _axisTargetedByUpAndDown;
  102282. private _joystickSensibility;
  102283. private _inversedSensibility;
  102284. private _joystickPointerID;
  102285. private _joystickColor;
  102286. private _joystickPointerPos;
  102287. private _joystickPreviousPointerPos;
  102288. private _joystickPointerStartPos;
  102289. private _deltaJoystickVector;
  102290. private _leftJoystick;
  102291. private _touches;
  102292. private _onPointerDownHandlerRef;
  102293. private _onPointerMoveHandlerRef;
  102294. private _onPointerUpHandlerRef;
  102295. private _onResize;
  102296. /**
  102297. * Creates a new virtual joystick
  102298. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102299. */
  102300. constructor(leftJoystick?: boolean);
  102301. /**
  102302. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102303. * @param newJoystickSensibility defines the new sensibility
  102304. */
  102305. setJoystickSensibility(newJoystickSensibility: number): void;
  102306. private _onPointerDown;
  102307. private _onPointerMove;
  102308. private _onPointerUp;
  102309. /**
  102310. * Change the color of the virtual joystick
  102311. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102312. */
  102313. setJoystickColor(newColor: string): void;
  102314. /**
  102315. * Defines a callback to call when the joystick is touched
  102316. * @param action defines the callback
  102317. */
  102318. setActionOnTouch(action: () => any): void;
  102319. /**
  102320. * Defines which axis you'd like to control for left & right
  102321. * @param axis defines the axis to use
  102322. */
  102323. setAxisForLeftRight(axis: JoystickAxis): void;
  102324. /**
  102325. * Defines which axis you'd like to control for up & down
  102326. * @param axis defines the axis to use
  102327. */
  102328. setAxisForUpDown(axis: JoystickAxis): void;
  102329. private _drawVirtualJoystick;
  102330. /**
  102331. * Release internal HTML canvas
  102332. */
  102333. releaseCanvas(): void;
  102334. }
  102335. }
  102336. declare module BABYLON {
  102337. interface FreeCameraInputsManager {
  102338. /**
  102339. * Add virtual joystick input support to the input manager.
  102340. * @returns the current input manager
  102341. */
  102342. addVirtualJoystick(): FreeCameraInputsManager;
  102343. }
  102344. /**
  102345. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102347. */
  102348. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102349. /**
  102350. * Defines the camera the input is attached to.
  102351. */
  102352. camera: FreeCamera;
  102353. private _leftjoystick;
  102354. private _rightjoystick;
  102355. /**
  102356. * Gets the left stick of the virtual joystick.
  102357. * @returns The virtual Joystick
  102358. */
  102359. getLeftJoystick(): VirtualJoystick;
  102360. /**
  102361. * Gets the right stick of the virtual joystick.
  102362. * @returns The virtual Joystick
  102363. */
  102364. getRightJoystick(): VirtualJoystick;
  102365. /**
  102366. * Update the current camera state depending on the inputs that have been used this frame.
  102367. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102368. */
  102369. checkInputs(): void;
  102370. /**
  102371. * Attach the input controls to a specific dom element to get the input from.
  102372. * @param element Defines the element the controls should be listened from
  102373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102374. */
  102375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102376. /**
  102377. * Detach the current controls from the specified dom element.
  102378. * @param element Defines the element to stop listening the inputs from
  102379. */
  102380. detachControl(element: Nullable<HTMLElement>): void;
  102381. /**
  102382. * Gets the class name of the current intput.
  102383. * @returns the class name
  102384. */
  102385. getClassName(): string;
  102386. /**
  102387. * Get the friendly name associated with the input class.
  102388. * @returns the input friendly name
  102389. */
  102390. getSimpleName(): string;
  102391. }
  102392. }
  102393. declare module BABYLON {
  102394. /**
  102395. * This represents a FPS type of camera controlled by touch.
  102396. * This is like a universal camera minus the Gamepad controls.
  102397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102398. */
  102399. export class TouchCamera extends FreeCamera {
  102400. /**
  102401. * Defines the touch sensibility for rotation.
  102402. * The higher the faster.
  102403. */
  102404. touchAngularSensibility: number;
  102405. /**
  102406. * Defines the touch sensibility for move.
  102407. * The higher the faster.
  102408. */
  102409. touchMoveSensibility: number;
  102410. /**
  102411. * Instantiates a new touch camera.
  102412. * This represents a FPS type of camera controlled by touch.
  102413. * This is like a universal camera minus the Gamepad controls.
  102414. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102415. * @param name Define the name of the camera in the scene
  102416. * @param position Define the start position of the camera in the scene
  102417. * @param scene Define the scene the camera belongs to
  102418. */
  102419. constructor(name: string, position: Vector3, scene: Scene);
  102420. /**
  102421. * Gets the current object class name.
  102422. * @return the class name
  102423. */
  102424. getClassName(): string;
  102425. /** @hidden */
  102426. _setupInputs(): void;
  102427. }
  102428. }
  102429. declare module BABYLON {
  102430. /**
  102431. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102432. * being tilted forward or back and left or right.
  102433. */
  102434. export class DeviceOrientationCamera extends FreeCamera {
  102435. private _initialQuaternion;
  102436. private _quaternionCache;
  102437. private _tmpDragQuaternion;
  102438. /**
  102439. * Creates a new device orientation camera
  102440. * @param name The name of the camera
  102441. * @param position The start position camera
  102442. * @param scene The scene the camera belongs to
  102443. */
  102444. constructor(name: string, position: Vector3, scene: Scene);
  102445. /**
  102446. * @hidden
  102447. * Disabled pointer input on first orientation sensor update (Default: true)
  102448. */
  102449. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  102450. private _dragFactor;
  102451. /**
  102452. * Enabled turning on the y axis when the orientation sensor is active
  102453. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102454. */
  102455. enableHorizontalDragging(dragFactor?: number): void;
  102456. /**
  102457. * Gets the current instance class name ("DeviceOrientationCamera").
  102458. * This helps avoiding instanceof at run time.
  102459. * @returns the class name
  102460. */
  102461. getClassName(): string;
  102462. /**
  102463. * @hidden
  102464. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102465. */
  102466. _checkInputs(): void;
  102467. /**
  102468. * Reset the camera to its default orientation on the specified axis only.
  102469. * @param axis The axis to reset
  102470. */
  102471. resetToCurrentRotation(axis?: Axis): void;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Defines supported buttons for XBox360 compatible gamepads
  102477. */
  102478. export enum Xbox360Button {
  102479. /** A */
  102480. A = 0,
  102481. /** B */
  102482. B = 1,
  102483. /** X */
  102484. X = 2,
  102485. /** Y */
  102486. Y = 3,
  102487. /** Start */
  102488. Start = 4,
  102489. /** Back */
  102490. Back = 5,
  102491. /** Left button */
  102492. LB = 6,
  102493. /** Right button */
  102494. RB = 7,
  102495. /** Left stick */
  102496. LeftStick = 8,
  102497. /** Right stick */
  102498. RightStick = 9
  102499. }
  102500. /** Defines values for XBox360 DPad */
  102501. export enum Xbox360Dpad {
  102502. /** Up */
  102503. Up = 0,
  102504. /** Down */
  102505. Down = 1,
  102506. /** Left */
  102507. Left = 2,
  102508. /** Right */
  102509. Right = 3
  102510. }
  102511. /**
  102512. * Defines a XBox360 gamepad
  102513. */
  102514. export class Xbox360Pad extends Gamepad {
  102515. private _leftTrigger;
  102516. private _rightTrigger;
  102517. private _onlefttriggerchanged;
  102518. private _onrighttriggerchanged;
  102519. private _onbuttondown;
  102520. private _onbuttonup;
  102521. private _ondpaddown;
  102522. private _ondpadup;
  102523. /** Observable raised when a button is pressed */
  102524. onButtonDownObservable: Observable<Xbox360Button>;
  102525. /** Observable raised when a button is released */
  102526. onButtonUpObservable: Observable<Xbox360Button>;
  102527. /** Observable raised when a pad is pressed */
  102528. onPadDownObservable: Observable<Xbox360Dpad>;
  102529. /** Observable raised when a pad is released */
  102530. onPadUpObservable: Observable<Xbox360Dpad>;
  102531. private _buttonA;
  102532. private _buttonB;
  102533. private _buttonX;
  102534. private _buttonY;
  102535. private _buttonBack;
  102536. private _buttonStart;
  102537. private _buttonLB;
  102538. private _buttonRB;
  102539. private _buttonLeftStick;
  102540. private _buttonRightStick;
  102541. private _dPadUp;
  102542. private _dPadDown;
  102543. private _dPadLeft;
  102544. private _dPadRight;
  102545. private _isXboxOnePad;
  102546. /**
  102547. * Creates a new XBox360 gamepad object
  102548. * @param id defines the id of this gamepad
  102549. * @param index defines its index
  102550. * @param gamepad defines the internal HTML gamepad object
  102551. * @param xboxOne defines if it is a XBox One gamepad
  102552. */
  102553. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102554. /**
  102555. * Defines the callback to call when left trigger is pressed
  102556. * @param callback defines the callback to use
  102557. */
  102558. onlefttriggerchanged(callback: (value: number) => void): void;
  102559. /**
  102560. * Defines the callback to call when right trigger is pressed
  102561. * @param callback defines the callback to use
  102562. */
  102563. onrighttriggerchanged(callback: (value: number) => void): void;
  102564. /**
  102565. * Gets the left trigger value
  102566. */
  102567. /**
  102568. * Sets the left trigger value
  102569. */
  102570. leftTrigger: number;
  102571. /**
  102572. * Gets the right trigger value
  102573. */
  102574. /**
  102575. * Sets the right trigger value
  102576. */
  102577. rightTrigger: number;
  102578. /**
  102579. * Defines the callback to call when a button is pressed
  102580. * @param callback defines the callback to use
  102581. */
  102582. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102583. /**
  102584. * Defines the callback to call when a button is released
  102585. * @param callback defines the callback to use
  102586. */
  102587. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102588. /**
  102589. * Defines the callback to call when a pad is pressed
  102590. * @param callback defines the callback to use
  102591. */
  102592. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102593. /**
  102594. * Defines the callback to call when a pad is released
  102595. * @param callback defines the callback to use
  102596. */
  102597. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102598. private _setButtonValue;
  102599. private _setDPadValue;
  102600. /**
  102601. * Gets the value of the `A` button
  102602. */
  102603. /**
  102604. * Sets the value of the `A` button
  102605. */
  102606. buttonA: number;
  102607. /**
  102608. * Gets the value of the `B` button
  102609. */
  102610. /**
  102611. * Sets the value of the `B` button
  102612. */
  102613. buttonB: number;
  102614. /**
  102615. * Gets the value of the `X` button
  102616. */
  102617. /**
  102618. * Sets the value of the `X` button
  102619. */
  102620. buttonX: number;
  102621. /**
  102622. * Gets the value of the `Y` button
  102623. */
  102624. /**
  102625. * Sets the value of the `Y` button
  102626. */
  102627. buttonY: number;
  102628. /**
  102629. * Gets the value of the `Start` button
  102630. */
  102631. /**
  102632. * Sets the value of the `Start` button
  102633. */
  102634. buttonStart: number;
  102635. /**
  102636. * Gets the value of the `Back` button
  102637. */
  102638. /**
  102639. * Sets the value of the `Back` button
  102640. */
  102641. buttonBack: number;
  102642. /**
  102643. * Gets the value of the `Left` button
  102644. */
  102645. /**
  102646. * Sets the value of the `Left` button
  102647. */
  102648. buttonLB: number;
  102649. /**
  102650. * Gets the value of the `Right` button
  102651. */
  102652. /**
  102653. * Sets the value of the `Right` button
  102654. */
  102655. buttonRB: number;
  102656. /**
  102657. * Gets the value of the Left joystick
  102658. */
  102659. /**
  102660. * Sets the value of the Left joystick
  102661. */
  102662. buttonLeftStick: number;
  102663. /**
  102664. * Gets the value of the Right joystick
  102665. */
  102666. /**
  102667. * Sets the value of the Right joystick
  102668. */
  102669. buttonRightStick: number;
  102670. /**
  102671. * Gets the value of D-pad up
  102672. */
  102673. /**
  102674. * Sets the value of D-pad up
  102675. */
  102676. dPadUp: number;
  102677. /**
  102678. * Gets the value of D-pad down
  102679. */
  102680. /**
  102681. * Sets the value of D-pad down
  102682. */
  102683. dPadDown: number;
  102684. /**
  102685. * Gets the value of D-pad left
  102686. */
  102687. /**
  102688. * Sets the value of D-pad left
  102689. */
  102690. dPadLeft: number;
  102691. /**
  102692. * Gets the value of D-pad right
  102693. */
  102694. /**
  102695. * Sets the value of D-pad right
  102696. */
  102697. dPadRight: number;
  102698. /**
  102699. * Force the gamepad to synchronize with device values
  102700. */
  102701. update(): void;
  102702. /**
  102703. * Disposes the gamepad
  102704. */
  102705. dispose(): void;
  102706. }
  102707. }
  102708. declare module BABYLON {
  102709. /**
  102710. * Defines supported buttons for DualShock compatible gamepads
  102711. */
  102712. export enum DualShockButton {
  102713. /** Cross */
  102714. Cross = 0,
  102715. /** Circle */
  102716. Circle = 1,
  102717. /** Square */
  102718. Square = 2,
  102719. /** Triangle */
  102720. Triangle = 3,
  102721. /** Options */
  102722. Options = 4,
  102723. /** Share */
  102724. Share = 5,
  102725. /** L1 */
  102726. L1 = 6,
  102727. /** R1 */
  102728. R1 = 7,
  102729. /** Left stick */
  102730. LeftStick = 8,
  102731. /** Right stick */
  102732. RightStick = 9
  102733. }
  102734. /** Defines values for DualShock DPad */
  102735. export enum DualShockDpad {
  102736. /** Up */
  102737. Up = 0,
  102738. /** Down */
  102739. Down = 1,
  102740. /** Left */
  102741. Left = 2,
  102742. /** Right */
  102743. Right = 3
  102744. }
  102745. /**
  102746. * Defines a DualShock gamepad
  102747. */
  102748. export class DualShockPad extends Gamepad {
  102749. private _leftTrigger;
  102750. private _rightTrigger;
  102751. private _onlefttriggerchanged;
  102752. private _onrighttriggerchanged;
  102753. private _onbuttondown;
  102754. private _onbuttonup;
  102755. private _ondpaddown;
  102756. private _ondpadup;
  102757. /** Observable raised when a button is pressed */
  102758. onButtonDownObservable: Observable<DualShockButton>;
  102759. /** Observable raised when a button is released */
  102760. onButtonUpObservable: Observable<DualShockButton>;
  102761. /** Observable raised when a pad is pressed */
  102762. onPadDownObservable: Observable<DualShockDpad>;
  102763. /** Observable raised when a pad is released */
  102764. onPadUpObservable: Observable<DualShockDpad>;
  102765. private _buttonCross;
  102766. private _buttonCircle;
  102767. private _buttonSquare;
  102768. private _buttonTriangle;
  102769. private _buttonShare;
  102770. private _buttonOptions;
  102771. private _buttonL1;
  102772. private _buttonR1;
  102773. private _buttonLeftStick;
  102774. private _buttonRightStick;
  102775. private _dPadUp;
  102776. private _dPadDown;
  102777. private _dPadLeft;
  102778. private _dPadRight;
  102779. /**
  102780. * Creates a new DualShock gamepad object
  102781. * @param id defines the id of this gamepad
  102782. * @param index defines its index
  102783. * @param gamepad defines the internal HTML gamepad object
  102784. */
  102785. constructor(id: string, index: number, gamepad: any);
  102786. /**
  102787. * Defines the callback to call when left trigger is pressed
  102788. * @param callback defines the callback to use
  102789. */
  102790. onlefttriggerchanged(callback: (value: number) => void): void;
  102791. /**
  102792. * Defines the callback to call when right trigger is pressed
  102793. * @param callback defines the callback to use
  102794. */
  102795. onrighttriggerchanged(callback: (value: number) => void): void;
  102796. /**
  102797. * Gets the left trigger value
  102798. */
  102799. /**
  102800. * Sets the left trigger value
  102801. */
  102802. leftTrigger: number;
  102803. /**
  102804. * Gets the right trigger value
  102805. */
  102806. /**
  102807. * Sets the right trigger value
  102808. */
  102809. rightTrigger: number;
  102810. /**
  102811. * Defines the callback to call when a button is pressed
  102812. * @param callback defines the callback to use
  102813. */
  102814. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  102815. /**
  102816. * Defines the callback to call when a button is released
  102817. * @param callback defines the callback to use
  102818. */
  102819. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  102820. /**
  102821. * Defines the callback to call when a pad is pressed
  102822. * @param callback defines the callback to use
  102823. */
  102824. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  102825. /**
  102826. * Defines the callback to call when a pad is released
  102827. * @param callback defines the callback to use
  102828. */
  102829. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  102830. private _setButtonValue;
  102831. private _setDPadValue;
  102832. /**
  102833. * Gets the value of the `Cross` button
  102834. */
  102835. /**
  102836. * Sets the value of the `Cross` button
  102837. */
  102838. buttonCross: number;
  102839. /**
  102840. * Gets the value of the `Circle` button
  102841. */
  102842. /**
  102843. * Sets the value of the `Circle` button
  102844. */
  102845. buttonCircle: number;
  102846. /**
  102847. * Gets the value of the `Square` button
  102848. */
  102849. /**
  102850. * Sets the value of the `Square` button
  102851. */
  102852. buttonSquare: number;
  102853. /**
  102854. * Gets the value of the `Triangle` button
  102855. */
  102856. /**
  102857. * Sets the value of the `Triangle` button
  102858. */
  102859. buttonTriangle: number;
  102860. /**
  102861. * Gets the value of the `Options` button
  102862. */
  102863. /**
  102864. * Sets the value of the `Options` button
  102865. */
  102866. buttonOptions: number;
  102867. /**
  102868. * Gets the value of the `Share` button
  102869. */
  102870. /**
  102871. * Sets the value of the `Share` button
  102872. */
  102873. buttonShare: number;
  102874. /**
  102875. * Gets the value of the `L1` button
  102876. */
  102877. /**
  102878. * Sets the value of the `L1` button
  102879. */
  102880. buttonL1: number;
  102881. /**
  102882. * Gets the value of the `R1` button
  102883. */
  102884. /**
  102885. * Sets the value of the `R1` button
  102886. */
  102887. buttonR1: number;
  102888. /**
  102889. * Gets the value of the Left joystick
  102890. */
  102891. /**
  102892. * Sets the value of the Left joystick
  102893. */
  102894. buttonLeftStick: number;
  102895. /**
  102896. * Gets the value of the Right joystick
  102897. */
  102898. /**
  102899. * Sets the value of the Right joystick
  102900. */
  102901. buttonRightStick: number;
  102902. /**
  102903. * Gets the value of D-pad up
  102904. */
  102905. /**
  102906. * Sets the value of D-pad up
  102907. */
  102908. dPadUp: number;
  102909. /**
  102910. * Gets the value of D-pad down
  102911. */
  102912. /**
  102913. * Sets the value of D-pad down
  102914. */
  102915. dPadDown: number;
  102916. /**
  102917. * Gets the value of D-pad left
  102918. */
  102919. /**
  102920. * Sets the value of D-pad left
  102921. */
  102922. dPadLeft: number;
  102923. /**
  102924. * Gets the value of D-pad right
  102925. */
  102926. /**
  102927. * Sets the value of D-pad right
  102928. */
  102929. dPadRight: number;
  102930. /**
  102931. * Force the gamepad to synchronize with device values
  102932. */
  102933. update(): void;
  102934. /**
  102935. * Disposes the gamepad
  102936. */
  102937. dispose(): void;
  102938. }
  102939. }
  102940. declare module BABYLON {
  102941. /**
  102942. * Manager for handling gamepads
  102943. */
  102944. export class GamepadManager {
  102945. private _scene?;
  102946. private _babylonGamepads;
  102947. private _oneGamepadConnected;
  102948. /** @hidden */
  102949. _isMonitoring: boolean;
  102950. private _gamepadEventSupported;
  102951. private _gamepadSupport;
  102952. /**
  102953. * observable to be triggered when the gamepad controller has been connected
  102954. */
  102955. onGamepadConnectedObservable: Observable<Gamepad>;
  102956. /**
  102957. * observable to be triggered when the gamepad controller has been disconnected
  102958. */
  102959. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102960. private _onGamepadConnectedEvent;
  102961. private _onGamepadDisconnectedEvent;
  102962. /**
  102963. * Initializes the gamepad manager
  102964. * @param _scene BabylonJS scene
  102965. */
  102966. constructor(_scene?: Scene | undefined);
  102967. /**
  102968. * The gamepads in the game pad manager
  102969. */
  102970. readonly gamepads: Gamepad[];
  102971. /**
  102972. * Get the gamepad controllers based on type
  102973. * @param type The type of gamepad controller
  102974. * @returns Nullable gamepad
  102975. */
  102976. getGamepadByType(type?: number): Nullable<Gamepad>;
  102977. /**
  102978. * Disposes the gamepad manager
  102979. */
  102980. dispose(): void;
  102981. private _addNewGamepad;
  102982. private _startMonitoringGamepads;
  102983. private _stopMonitoringGamepads;
  102984. /** @hidden */
  102985. _checkGamepadsStatus(): void;
  102986. private _updateGamepadObjects;
  102987. }
  102988. }
  102989. declare module BABYLON {
  102990. interface Scene {
  102991. /** @hidden */
  102992. _gamepadManager: Nullable<GamepadManager>;
  102993. /**
  102994. * Gets the gamepad manager associated with the scene
  102995. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102996. */
  102997. gamepadManager: GamepadManager;
  102998. }
  102999. /**
  103000. * Interface representing a free camera inputs manager
  103001. */
  103002. interface FreeCameraInputsManager {
  103003. /**
  103004. * Adds gamepad input support to the FreeCameraInputsManager.
  103005. * @returns the FreeCameraInputsManager
  103006. */
  103007. addGamepad(): FreeCameraInputsManager;
  103008. }
  103009. /**
  103010. * Interface representing an arc rotate camera inputs manager
  103011. */
  103012. interface ArcRotateCameraInputsManager {
  103013. /**
  103014. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103015. * @returns the camera inputs manager
  103016. */
  103017. addGamepad(): ArcRotateCameraInputsManager;
  103018. }
  103019. /**
  103020. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103021. */
  103022. export class GamepadSystemSceneComponent implements ISceneComponent {
  103023. /**
  103024. * The component name helpfull to identify the component in the list of scene components.
  103025. */
  103026. readonly name: string;
  103027. /**
  103028. * The scene the component belongs to.
  103029. */
  103030. scene: Scene;
  103031. /**
  103032. * Creates a new instance of the component for the given scene
  103033. * @param scene Defines the scene to register the component in
  103034. */
  103035. constructor(scene: Scene);
  103036. /**
  103037. * Registers the component in a given scene
  103038. */
  103039. register(): void;
  103040. /**
  103041. * Rebuilds the elements related to this component in case of
  103042. * context lost for instance.
  103043. */
  103044. rebuild(): void;
  103045. /**
  103046. * Disposes the component and the associated ressources
  103047. */
  103048. dispose(): void;
  103049. private _beforeCameraUpdate;
  103050. }
  103051. }
  103052. declare module BABYLON {
  103053. /**
  103054. * 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,
  103055. * which still works and will still be found in many Playgrounds.
  103056. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103057. */
  103058. export class UniversalCamera extends TouchCamera {
  103059. /**
  103060. * Defines the gamepad rotation sensiblity.
  103061. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103062. */
  103063. gamepadAngularSensibility: number;
  103064. /**
  103065. * Defines the gamepad move sensiblity.
  103066. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103067. */
  103068. gamepadMoveSensibility: number;
  103069. /**
  103070. * 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,
  103071. * which still works and will still be found in many Playgrounds.
  103072. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103073. * @param name Define the name of the camera in the scene
  103074. * @param position Define the start position of the camera in the scene
  103075. * @param scene Define the scene the camera belongs to
  103076. */
  103077. constructor(name: string, position: Vector3, scene: Scene);
  103078. /**
  103079. * Gets the current object class name.
  103080. * @return the class name
  103081. */
  103082. getClassName(): string;
  103083. }
  103084. }
  103085. declare module BABYLON {
  103086. /**
  103087. * This represents a FPS type of camera. This is only here for back compat purpose.
  103088. * Please use the UniversalCamera instead as both are identical.
  103089. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103090. */
  103091. export class GamepadCamera extends UniversalCamera {
  103092. /**
  103093. * Instantiates a new Gamepad Camera
  103094. * This represents a FPS type of camera. This is only here for back compat purpose.
  103095. * Please use the UniversalCamera instead as both are identical.
  103096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103097. * @param name Define the name of the camera in the scene
  103098. * @param position Define the start position of the camera in the scene
  103099. * @param scene Define the scene the camera belongs to
  103100. */
  103101. constructor(name: string, position: Vector3, scene: Scene);
  103102. /**
  103103. * Gets the current object class name.
  103104. * @return the class name
  103105. */
  103106. getClassName(): string;
  103107. }
  103108. }
  103109. declare module BABYLON {
  103110. /** @hidden */
  103111. export var passPixelShader: {
  103112. name: string;
  103113. shader: string;
  103114. };
  103115. }
  103116. declare module BABYLON {
  103117. /** @hidden */
  103118. export var passCubePixelShader: {
  103119. name: string;
  103120. shader: string;
  103121. };
  103122. }
  103123. declare module BABYLON {
  103124. /**
  103125. * PassPostProcess which produces an output the same as it's input
  103126. */
  103127. export class PassPostProcess extends PostProcess {
  103128. /**
  103129. * Creates the PassPostProcess
  103130. * @param name The name of the effect.
  103131. * @param options The required width/height ratio to downsize to before computing the render pass.
  103132. * @param camera The camera to apply the render pass to.
  103133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103134. * @param engine The engine which the post process will be applied. (default: current engine)
  103135. * @param reusable If the post process can be reused on the same frame. (default: false)
  103136. * @param textureType The type of texture to be used when performing the post processing.
  103137. * @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)
  103138. */
  103139. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103140. }
  103141. /**
  103142. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103143. */
  103144. export class PassCubePostProcess extends PostProcess {
  103145. private _face;
  103146. /**
  103147. * Gets or sets the cube face to display.
  103148. * * 0 is +X
  103149. * * 1 is -X
  103150. * * 2 is +Y
  103151. * * 3 is -Y
  103152. * * 4 is +Z
  103153. * * 5 is -Z
  103154. */
  103155. face: number;
  103156. /**
  103157. * Creates the PassCubePostProcess
  103158. * @param name The name of the effect.
  103159. * @param options The required width/height ratio to downsize to before computing the render pass.
  103160. * @param camera The camera to apply the render pass to.
  103161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103162. * @param engine The engine which the post process will be applied. (default: current engine)
  103163. * @param reusable If the post process can be reused on the same frame. (default: false)
  103164. * @param textureType The type of texture to be used when performing the post processing.
  103165. * @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)
  103166. */
  103167. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /** @hidden */
  103172. export var anaglyphPixelShader: {
  103173. name: string;
  103174. shader: string;
  103175. };
  103176. }
  103177. declare module BABYLON {
  103178. /**
  103179. * Postprocess used to generate anaglyphic rendering
  103180. */
  103181. export class AnaglyphPostProcess extends PostProcess {
  103182. private _passedProcess;
  103183. /**
  103184. * Creates a new AnaglyphPostProcess
  103185. * @param name defines postprocess name
  103186. * @param options defines creation options or target ratio scale
  103187. * @param rigCameras defines cameras using this postprocess
  103188. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103189. * @param engine defines hosting engine
  103190. * @param reusable defines if the postprocess will be reused multiple times per frame
  103191. */
  103192. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103193. }
  103194. }
  103195. declare module BABYLON {
  103196. /**
  103197. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103198. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103199. */
  103200. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103201. /**
  103202. * Creates a new AnaglyphArcRotateCamera
  103203. * @param name defines camera name
  103204. * @param alpha defines alpha angle (in radians)
  103205. * @param beta defines beta angle (in radians)
  103206. * @param radius defines radius
  103207. * @param target defines camera target
  103208. * @param interaxialDistance defines distance between each color axis
  103209. * @param scene defines the hosting scene
  103210. */
  103211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103212. /**
  103213. * Gets camera class name
  103214. * @returns AnaglyphArcRotateCamera
  103215. */
  103216. getClassName(): string;
  103217. }
  103218. }
  103219. declare module BABYLON {
  103220. /**
  103221. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103222. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103223. */
  103224. export class AnaglyphFreeCamera extends FreeCamera {
  103225. /**
  103226. * Creates a new AnaglyphFreeCamera
  103227. * @param name defines camera name
  103228. * @param position defines initial position
  103229. * @param interaxialDistance defines distance between each color axis
  103230. * @param scene defines the hosting scene
  103231. */
  103232. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103233. /**
  103234. * Gets camera class name
  103235. * @returns AnaglyphFreeCamera
  103236. */
  103237. getClassName(): string;
  103238. }
  103239. }
  103240. declare module BABYLON {
  103241. /**
  103242. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103243. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103244. */
  103245. export class AnaglyphGamepadCamera extends GamepadCamera {
  103246. /**
  103247. * Creates a new AnaglyphGamepadCamera
  103248. * @param name defines camera name
  103249. * @param position defines initial position
  103250. * @param interaxialDistance defines distance between each color axis
  103251. * @param scene defines the hosting scene
  103252. */
  103253. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103254. /**
  103255. * Gets camera class name
  103256. * @returns AnaglyphGamepadCamera
  103257. */
  103258. getClassName(): string;
  103259. }
  103260. }
  103261. declare module BABYLON {
  103262. /**
  103263. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103264. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103265. */
  103266. export class AnaglyphUniversalCamera extends UniversalCamera {
  103267. /**
  103268. * Creates a new AnaglyphUniversalCamera
  103269. * @param name defines camera name
  103270. * @param position defines initial position
  103271. * @param interaxialDistance defines distance between each color axis
  103272. * @param scene defines the hosting scene
  103273. */
  103274. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103275. /**
  103276. * Gets camera class name
  103277. * @returns AnaglyphUniversalCamera
  103278. */
  103279. getClassName(): string;
  103280. }
  103281. }
  103282. declare module BABYLON {
  103283. /** @hidden */
  103284. export var stereoscopicInterlacePixelShader: {
  103285. name: string;
  103286. shader: string;
  103287. };
  103288. }
  103289. declare module BABYLON {
  103290. /**
  103291. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103292. */
  103293. export class StereoscopicInterlacePostProcess extends PostProcess {
  103294. private _stepSize;
  103295. private _passedProcess;
  103296. /**
  103297. * Initializes a StereoscopicInterlacePostProcess
  103298. * @param name The name of the effect.
  103299. * @param rigCameras The rig cameras to be appled to the post process
  103300. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103302. * @param engine The engine which the post process will be applied. (default: current engine)
  103303. * @param reusable If the post process can be reused on the same frame. (default: false)
  103304. */
  103305. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103306. }
  103307. }
  103308. declare module BABYLON {
  103309. /**
  103310. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103311. * @see http://doc.babylonjs.com/features/cameras
  103312. */
  103313. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103314. /**
  103315. * Creates a new StereoscopicArcRotateCamera
  103316. * @param name defines camera name
  103317. * @param alpha defines alpha angle (in radians)
  103318. * @param beta defines beta angle (in radians)
  103319. * @param radius defines radius
  103320. * @param target defines camera target
  103321. * @param interaxialDistance defines distance between each color axis
  103322. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103323. * @param scene defines the hosting scene
  103324. */
  103325. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103326. /**
  103327. * Gets camera class name
  103328. * @returns StereoscopicArcRotateCamera
  103329. */
  103330. getClassName(): string;
  103331. }
  103332. }
  103333. declare module BABYLON {
  103334. /**
  103335. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103336. * @see http://doc.babylonjs.com/features/cameras
  103337. */
  103338. export class StereoscopicFreeCamera extends FreeCamera {
  103339. /**
  103340. * Creates a new StereoscopicFreeCamera
  103341. * @param name defines camera name
  103342. * @param position defines initial position
  103343. * @param interaxialDistance defines distance between each color axis
  103344. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103345. * @param scene defines the hosting scene
  103346. */
  103347. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103348. /**
  103349. * Gets camera class name
  103350. * @returns StereoscopicFreeCamera
  103351. */
  103352. getClassName(): string;
  103353. }
  103354. }
  103355. declare module BABYLON {
  103356. /**
  103357. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103358. * @see http://doc.babylonjs.com/features/cameras
  103359. */
  103360. export class StereoscopicGamepadCamera extends GamepadCamera {
  103361. /**
  103362. * Creates a new StereoscopicGamepadCamera
  103363. * @param name defines camera name
  103364. * @param position defines initial position
  103365. * @param interaxialDistance defines distance between each color axis
  103366. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103367. * @param scene defines the hosting scene
  103368. */
  103369. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103370. /**
  103371. * Gets camera class name
  103372. * @returns StereoscopicGamepadCamera
  103373. */
  103374. getClassName(): string;
  103375. }
  103376. }
  103377. declare module BABYLON {
  103378. /**
  103379. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103380. * @see http://doc.babylonjs.com/features/cameras
  103381. */
  103382. export class StereoscopicUniversalCamera extends UniversalCamera {
  103383. /**
  103384. * Creates a new StereoscopicUniversalCamera
  103385. * @param name defines camera name
  103386. * @param position defines initial position
  103387. * @param interaxialDistance defines distance between each color axis
  103388. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103389. * @param scene defines the hosting scene
  103390. */
  103391. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103392. /**
  103393. * Gets camera class name
  103394. * @returns StereoscopicUniversalCamera
  103395. */
  103396. getClassName(): string;
  103397. }
  103398. }
  103399. declare module BABYLON {
  103400. /**
  103401. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103402. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103403. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103404. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103405. */
  103406. export class VirtualJoysticksCamera extends FreeCamera {
  103407. /**
  103408. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103409. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103410. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103411. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103412. * @param name Define the name of the camera in the scene
  103413. * @param position Define the start position of the camera in the scene
  103414. * @param scene Define the scene the camera belongs to
  103415. */
  103416. constructor(name: string, position: Vector3, scene: Scene);
  103417. /**
  103418. * Gets the current object class name.
  103419. * @return the class name
  103420. */
  103421. getClassName(): string;
  103422. }
  103423. }
  103424. declare module BABYLON {
  103425. /**
  103426. * This represents all the required metrics to create a VR camera.
  103427. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103428. */
  103429. export class VRCameraMetrics {
  103430. /**
  103431. * Define the horizontal resolution off the screen.
  103432. */
  103433. hResolution: number;
  103434. /**
  103435. * Define the vertical resolution off the screen.
  103436. */
  103437. vResolution: number;
  103438. /**
  103439. * Define the horizontal screen size.
  103440. */
  103441. hScreenSize: number;
  103442. /**
  103443. * Define the vertical screen size.
  103444. */
  103445. vScreenSize: number;
  103446. /**
  103447. * Define the vertical screen center position.
  103448. */
  103449. vScreenCenter: number;
  103450. /**
  103451. * Define the distance of the eyes to the screen.
  103452. */
  103453. eyeToScreenDistance: number;
  103454. /**
  103455. * Define the distance between both lenses
  103456. */
  103457. lensSeparationDistance: number;
  103458. /**
  103459. * Define the distance between both viewer's eyes.
  103460. */
  103461. interpupillaryDistance: number;
  103462. /**
  103463. * Define the distortion factor of the VR postprocess.
  103464. * Please, touch with care.
  103465. */
  103466. distortionK: number[];
  103467. /**
  103468. * Define the chromatic aberration correction factors for the VR post process.
  103469. */
  103470. chromaAbCorrection: number[];
  103471. /**
  103472. * Define the scale factor of the post process.
  103473. * The smaller the better but the slower.
  103474. */
  103475. postProcessScaleFactor: number;
  103476. /**
  103477. * Define an offset for the lens center.
  103478. */
  103479. lensCenterOffset: number;
  103480. /**
  103481. * Define if the current vr camera should compensate the distortion of the lense or not.
  103482. */
  103483. compensateDistortion: boolean;
  103484. /**
  103485. * Defines if multiview should be enabled when rendering (Default: false)
  103486. */
  103487. multiviewEnabled: boolean;
  103488. /**
  103489. * Gets the rendering aspect ratio based on the provided resolutions.
  103490. */
  103491. readonly aspectRatio: number;
  103492. /**
  103493. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103494. */
  103495. readonly aspectRatioFov: number;
  103496. /**
  103497. * @hidden
  103498. */
  103499. readonly leftHMatrix: Matrix;
  103500. /**
  103501. * @hidden
  103502. */
  103503. readonly rightHMatrix: Matrix;
  103504. /**
  103505. * @hidden
  103506. */
  103507. readonly leftPreViewMatrix: Matrix;
  103508. /**
  103509. * @hidden
  103510. */
  103511. readonly rightPreViewMatrix: Matrix;
  103512. /**
  103513. * Get the default VRMetrics based on the most generic setup.
  103514. * @returns the default vr metrics
  103515. */
  103516. static GetDefault(): VRCameraMetrics;
  103517. }
  103518. }
  103519. declare module BABYLON {
  103520. /** @hidden */
  103521. export var vrDistortionCorrectionPixelShader: {
  103522. name: string;
  103523. shader: string;
  103524. };
  103525. }
  103526. declare module BABYLON {
  103527. /**
  103528. * VRDistortionCorrectionPostProcess used for mobile VR
  103529. */
  103530. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103531. private _isRightEye;
  103532. private _distortionFactors;
  103533. private _postProcessScaleFactor;
  103534. private _lensCenterOffset;
  103535. private _scaleIn;
  103536. private _scaleFactor;
  103537. private _lensCenter;
  103538. /**
  103539. * Initializes the VRDistortionCorrectionPostProcess
  103540. * @param name The name of the effect.
  103541. * @param camera The camera to apply the render pass to.
  103542. * @param isRightEye If this is for the right eye distortion
  103543. * @param vrMetrics All the required metrics for the VR camera
  103544. */
  103545. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103546. }
  103547. }
  103548. declare module BABYLON {
  103549. /**
  103550. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103551. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103552. */
  103553. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103554. /**
  103555. * Creates a new VRDeviceOrientationArcRotateCamera
  103556. * @param name defines camera name
  103557. * @param alpha defines the camera rotation along the logitudinal axis
  103558. * @param beta defines the camera rotation along the latitudinal axis
  103559. * @param radius defines the camera distance from its target
  103560. * @param target defines the camera target
  103561. * @param scene defines the scene the camera belongs to
  103562. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103563. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103564. */
  103565. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103566. /**
  103567. * Gets camera class name
  103568. * @returns VRDeviceOrientationArcRotateCamera
  103569. */
  103570. getClassName(): string;
  103571. }
  103572. }
  103573. declare module BABYLON {
  103574. /**
  103575. * Camera used to simulate VR rendering (based on FreeCamera)
  103576. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103577. */
  103578. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103579. /**
  103580. * Creates a new VRDeviceOrientationFreeCamera
  103581. * @param name defines camera name
  103582. * @param position defines the start position of the camera
  103583. * @param scene defines the scene the camera belongs to
  103584. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103585. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103586. */
  103587. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103588. /**
  103589. * Gets camera class name
  103590. * @returns VRDeviceOrientationFreeCamera
  103591. */
  103592. getClassName(): string;
  103593. }
  103594. }
  103595. declare module BABYLON {
  103596. /**
  103597. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103598. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103599. */
  103600. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103601. /**
  103602. * Creates a new VRDeviceOrientationGamepadCamera
  103603. * @param name defines camera name
  103604. * @param position defines the start position of the camera
  103605. * @param scene defines the scene the camera belongs to
  103606. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103607. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103608. */
  103609. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103610. /**
  103611. * Gets camera class name
  103612. * @returns VRDeviceOrientationGamepadCamera
  103613. */
  103614. getClassName(): string;
  103615. }
  103616. }
  103617. declare module BABYLON {
  103618. /**
  103619. * Base class of materials working in push mode in babylon JS
  103620. * @hidden
  103621. */
  103622. export class PushMaterial extends Material {
  103623. protected _activeEffect: Effect;
  103624. protected _normalMatrix: Matrix;
  103625. /**
  103626. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103627. * This means that the material can keep using a previous shader while a new one is being compiled.
  103628. * This is mostly used when shader parallel compilation is supported (true by default)
  103629. */
  103630. allowShaderHotSwapping: boolean;
  103631. constructor(name: string, scene: Scene);
  103632. getEffect(): Effect;
  103633. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103634. /**
  103635. * Binds the given world matrix to the active effect
  103636. *
  103637. * @param world the matrix to bind
  103638. */
  103639. bindOnlyWorldMatrix(world: Matrix): void;
  103640. /**
  103641. * Binds the given normal matrix to the active effect
  103642. *
  103643. * @param normalMatrix the matrix to bind
  103644. */
  103645. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103646. bind(world: Matrix, mesh?: Mesh): void;
  103647. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103648. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * This groups all the flags used to control the materials channel.
  103654. */
  103655. export class MaterialFlags {
  103656. private static _DiffuseTextureEnabled;
  103657. /**
  103658. * Are diffuse textures enabled in the application.
  103659. */
  103660. static DiffuseTextureEnabled: boolean;
  103661. private static _AmbientTextureEnabled;
  103662. /**
  103663. * Are ambient textures enabled in the application.
  103664. */
  103665. static AmbientTextureEnabled: boolean;
  103666. private static _OpacityTextureEnabled;
  103667. /**
  103668. * Are opacity textures enabled in the application.
  103669. */
  103670. static OpacityTextureEnabled: boolean;
  103671. private static _ReflectionTextureEnabled;
  103672. /**
  103673. * Are reflection textures enabled in the application.
  103674. */
  103675. static ReflectionTextureEnabled: boolean;
  103676. private static _EmissiveTextureEnabled;
  103677. /**
  103678. * Are emissive textures enabled in the application.
  103679. */
  103680. static EmissiveTextureEnabled: boolean;
  103681. private static _SpecularTextureEnabled;
  103682. /**
  103683. * Are specular textures enabled in the application.
  103684. */
  103685. static SpecularTextureEnabled: boolean;
  103686. private static _BumpTextureEnabled;
  103687. /**
  103688. * Are bump textures enabled in the application.
  103689. */
  103690. static BumpTextureEnabled: boolean;
  103691. private static _LightmapTextureEnabled;
  103692. /**
  103693. * Are lightmap textures enabled in the application.
  103694. */
  103695. static LightmapTextureEnabled: boolean;
  103696. private static _RefractionTextureEnabled;
  103697. /**
  103698. * Are refraction textures enabled in the application.
  103699. */
  103700. static RefractionTextureEnabled: boolean;
  103701. private static _ColorGradingTextureEnabled;
  103702. /**
  103703. * Are color grading textures enabled in the application.
  103704. */
  103705. static ColorGradingTextureEnabled: boolean;
  103706. private static _FresnelEnabled;
  103707. /**
  103708. * Are fresnels enabled in the application.
  103709. */
  103710. static FresnelEnabled: boolean;
  103711. private static _ClearCoatTextureEnabled;
  103712. /**
  103713. * Are clear coat textures enabled in the application.
  103714. */
  103715. static ClearCoatTextureEnabled: boolean;
  103716. private static _ClearCoatBumpTextureEnabled;
  103717. /**
  103718. * Are clear coat bump textures enabled in the application.
  103719. */
  103720. static ClearCoatBumpTextureEnabled: boolean;
  103721. private static _ClearCoatTintTextureEnabled;
  103722. /**
  103723. * Are clear coat tint textures enabled in the application.
  103724. */
  103725. static ClearCoatTintTextureEnabled: boolean;
  103726. private static _SheenTextureEnabled;
  103727. /**
  103728. * Are sheen textures enabled in the application.
  103729. */
  103730. static SheenTextureEnabled: boolean;
  103731. private static _AnisotropicTextureEnabled;
  103732. /**
  103733. * Are anisotropic textures enabled in the application.
  103734. */
  103735. static AnisotropicTextureEnabled: boolean;
  103736. private static _ThicknessTextureEnabled;
  103737. /**
  103738. * Are thickness textures enabled in the application.
  103739. */
  103740. static ThicknessTextureEnabled: boolean;
  103741. }
  103742. }
  103743. declare module BABYLON {
  103744. /** @hidden */
  103745. export var defaultFragmentDeclaration: {
  103746. name: string;
  103747. shader: string;
  103748. };
  103749. }
  103750. declare module BABYLON {
  103751. /** @hidden */
  103752. export var defaultUboDeclaration: {
  103753. name: string;
  103754. shader: string;
  103755. };
  103756. }
  103757. declare module BABYLON {
  103758. /** @hidden */
  103759. export var lightFragmentDeclaration: {
  103760. name: string;
  103761. shader: string;
  103762. };
  103763. }
  103764. declare module BABYLON {
  103765. /** @hidden */
  103766. export var lightUboDeclaration: {
  103767. name: string;
  103768. shader: string;
  103769. };
  103770. }
  103771. declare module BABYLON {
  103772. /** @hidden */
  103773. export var lightsFragmentFunctions: {
  103774. name: string;
  103775. shader: string;
  103776. };
  103777. }
  103778. declare module BABYLON {
  103779. /** @hidden */
  103780. export var shadowsFragmentFunctions: {
  103781. name: string;
  103782. shader: string;
  103783. };
  103784. }
  103785. declare module BABYLON {
  103786. /** @hidden */
  103787. export var fresnelFunction: {
  103788. name: string;
  103789. shader: string;
  103790. };
  103791. }
  103792. declare module BABYLON {
  103793. /** @hidden */
  103794. export var reflectionFunction: {
  103795. name: string;
  103796. shader: string;
  103797. };
  103798. }
  103799. declare module BABYLON {
  103800. /** @hidden */
  103801. export var bumpFragmentFunctions: {
  103802. name: string;
  103803. shader: string;
  103804. };
  103805. }
  103806. declare module BABYLON {
  103807. /** @hidden */
  103808. export var logDepthDeclaration: {
  103809. name: string;
  103810. shader: string;
  103811. };
  103812. }
  103813. declare module BABYLON {
  103814. /** @hidden */
  103815. export var bumpFragment: {
  103816. name: string;
  103817. shader: string;
  103818. };
  103819. }
  103820. declare module BABYLON {
  103821. /** @hidden */
  103822. export var depthPrePass: {
  103823. name: string;
  103824. shader: string;
  103825. };
  103826. }
  103827. declare module BABYLON {
  103828. /** @hidden */
  103829. export var lightFragment: {
  103830. name: string;
  103831. shader: string;
  103832. };
  103833. }
  103834. declare module BABYLON {
  103835. /** @hidden */
  103836. export var logDepthFragment: {
  103837. name: string;
  103838. shader: string;
  103839. };
  103840. }
  103841. declare module BABYLON {
  103842. /** @hidden */
  103843. export var defaultPixelShader: {
  103844. name: string;
  103845. shader: string;
  103846. };
  103847. }
  103848. declare module BABYLON {
  103849. /** @hidden */
  103850. export var defaultVertexDeclaration: {
  103851. name: string;
  103852. shader: string;
  103853. };
  103854. }
  103855. declare module BABYLON {
  103856. /** @hidden */
  103857. export var bumpVertexDeclaration: {
  103858. name: string;
  103859. shader: string;
  103860. };
  103861. }
  103862. declare module BABYLON {
  103863. /** @hidden */
  103864. export var bumpVertex: {
  103865. name: string;
  103866. shader: string;
  103867. };
  103868. }
  103869. declare module BABYLON {
  103870. /** @hidden */
  103871. export var fogVertex: {
  103872. name: string;
  103873. shader: string;
  103874. };
  103875. }
  103876. declare module BABYLON {
  103877. /** @hidden */
  103878. export var shadowsVertex: {
  103879. name: string;
  103880. shader: string;
  103881. };
  103882. }
  103883. declare module BABYLON {
  103884. /** @hidden */
  103885. export var pointCloudVertex: {
  103886. name: string;
  103887. shader: string;
  103888. };
  103889. }
  103890. declare module BABYLON {
  103891. /** @hidden */
  103892. export var logDepthVertex: {
  103893. name: string;
  103894. shader: string;
  103895. };
  103896. }
  103897. declare module BABYLON {
  103898. /** @hidden */
  103899. export var defaultVertexShader: {
  103900. name: string;
  103901. shader: string;
  103902. };
  103903. }
  103904. declare module BABYLON {
  103905. /** @hidden */
  103906. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103907. MAINUV1: boolean;
  103908. MAINUV2: boolean;
  103909. DIFFUSE: boolean;
  103910. DIFFUSEDIRECTUV: number;
  103911. AMBIENT: boolean;
  103912. AMBIENTDIRECTUV: number;
  103913. OPACITY: boolean;
  103914. OPACITYDIRECTUV: number;
  103915. OPACITYRGB: boolean;
  103916. REFLECTION: boolean;
  103917. EMISSIVE: boolean;
  103918. EMISSIVEDIRECTUV: number;
  103919. SPECULAR: boolean;
  103920. SPECULARDIRECTUV: number;
  103921. BUMP: boolean;
  103922. BUMPDIRECTUV: number;
  103923. PARALLAX: boolean;
  103924. PARALLAXOCCLUSION: boolean;
  103925. SPECULAROVERALPHA: boolean;
  103926. CLIPPLANE: boolean;
  103927. CLIPPLANE2: boolean;
  103928. CLIPPLANE3: boolean;
  103929. CLIPPLANE4: boolean;
  103930. ALPHATEST: boolean;
  103931. DEPTHPREPASS: boolean;
  103932. ALPHAFROMDIFFUSE: boolean;
  103933. POINTSIZE: boolean;
  103934. FOG: boolean;
  103935. SPECULARTERM: boolean;
  103936. DIFFUSEFRESNEL: boolean;
  103937. OPACITYFRESNEL: boolean;
  103938. REFLECTIONFRESNEL: boolean;
  103939. REFRACTIONFRESNEL: boolean;
  103940. EMISSIVEFRESNEL: boolean;
  103941. FRESNEL: boolean;
  103942. NORMAL: boolean;
  103943. UV1: boolean;
  103944. UV2: boolean;
  103945. VERTEXCOLOR: boolean;
  103946. VERTEXALPHA: boolean;
  103947. NUM_BONE_INFLUENCERS: number;
  103948. BonesPerMesh: number;
  103949. BONETEXTURE: boolean;
  103950. INSTANCES: boolean;
  103951. GLOSSINESS: boolean;
  103952. ROUGHNESS: boolean;
  103953. EMISSIVEASILLUMINATION: boolean;
  103954. LINKEMISSIVEWITHDIFFUSE: boolean;
  103955. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103956. LIGHTMAP: boolean;
  103957. LIGHTMAPDIRECTUV: number;
  103958. OBJECTSPACE_NORMALMAP: boolean;
  103959. USELIGHTMAPASSHADOWMAP: boolean;
  103960. REFLECTIONMAP_3D: boolean;
  103961. REFLECTIONMAP_SPHERICAL: boolean;
  103962. REFLECTIONMAP_PLANAR: boolean;
  103963. REFLECTIONMAP_CUBIC: boolean;
  103964. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103965. REFLECTIONMAP_PROJECTION: boolean;
  103966. REFLECTIONMAP_SKYBOX: boolean;
  103967. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103968. REFLECTIONMAP_EXPLICIT: boolean;
  103969. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103970. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103971. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103972. INVERTCUBICMAP: boolean;
  103973. LOGARITHMICDEPTH: boolean;
  103974. REFRACTION: boolean;
  103975. REFRACTIONMAP_3D: boolean;
  103976. REFLECTIONOVERALPHA: boolean;
  103977. TWOSIDEDLIGHTING: boolean;
  103978. SHADOWFLOAT: boolean;
  103979. MORPHTARGETS: boolean;
  103980. MORPHTARGETS_NORMAL: boolean;
  103981. MORPHTARGETS_TANGENT: boolean;
  103982. MORPHTARGETS_UV: boolean;
  103983. NUM_MORPH_INFLUENCERS: number;
  103984. NONUNIFORMSCALING: boolean;
  103985. PREMULTIPLYALPHA: boolean;
  103986. IMAGEPROCESSING: boolean;
  103987. VIGNETTE: boolean;
  103988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103989. VIGNETTEBLENDMODEOPAQUE: boolean;
  103990. TONEMAPPING: boolean;
  103991. TONEMAPPING_ACES: boolean;
  103992. CONTRAST: boolean;
  103993. COLORCURVES: boolean;
  103994. COLORGRADING: boolean;
  103995. COLORGRADING3D: boolean;
  103996. SAMPLER3DGREENDEPTH: boolean;
  103997. SAMPLER3DBGRMAP: boolean;
  103998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103999. MULTIVIEW: boolean;
  104000. /**
  104001. * If the reflection texture on this material is in linear color space
  104002. * @hidden
  104003. */
  104004. IS_REFLECTION_LINEAR: boolean;
  104005. /**
  104006. * If the refraction texture on this material is in linear color space
  104007. * @hidden
  104008. */
  104009. IS_REFRACTION_LINEAR: boolean;
  104010. EXPOSURE: boolean;
  104011. constructor();
  104012. setReflectionMode(modeToEnable: string): void;
  104013. }
  104014. /**
  104015. * This is the default material used in Babylon. It is the best trade off between quality
  104016. * and performances.
  104017. * @see http://doc.babylonjs.com/babylon101/materials
  104018. */
  104019. export class StandardMaterial extends PushMaterial {
  104020. private _diffuseTexture;
  104021. /**
  104022. * The basic texture of the material as viewed under a light.
  104023. */
  104024. diffuseTexture: Nullable<BaseTexture>;
  104025. private _ambientTexture;
  104026. /**
  104027. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104028. */
  104029. ambientTexture: Nullable<BaseTexture>;
  104030. private _opacityTexture;
  104031. /**
  104032. * Define the transparency of the material from a texture.
  104033. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104034. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104035. */
  104036. opacityTexture: Nullable<BaseTexture>;
  104037. private _reflectionTexture;
  104038. /**
  104039. * Define the texture used to display the reflection.
  104040. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104041. */
  104042. reflectionTexture: Nullable<BaseTexture>;
  104043. private _emissiveTexture;
  104044. /**
  104045. * Define texture of the material as if self lit.
  104046. * This will be mixed in the final result even in the absence of light.
  104047. */
  104048. emissiveTexture: Nullable<BaseTexture>;
  104049. private _specularTexture;
  104050. /**
  104051. * Define how the color and intensity of the highlight given by the light in the material.
  104052. */
  104053. specularTexture: Nullable<BaseTexture>;
  104054. private _bumpTexture;
  104055. /**
  104056. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104057. * 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.
  104058. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104059. */
  104060. bumpTexture: Nullable<BaseTexture>;
  104061. private _lightmapTexture;
  104062. /**
  104063. * Complex lighting can be computationally expensive to compute at runtime.
  104064. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104065. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104066. */
  104067. lightmapTexture: Nullable<BaseTexture>;
  104068. private _refractionTexture;
  104069. /**
  104070. * Define the texture used to display the refraction.
  104071. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104072. */
  104073. refractionTexture: Nullable<BaseTexture>;
  104074. /**
  104075. * The color of the material lit by the environmental background lighting.
  104076. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104077. */
  104078. ambientColor: Color3;
  104079. /**
  104080. * The basic color of the material as viewed under a light.
  104081. */
  104082. diffuseColor: Color3;
  104083. /**
  104084. * Define how the color and intensity of the highlight given by the light in the material.
  104085. */
  104086. specularColor: Color3;
  104087. /**
  104088. * Define the color of the material as if self lit.
  104089. * This will be mixed in the final result even in the absence of light.
  104090. */
  104091. emissiveColor: Color3;
  104092. /**
  104093. * Defines how sharp are the highlights in the material.
  104094. * The bigger the value the sharper giving a more glossy feeling to the result.
  104095. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104096. */
  104097. specularPower: number;
  104098. private _useAlphaFromDiffuseTexture;
  104099. /**
  104100. * Does the transparency come from the diffuse texture alpha channel.
  104101. */
  104102. useAlphaFromDiffuseTexture: boolean;
  104103. private _useEmissiveAsIllumination;
  104104. /**
  104105. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104106. */
  104107. useEmissiveAsIllumination: boolean;
  104108. private _linkEmissiveWithDiffuse;
  104109. /**
  104110. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104111. * the emissive level when the final color is close to one.
  104112. */
  104113. linkEmissiveWithDiffuse: boolean;
  104114. private _useSpecularOverAlpha;
  104115. /**
  104116. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104117. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104118. */
  104119. useSpecularOverAlpha: boolean;
  104120. private _useReflectionOverAlpha;
  104121. /**
  104122. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104123. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104124. */
  104125. useReflectionOverAlpha: boolean;
  104126. private _disableLighting;
  104127. /**
  104128. * Does lights from the scene impacts this material.
  104129. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104130. */
  104131. disableLighting: boolean;
  104132. private _useObjectSpaceNormalMap;
  104133. /**
  104134. * Allows using an object space normal map (instead of tangent space).
  104135. */
  104136. useObjectSpaceNormalMap: boolean;
  104137. private _useParallax;
  104138. /**
  104139. * Is parallax enabled or not.
  104140. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104141. */
  104142. useParallax: boolean;
  104143. private _useParallaxOcclusion;
  104144. /**
  104145. * Is parallax occlusion enabled or not.
  104146. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104147. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104148. */
  104149. useParallaxOcclusion: boolean;
  104150. /**
  104151. * 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.
  104152. */
  104153. parallaxScaleBias: number;
  104154. private _roughness;
  104155. /**
  104156. * Helps to define how blurry the reflections should appears in the material.
  104157. */
  104158. roughness: number;
  104159. /**
  104160. * In case of refraction, define the value of the index of refraction.
  104161. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104162. */
  104163. indexOfRefraction: number;
  104164. /**
  104165. * Invert the refraction texture alongside the y axis.
  104166. * It can be useful with procedural textures or probe for instance.
  104167. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104168. */
  104169. invertRefractionY: boolean;
  104170. /**
  104171. * Defines the alpha limits in alpha test mode.
  104172. */
  104173. alphaCutOff: number;
  104174. private _useLightmapAsShadowmap;
  104175. /**
  104176. * In case of light mapping, define whether the map contains light or shadow informations.
  104177. */
  104178. useLightmapAsShadowmap: boolean;
  104179. private _diffuseFresnelParameters;
  104180. /**
  104181. * Define the diffuse fresnel parameters of the material.
  104182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104183. */
  104184. diffuseFresnelParameters: FresnelParameters;
  104185. private _opacityFresnelParameters;
  104186. /**
  104187. * Define the opacity fresnel parameters of the material.
  104188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104189. */
  104190. opacityFresnelParameters: FresnelParameters;
  104191. private _reflectionFresnelParameters;
  104192. /**
  104193. * Define the reflection fresnel parameters of the material.
  104194. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104195. */
  104196. reflectionFresnelParameters: FresnelParameters;
  104197. private _refractionFresnelParameters;
  104198. /**
  104199. * Define the refraction fresnel parameters of the material.
  104200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104201. */
  104202. refractionFresnelParameters: FresnelParameters;
  104203. private _emissiveFresnelParameters;
  104204. /**
  104205. * Define the emissive fresnel parameters of the material.
  104206. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104207. */
  104208. emissiveFresnelParameters: FresnelParameters;
  104209. private _useReflectionFresnelFromSpecular;
  104210. /**
  104211. * If true automatically deducts the fresnels values from the material specularity.
  104212. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104213. */
  104214. useReflectionFresnelFromSpecular: boolean;
  104215. private _useGlossinessFromSpecularMapAlpha;
  104216. /**
  104217. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104218. */
  104219. useGlossinessFromSpecularMapAlpha: boolean;
  104220. private _maxSimultaneousLights;
  104221. /**
  104222. * Defines the maximum number of lights that can be used in the material
  104223. */
  104224. maxSimultaneousLights: number;
  104225. private _invertNormalMapX;
  104226. /**
  104227. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104228. */
  104229. invertNormalMapX: boolean;
  104230. private _invertNormalMapY;
  104231. /**
  104232. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104233. */
  104234. invertNormalMapY: boolean;
  104235. private _twoSidedLighting;
  104236. /**
  104237. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104238. */
  104239. twoSidedLighting: boolean;
  104240. /**
  104241. * Default configuration related to image processing available in the standard Material.
  104242. */
  104243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104244. /**
  104245. * Gets the image processing configuration used either in this material.
  104246. */
  104247. /**
  104248. * Sets the Default image processing configuration used either in the this material.
  104249. *
  104250. * If sets to null, the scene one is in use.
  104251. */
  104252. imageProcessingConfiguration: ImageProcessingConfiguration;
  104253. /**
  104254. * Keep track of the image processing observer to allow dispose and replace.
  104255. */
  104256. private _imageProcessingObserver;
  104257. /**
  104258. * Attaches a new image processing configuration to the Standard Material.
  104259. * @param configuration
  104260. */
  104261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104262. /**
  104263. * Gets wether the color curves effect is enabled.
  104264. */
  104265. /**
  104266. * Sets wether the color curves effect is enabled.
  104267. */
  104268. cameraColorCurvesEnabled: boolean;
  104269. /**
  104270. * Gets wether the color grading effect is enabled.
  104271. */
  104272. /**
  104273. * Gets wether the color grading effect is enabled.
  104274. */
  104275. cameraColorGradingEnabled: boolean;
  104276. /**
  104277. * Gets wether tonemapping is enabled or not.
  104278. */
  104279. /**
  104280. * Sets wether tonemapping is enabled or not
  104281. */
  104282. cameraToneMappingEnabled: boolean;
  104283. /**
  104284. * The camera exposure used on this material.
  104285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104286. * This corresponds to a photographic exposure.
  104287. */
  104288. /**
  104289. * The camera exposure used on this material.
  104290. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104291. * This corresponds to a photographic exposure.
  104292. */
  104293. cameraExposure: number;
  104294. /**
  104295. * Gets The camera contrast used on this material.
  104296. */
  104297. /**
  104298. * Sets The camera contrast used on this material.
  104299. */
  104300. cameraContrast: number;
  104301. /**
  104302. * Gets the Color Grading 2D Lookup Texture.
  104303. */
  104304. /**
  104305. * Sets the Color Grading 2D Lookup Texture.
  104306. */
  104307. cameraColorGradingTexture: Nullable<BaseTexture>;
  104308. /**
  104309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104311. * 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;
  104312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104313. */
  104314. /**
  104315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104317. * 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;
  104318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104319. */
  104320. cameraColorCurves: Nullable<ColorCurves>;
  104321. /**
  104322. * Custom callback helping to override the default shader used in the material.
  104323. */
  104324. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104325. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104326. protected _worldViewProjectionMatrix: Matrix;
  104327. protected _globalAmbientColor: Color3;
  104328. protected _useLogarithmicDepth: boolean;
  104329. /**
  104330. * Instantiates a new standard material.
  104331. * This is the default material used in Babylon. It is the best trade off between quality
  104332. * and performances.
  104333. * @see http://doc.babylonjs.com/babylon101/materials
  104334. * @param name Define the name of the material in the scene
  104335. * @param scene Define the scene the material belong to
  104336. */
  104337. constructor(name: string, scene: Scene);
  104338. /**
  104339. * Gets a boolean indicating that current material needs to register RTT
  104340. */
  104341. readonly hasRenderTargetTextures: boolean;
  104342. /**
  104343. * Gets the current class name of the material e.g. "StandardMaterial"
  104344. * Mainly use in serialization.
  104345. * @returns the class name
  104346. */
  104347. getClassName(): string;
  104348. /**
  104349. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104350. * You can try switching to logarithmic depth.
  104351. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104352. */
  104353. useLogarithmicDepth: boolean;
  104354. /**
  104355. * Specifies if the material will require alpha blending
  104356. * @returns a boolean specifying if alpha blending is needed
  104357. */
  104358. needAlphaBlending(): boolean;
  104359. /**
  104360. * Specifies if this material should be rendered in alpha test mode
  104361. * @returns a boolean specifying if an alpha test is needed.
  104362. */
  104363. needAlphaTesting(): boolean;
  104364. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104365. /**
  104366. * Get the texture used for alpha test purpose.
  104367. * @returns the diffuse texture in case of the standard material.
  104368. */
  104369. getAlphaTestTexture(): Nullable<BaseTexture>;
  104370. /**
  104371. * Get if the submesh is ready to be used and all its information available.
  104372. * Child classes can use it to update shaders
  104373. * @param mesh defines the mesh to check
  104374. * @param subMesh defines which submesh to check
  104375. * @param useInstances specifies that instances should be used
  104376. * @returns a boolean indicating that the submesh is ready or not
  104377. */
  104378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104379. /**
  104380. * Builds the material UBO layouts.
  104381. * Used internally during the effect preparation.
  104382. */
  104383. buildUniformLayout(): void;
  104384. /**
  104385. * Unbinds the material from the mesh
  104386. */
  104387. unbind(): void;
  104388. /**
  104389. * Binds the submesh to this material by preparing the effect and shader to draw
  104390. * @param world defines the world transformation matrix
  104391. * @param mesh defines the mesh containing the submesh
  104392. * @param subMesh defines the submesh to bind the material to
  104393. */
  104394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104395. /**
  104396. * Get the list of animatables in the material.
  104397. * @returns the list of animatables object used in the material
  104398. */
  104399. getAnimatables(): IAnimatable[];
  104400. /**
  104401. * Gets the active textures from the material
  104402. * @returns an array of textures
  104403. */
  104404. getActiveTextures(): BaseTexture[];
  104405. /**
  104406. * Specifies if the material uses a texture
  104407. * @param texture defines the texture to check against the material
  104408. * @returns a boolean specifying if the material uses the texture
  104409. */
  104410. hasTexture(texture: BaseTexture): boolean;
  104411. /**
  104412. * Disposes the material
  104413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104414. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104415. */
  104416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104417. /**
  104418. * Makes a duplicate of the material, and gives it a new name
  104419. * @param name defines the new name for the duplicated material
  104420. * @returns the cloned material
  104421. */
  104422. clone(name: string): StandardMaterial;
  104423. /**
  104424. * Serializes this material in a JSON representation
  104425. * @returns the serialized material object
  104426. */
  104427. serialize(): any;
  104428. /**
  104429. * Creates a standard material from parsed material data
  104430. * @param source defines the JSON representation of the material
  104431. * @param scene defines the hosting scene
  104432. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104433. * @returns a new standard material
  104434. */
  104435. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104436. /**
  104437. * Are diffuse textures enabled in the application.
  104438. */
  104439. static DiffuseTextureEnabled: boolean;
  104440. /**
  104441. * Are ambient textures enabled in the application.
  104442. */
  104443. static AmbientTextureEnabled: boolean;
  104444. /**
  104445. * Are opacity textures enabled in the application.
  104446. */
  104447. static OpacityTextureEnabled: boolean;
  104448. /**
  104449. * Are reflection textures enabled in the application.
  104450. */
  104451. static ReflectionTextureEnabled: boolean;
  104452. /**
  104453. * Are emissive textures enabled in the application.
  104454. */
  104455. static EmissiveTextureEnabled: boolean;
  104456. /**
  104457. * Are specular textures enabled in the application.
  104458. */
  104459. static SpecularTextureEnabled: boolean;
  104460. /**
  104461. * Are bump textures enabled in the application.
  104462. */
  104463. static BumpTextureEnabled: boolean;
  104464. /**
  104465. * Are lightmap textures enabled in the application.
  104466. */
  104467. static LightmapTextureEnabled: boolean;
  104468. /**
  104469. * Are refraction textures enabled in the application.
  104470. */
  104471. static RefractionTextureEnabled: boolean;
  104472. /**
  104473. * Are color grading textures enabled in the application.
  104474. */
  104475. static ColorGradingTextureEnabled: boolean;
  104476. /**
  104477. * Are fresnels enabled in the application.
  104478. */
  104479. static FresnelEnabled: boolean;
  104480. }
  104481. }
  104482. declare module BABYLON {
  104483. /**
  104484. * A class extending Texture allowing drawing on a texture
  104485. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104486. */
  104487. export class DynamicTexture extends Texture {
  104488. private _generateMipMaps;
  104489. private _canvas;
  104490. private _context;
  104491. private _engine;
  104492. /**
  104493. * Creates a DynamicTexture
  104494. * @param name defines the name of the texture
  104495. * @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
  104496. * @param scene defines the scene where you want the texture
  104497. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104498. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104499. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104500. */
  104501. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104502. /**
  104503. * Get the current class name of the texture useful for serialization or dynamic coding.
  104504. * @returns "DynamicTexture"
  104505. */
  104506. getClassName(): string;
  104507. /**
  104508. * Gets the current state of canRescale
  104509. */
  104510. readonly canRescale: boolean;
  104511. private _recreate;
  104512. /**
  104513. * Scales the texture
  104514. * @param ratio the scale factor to apply to both width and height
  104515. */
  104516. scale(ratio: number): void;
  104517. /**
  104518. * Resizes the texture
  104519. * @param width the new width
  104520. * @param height the new height
  104521. */
  104522. scaleTo(width: number, height: number): void;
  104523. /**
  104524. * Gets the context of the canvas used by the texture
  104525. * @returns the canvas context of the dynamic texture
  104526. */
  104527. getContext(): CanvasRenderingContext2D;
  104528. /**
  104529. * Clears the texture
  104530. */
  104531. clear(): void;
  104532. /**
  104533. * Updates the texture
  104534. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104535. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104536. */
  104537. update(invertY?: boolean, premulAlpha?: boolean): void;
  104538. /**
  104539. * Draws text onto the texture
  104540. * @param text defines the text to be drawn
  104541. * @param x defines the placement of the text from the left
  104542. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104543. * @param font defines the font to be used with font-style, font-size, font-name
  104544. * @param color defines the color used for the text
  104545. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104546. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104547. * @param update defines whether texture is immediately update (default is true)
  104548. */
  104549. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104550. /**
  104551. * Clones the texture
  104552. * @returns the clone of the texture.
  104553. */
  104554. clone(): DynamicTexture;
  104555. /**
  104556. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104557. * @returns a serialized dynamic texture object
  104558. */
  104559. serialize(): any;
  104560. /** @hidden */
  104561. _rebuild(): void;
  104562. }
  104563. }
  104564. declare module BABYLON {
  104565. /** @hidden */
  104566. export var imageProcessingPixelShader: {
  104567. name: string;
  104568. shader: string;
  104569. };
  104570. }
  104571. declare module BABYLON {
  104572. /**
  104573. * ImageProcessingPostProcess
  104574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104575. */
  104576. export class ImageProcessingPostProcess extends PostProcess {
  104577. /**
  104578. * Default configuration related to image processing available in the PBR Material.
  104579. */
  104580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104581. /**
  104582. * Gets the image processing configuration used either in this material.
  104583. */
  104584. /**
  104585. * Sets the Default image processing configuration used either in the this material.
  104586. *
  104587. * If sets to null, the scene one is in use.
  104588. */
  104589. imageProcessingConfiguration: ImageProcessingConfiguration;
  104590. /**
  104591. * Keep track of the image processing observer to allow dispose and replace.
  104592. */
  104593. private _imageProcessingObserver;
  104594. /**
  104595. * Attaches a new image processing configuration to the PBR Material.
  104596. * @param configuration
  104597. */
  104598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104599. /**
  104600. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104601. */
  104602. /**
  104603. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104604. */
  104605. colorCurves: Nullable<ColorCurves>;
  104606. /**
  104607. * Gets wether the color curves effect is enabled.
  104608. */
  104609. /**
  104610. * Sets wether the color curves effect is enabled.
  104611. */
  104612. colorCurvesEnabled: boolean;
  104613. /**
  104614. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104615. */
  104616. /**
  104617. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104618. */
  104619. colorGradingTexture: Nullable<BaseTexture>;
  104620. /**
  104621. * Gets wether the color grading effect is enabled.
  104622. */
  104623. /**
  104624. * Gets wether the color grading effect is enabled.
  104625. */
  104626. colorGradingEnabled: boolean;
  104627. /**
  104628. * Gets exposure used in the effect.
  104629. */
  104630. /**
  104631. * Sets exposure used in the effect.
  104632. */
  104633. exposure: number;
  104634. /**
  104635. * Gets wether tonemapping is enabled or not.
  104636. */
  104637. /**
  104638. * Sets wether tonemapping is enabled or not
  104639. */
  104640. toneMappingEnabled: boolean;
  104641. /**
  104642. * Gets the type of tone mapping effect.
  104643. */
  104644. /**
  104645. * Sets the type of tone mapping effect.
  104646. */
  104647. toneMappingType: number;
  104648. /**
  104649. * Gets contrast used in the effect.
  104650. */
  104651. /**
  104652. * Sets contrast used in the effect.
  104653. */
  104654. contrast: number;
  104655. /**
  104656. * Gets Vignette stretch size.
  104657. */
  104658. /**
  104659. * Sets Vignette stretch size.
  104660. */
  104661. vignetteStretch: number;
  104662. /**
  104663. * Gets Vignette centre X Offset.
  104664. */
  104665. /**
  104666. * Sets Vignette centre X Offset.
  104667. */
  104668. vignetteCentreX: number;
  104669. /**
  104670. * Gets Vignette centre Y Offset.
  104671. */
  104672. /**
  104673. * Sets Vignette centre Y Offset.
  104674. */
  104675. vignetteCentreY: number;
  104676. /**
  104677. * Gets Vignette weight or intensity of the vignette effect.
  104678. */
  104679. /**
  104680. * Sets Vignette weight or intensity of the vignette effect.
  104681. */
  104682. vignetteWeight: number;
  104683. /**
  104684. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104685. * if vignetteEnabled is set to true.
  104686. */
  104687. /**
  104688. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104689. * if vignetteEnabled is set to true.
  104690. */
  104691. vignetteColor: Color4;
  104692. /**
  104693. * Gets Camera field of view used by the Vignette effect.
  104694. */
  104695. /**
  104696. * Sets Camera field of view used by the Vignette effect.
  104697. */
  104698. vignetteCameraFov: number;
  104699. /**
  104700. * Gets the vignette blend mode allowing different kind of effect.
  104701. */
  104702. /**
  104703. * Sets the vignette blend mode allowing different kind of effect.
  104704. */
  104705. vignetteBlendMode: number;
  104706. /**
  104707. * Gets wether the vignette effect is enabled.
  104708. */
  104709. /**
  104710. * Sets wether the vignette effect is enabled.
  104711. */
  104712. vignetteEnabled: boolean;
  104713. private _fromLinearSpace;
  104714. /**
  104715. * Gets wether the input of the processing is in Gamma or Linear Space.
  104716. */
  104717. /**
  104718. * Sets wether the input of the processing is in Gamma or Linear Space.
  104719. */
  104720. fromLinearSpace: boolean;
  104721. /**
  104722. * Defines cache preventing GC.
  104723. */
  104724. private _defines;
  104725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104726. /**
  104727. * "ImageProcessingPostProcess"
  104728. * @returns "ImageProcessingPostProcess"
  104729. */
  104730. getClassName(): string;
  104731. protected _updateParameters(): void;
  104732. dispose(camera?: Camera): void;
  104733. }
  104734. }
  104735. declare module BABYLON {
  104736. /**
  104737. * Class containing static functions to help procedurally build meshes
  104738. */
  104739. export class GroundBuilder {
  104740. /**
  104741. * Creates a ground mesh
  104742. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104743. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104745. * @param name defines the name of the mesh
  104746. * @param options defines the options used to create the mesh
  104747. * @param scene defines the hosting scene
  104748. * @returns the ground mesh
  104749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104750. */
  104751. static CreateGround(name: string, options: {
  104752. width?: number;
  104753. height?: number;
  104754. subdivisions?: number;
  104755. subdivisionsX?: number;
  104756. subdivisionsY?: number;
  104757. updatable?: boolean;
  104758. }, scene: any): Mesh;
  104759. /**
  104760. * Creates a tiled ground mesh
  104761. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104762. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104763. * * 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
  104764. * * 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
  104765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104766. * @param name defines the name of the mesh
  104767. * @param options defines the options used to create the mesh
  104768. * @param scene defines the hosting scene
  104769. * @returns the tiled ground mesh
  104770. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104771. */
  104772. static CreateTiledGround(name: string, options: {
  104773. xmin: number;
  104774. zmin: number;
  104775. xmax: number;
  104776. zmax: number;
  104777. subdivisions?: {
  104778. w: number;
  104779. h: number;
  104780. };
  104781. precision?: {
  104782. w: number;
  104783. h: number;
  104784. };
  104785. updatable?: boolean;
  104786. }, scene?: Nullable<Scene>): Mesh;
  104787. /**
  104788. * Creates a ground mesh from a height map
  104789. * * The parameter `url` sets the URL of the height map image resource.
  104790. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104791. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104792. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104793. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104794. * * 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.
  104795. * * 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).
  104796. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104798. * @param name defines the name of the mesh
  104799. * @param url defines the url to the height map
  104800. * @param options defines the options used to create the mesh
  104801. * @param scene defines the hosting scene
  104802. * @returns the ground mesh
  104803. * @see https://doc.babylonjs.com/babylon101/height_map
  104804. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104805. */
  104806. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104807. width?: number;
  104808. height?: number;
  104809. subdivisions?: number;
  104810. minHeight?: number;
  104811. maxHeight?: number;
  104812. colorFilter?: Color3;
  104813. alphaFilter?: number;
  104814. updatable?: boolean;
  104815. onReady?: (mesh: GroundMesh) => void;
  104816. }, scene?: Nullable<Scene>): GroundMesh;
  104817. }
  104818. }
  104819. declare module BABYLON {
  104820. /**
  104821. * Class containing static functions to help procedurally build meshes
  104822. */
  104823. export class TorusBuilder {
  104824. /**
  104825. * Creates a torus mesh
  104826. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104827. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104828. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104832. * @param name defines the name of the mesh
  104833. * @param options defines the options used to create the mesh
  104834. * @param scene defines the hosting scene
  104835. * @returns the torus mesh
  104836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104837. */
  104838. static CreateTorus(name: string, options: {
  104839. diameter?: number;
  104840. thickness?: number;
  104841. tessellation?: number;
  104842. updatable?: boolean;
  104843. sideOrientation?: number;
  104844. frontUVs?: Vector4;
  104845. backUVs?: Vector4;
  104846. }, scene: any): Mesh;
  104847. }
  104848. }
  104849. declare module BABYLON {
  104850. /**
  104851. * Class containing static functions to help procedurally build meshes
  104852. */
  104853. export class CylinderBuilder {
  104854. /**
  104855. * Creates a cylinder or a cone mesh
  104856. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104857. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104858. * * 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.
  104859. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104860. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104861. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104862. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104863. * * 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).
  104864. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104865. * * 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).
  104866. * * 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
  104867. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104868. * * 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
  104869. * * 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.
  104870. * * If `enclose` is false, a ring surface is one element.
  104871. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104872. * * 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
  104873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104876. * @param name defines the name of the mesh
  104877. * @param options defines the options used to create the mesh
  104878. * @param scene defines the hosting scene
  104879. * @returns the cylinder mesh
  104880. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104881. */
  104882. static CreateCylinder(name: string, options: {
  104883. height?: number;
  104884. diameterTop?: number;
  104885. diameterBottom?: number;
  104886. diameter?: number;
  104887. tessellation?: number;
  104888. subdivisions?: number;
  104889. arc?: number;
  104890. faceColors?: Color4[];
  104891. faceUV?: Vector4[];
  104892. updatable?: boolean;
  104893. hasRings?: boolean;
  104894. enclose?: boolean;
  104895. cap?: number;
  104896. sideOrientation?: number;
  104897. frontUVs?: Vector4;
  104898. backUVs?: Vector4;
  104899. }, scene: any): Mesh;
  104900. }
  104901. }
  104902. declare module BABYLON {
  104903. /**
  104904. * Options to modify the vr teleportation behavior.
  104905. */
  104906. export interface VRTeleportationOptions {
  104907. /**
  104908. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104909. */
  104910. floorMeshName?: string;
  104911. /**
  104912. * A list of meshes to be used as the teleportation floor. (default: empty)
  104913. */
  104914. floorMeshes?: Mesh[];
  104915. }
  104916. /**
  104917. * Options to modify the vr experience helper's behavior.
  104918. */
  104919. export interface VRExperienceHelperOptions extends WebVROptions {
  104920. /**
  104921. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104922. */
  104923. createDeviceOrientationCamera?: boolean;
  104924. /**
  104925. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104926. */
  104927. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104928. /**
  104929. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104930. */
  104931. laserToggle?: boolean;
  104932. /**
  104933. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104934. */
  104935. floorMeshes?: Mesh[];
  104936. /**
  104937. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104938. */
  104939. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104940. }
  104941. /**
  104942. * Event containing information after VR has been entered
  104943. */
  104944. export class OnAfterEnteringVRObservableEvent {
  104945. /**
  104946. * If entering vr was successful
  104947. */
  104948. success: boolean;
  104949. }
  104950. /**
  104951. * Helps to quickly add VR support to an existing scene.
  104952. * See http://doc.babylonjs.com/how_to/webvr_helper
  104953. */
  104954. export class VRExperienceHelper {
  104955. /** Options to modify the vr experience helper's behavior. */
  104956. webVROptions: VRExperienceHelperOptions;
  104957. private _scene;
  104958. private _position;
  104959. private _btnVR;
  104960. private _btnVRDisplayed;
  104961. private _webVRsupported;
  104962. private _webVRready;
  104963. private _webVRrequesting;
  104964. private _webVRpresenting;
  104965. private _hasEnteredVR;
  104966. private _fullscreenVRpresenting;
  104967. private _canvas;
  104968. private _webVRCamera;
  104969. private _vrDeviceOrientationCamera;
  104970. private _deviceOrientationCamera;
  104971. private _existingCamera;
  104972. private _onKeyDown;
  104973. private _onVrDisplayPresentChange;
  104974. private _onVRDisplayChanged;
  104975. private _onVRRequestPresentStart;
  104976. private _onVRRequestPresentComplete;
  104977. /**
  104978. * 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)
  104979. */
  104980. enableGazeEvenWhenNoPointerLock: boolean;
  104981. /**
  104982. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104983. */
  104984. exitVROnDoubleTap: boolean;
  104985. /**
  104986. * Observable raised right before entering VR.
  104987. */
  104988. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104989. /**
  104990. * Observable raised when entering VR has completed.
  104991. */
  104992. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104993. /**
  104994. * Observable raised when exiting VR.
  104995. */
  104996. onExitingVRObservable: Observable<VRExperienceHelper>;
  104997. /**
  104998. * Observable raised when controller mesh is loaded.
  104999. */
  105000. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105001. /** Return this.onEnteringVRObservable
  105002. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105003. */
  105004. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105005. /** Return this.onExitingVRObservable
  105006. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105007. */
  105008. readonly onExitingVR: Observable<VRExperienceHelper>;
  105009. /** Return this.onControllerMeshLoadedObservable
  105010. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105011. */
  105012. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105013. private _rayLength;
  105014. private _useCustomVRButton;
  105015. private _teleportationRequested;
  105016. private _teleportActive;
  105017. private _floorMeshName;
  105018. private _floorMeshesCollection;
  105019. private _rotationAllowed;
  105020. private _teleportBackwardsVector;
  105021. private _teleportationTarget;
  105022. private _isDefaultTeleportationTarget;
  105023. private _postProcessMove;
  105024. private _teleportationFillColor;
  105025. private _teleportationBorderColor;
  105026. private _rotationAngle;
  105027. private _haloCenter;
  105028. private _cameraGazer;
  105029. private _padSensibilityUp;
  105030. private _padSensibilityDown;
  105031. private _leftController;
  105032. private _rightController;
  105033. /**
  105034. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105035. */
  105036. onNewMeshSelected: Observable<AbstractMesh>;
  105037. /**
  105038. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105039. */
  105040. onNewMeshPicked: Observable<PickingInfo>;
  105041. private _circleEase;
  105042. /**
  105043. * Observable raised before camera teleportation
  105044. */
  105045. onBeforeCameraTeleport: Observable<Vector3>;
  105046. /**
  105047. * Observable raised after camera teleportation
  105048. */
  105049. onAfterCameraTeleport: Observable<Vector3>;
  105050. /**
  105051. * Observable raised when current selected mesh gets unselected
  105052. */
  105053. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105054. private _raySelectionPredicate;
  105055. /**
  105056. * To be optionaly changed by user to define custom ray selection
  105057. */
  105058. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105059. /**
  105060. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105061. */
  105062. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105063. /**
  105064. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105065. */
  105066. teleportationEnabled: boolean;
  105067. private _defaultHeight;
  105068. private _teleportationInitialized;
  105069. private _interactionsEnabled;
  105070. private _interactionsRequested;
  105071. private _displayGaze;
  105072. private _displayLaserPointer;
  105073. /**
  105074. * The mesh used to display where the user is going to teleport.
  105075. */
  105076. /**
  105077. * Sets the mesh to be used to display where the user is going to teleport.
  105078. */
  105079. teleportationTarget: Mesh;
  105080. /**
  105081. * 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
  105082. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105083. * See http://doc.babylonjs.com/resources/baking_transformations
  105084. */
  105085. gazeTrackerMesh: Mesh;
  105086. /**
  105087. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105088. */
  105089. updateGazeTrackerScale: boolean;
  105090. /**
  105091. * If the gaze trackers color should be updated when selecting meshes
  105092. */
  105093. updateGazeTrackerColor: boolean;
  105094. /**
  105095. * The gaze tracking mesh corresponding to the left controller
  105096. */
  105097. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105098. /**
  105099. * The gaze tracking mesh corresponding to the right controller
  105100. */
  105101. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105102. /**
  105103. * If the ray of the gaze should be displayed.
  105104. */
  105105. /**
  105106. * Sets if the ray of the gaze should be displayed.
  105107. */
  105108. displayGaze: boolean;
  105109. /**
  105110. * If the ray of the LaserPointer should be displayed.
  105111. */
  105112. /**
  105113. * Sets if the ray of the LaserPointer should be displayed.
  105114. */
  105115. displayLaserPointer: boolean;
  105116. /**
  105117. * The deviceOrientationCamera used as the camera when not in VR.
  105118. */
  105119. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105120. /**
  105121. * Based on the current WebVR support, returns the current VR camera used.
  105122. */
  105123. readonly currentVRCamera: Nullable<Camera>;
  105124. /**
  105125. * The webVRCamera which is used when in VR.
  105126. */
  105127. readonly webVRCamera: WebVRFreeCamera;
  105128. /**
  105129. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105130. */
  105131. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105132. /**
  105133. * The html button that is used to trigger entering into VR.
  105134. */
  105135. readonly vrButton: Nullable<HTMLButtonElement>;
  105136. private readonly _teleportationRequestInitiated;
  105137. /**
  105138. * Defines wether or not Pointer lock should be requested when switching to
  105139. * full screen.
  105140. */
  105141. requestPointerLockOnFullScreen: boolean;
  105142. /**
  105143. * Instantiates a VRExperienceHelper.
  105144. * Helps to quickly add VR support to an existing scene.
  105145. * @param scene The scene the VRExperienceHelper belongs to.
  105146. * @param webVROptions Options to modify the vr experience helper's behavior.
  105147. */
  105148. constructor(scene: Scene,
  105149. /** Options to modify the vr experience helper's behavior. */
  105150. webVROptions?: VRExperienceHelperOptions);
  105151. private _onDefaultMeshLoaded;
  105152. private _onResize;
  105153. private _onFullscreenChange;
  105154. /**
  105155. * Gets a value indicating if we are currently in VR mode.
  105156. */
  105157. readonly isInVRMode: boolean;
  105158. private onVrDisplayPresentChange;
  105159. private onVRDisplayChanged;
  105160. private moveButtonToBottomRight;
  105161. private displayVRButton;
  105162. private updateButtonVisibility;
  105163. private _cachedAngularSensibility;
  105164. /**
  105165. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105166. * Otherwise, will use the fullscreen API.
  105167. */
  105168. enterVR(): void;
  105169. /**
  105170. * Attempt to exit VR, or fullscreen.
  105171. */
  105172. exitVR(): void;
  105173. /**
  105174. * The position of the vr experience helper.
  105175. */
  105176. /**
  105177. * Sets the position of the vr experience helper.
  105178. */
  105179. position: Vector3;
  105180. /**
  105181. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105182. */
  105183. enableInteractions(): void;
  105184. private readonly _noControllerIsActive;
  105185. private beforeRender;
  105186. private _isTeleportationFloor;
  105187. /**
  105188. * Adds a floor mesh to be used for teleportation.
  105189. * @param floorMesh the mesh to be used for teleportation.
  105190. */
  105191. addFloorMesh(floorMesh: Mesh): void;
  105192. /**
  105193. * Removes a floor mesh from being used for teleportation.
  105194. * @param floorMesh the mesh to be removed.
  105195. */
  105196. removeFloorMesh(floorMesh: Mesh): void;
  105197. /**
  105198. * Enables interactions and teleportation using the VR controllers and gaze.
  105199. * @param vrTeleportationOptions options to modify teleportation behavior.
  105200. */
  105201. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105202. private _onNewGamepadConnected;
  105203. private _tryEnableInteractionOnController;
  105204. private _onNewGamepadDisconnected;
  105205. private _enableInteractionOnController;
  105206. private _checkTeleportWithRay;
  105207. private _checkRotate;
  105208. private _checkTeleportBackwards;
  105209. private _enableTeleportationOnController;
  105210. private _createTeleportationCircles;
  105211. private _displayTeleportationTarget;
  105212. private _hideTeleportationTarget;
  105213. private _rotateCamera;
  105214. private _moveTeleportationSelectorTo;
  105215. private _workingVector;
  105216. private _workingQuaternion;
  105217. private _workingMatrix;
  105218. /**
  105219. * Teleports the users feet to the desired location
  105220. * @param location The location where the user's feet should be placed
  105221. */
  105222. teleportCamera(location: Vector3): void;
  105223. private _convertNormalToDirectionOfRay;
  105224. private _castRayAndSelectObject;
  105225. private _notifySelectedMeshUnselected;
  105226. /**
  105227. * Sets the color of the laser ray from the vr controllers.
  105228. * @param color new color for the ray.
  105229. */
  105230. changeLaserColor(color: Color3): void;
  105231. /**
  105232. * Sets the color of the ray from the vr headsets gaze.
  105233. * @param color new color for the ray.
  105234. */
  105235. changeGazeColor(color: Color3): void;
  105236. /**
  105237. * Exits VR and disposes of the vr experience helper
  105238. */
  105239. dispose(): void;
  105240. /**
  105241. * Gets the name of the VRExperienceHelper class
  105242. * @returns "VRExperienceHelper"
  105243. */
  105244. getClassName(): string;
  105245. }
  105246. }
  105247. declare module BABYLON {
  105248. /**
  105249. * Manages an XRSession to work with Babylon's engine
  105250. * @see https://doc.babylonjs.com/how_to/webxr
  105251. */
  105252. export class WebXRSessionManager implements IDisposable {
  105253. private scene;
  105254. /**
  105255. * Fires every time a new xrFrame arrives which can be used to update the camera
  105256. */
  105257. onXRFrameObservable: Observable<any>;
  105258. /**
  105259. * Fires when the xr session is ended either by the device or manually done
  105260. */
  105261. onXRSessionEnded: Observable<any>;
  105262. /**
  105263. * Underlying xr session
  105264. */
  105265. session: XRSession;
  105266. /**
  105267. * Type of reference space used when creating the session
  105268. */
  105269. referenceSpace: XRReferenceSpace;
  105270. /** @hidden */
  105271. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105272. /**
  105273. * Current XR frame
  105274. */
  105275. currentFrame: Nullable<XRFrame>;
  105276. private _xrNavigator;
  105277. private baseLayer;
  105278. /**
  105279. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105280. * @param scene The scene which the session should be created for
  105281. */
  105282. constructor(scene: Scene);
  105283. /**
  105284. * Initializes the manager
  105285. * After initialization enterXR can be called to start an XR session
  105286. * @returns Promise which resolves after it is initialized
  105287. */
  105288. initializeAsync(): Promise<void>;
  105289. /**
  105290. * Initializes an xr session
  105291. * @param xrSessionMode mode to initialize
  105292. * @returns a promise which will resolve once the session has been initialized
  105293. */
  105294. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105295. /**
  105296. * Sets the reference space on the xr session
  105297. * @param referenceSpace space to set
  105298. * @returns a promise that will resolve once the reference space has been set
  105299. */
  105300. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105301. /**
  105302. * Updates the render state of the session
  105303. * @param state state to set
  105304. * @returns a promise that resolves once the render state has been updated
  105305. */
  105306. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105307. /**
  105308. * Starts rendering to the xr layer
  105309. * @returns a promise that will resolve once rendering has started
  105310. */
  105311. startRenderingToXRAsync(): Promise<void>;
  105312. /**
  105313. * Stops the xrSession and restores the renderloop
  105314. * @returns Promise which resolves after it exits XR
  105315. */
  105316. exitXRAsync(): Promise<unknown>;
  105317. /**
  105318. * Checks if a session would be supported for the creation options specified
  105319. * @param sessionMode session mode to check if supported eg. immersive-vr
  105320. * @returns true if supported
  105321. */
  105322. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105323. /**
  105324. * @hidden
  105325. * Converts the render layer of xrSession to a render target
  105326. * @param session session to create render target for
  105327. * @param scene scene the new render target should be created for
  105328. */
  105329. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105330. /**
  105331. * Disposes of the session manager
  105332. */
  105333. dispose(): void;
  105334. }
  105335. }
  105336. declare module BABYLON {
  105337. /**
  105338. * WebXR Camera which holds the views for the xrSession
  105339. * @see https://doc.babylonjs.com/how_to/webxr
  105340. */
  105341. export class WebXRCamera extends FreeCamera {
  105342. private static _TmpMatrix;
  105343. /**
  105344. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105345. * @param name the name of the camera
  105346. * @param scene the scene to add the camera to
  105347. */
  105348. constructor(name: string, scene: Scene);
  105349. private _updateNumberOfRigCameras;
  105350. /** @hidden */
  105351. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105352. /**
  105353. * Updates the cameras position from the current pose information of the XR session
  105354. * @param xrSessionManager the session containing pose information
  105355. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105356. */
  105357. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105358. }
  105359. }
  105360. declare module BABYLON {
  105361. /**
  105362. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105363. */
  105364. export class WebXRManagedOutputCanvas implements IDisposable {
  105365. private helper;
  105366. private _canvas;
  105367. /**
  105368. * xrpresent context of the canvas which can be used to display/mirror xr content
  105369. */
  105370. canvasContext: WebGLRenderingContext;
  105371. /**
  105372. * xr layer for the canvas
  105373. */
  105374. xrLayer: Nullable<XRWebGLLayer>;
  105375. /**
  105376. * Initializes the xr layer for the session
  105377. * @param xrSession xr session
  105378. * @returns a promise that will resolve once the XR Layer has been created
  105379. */
  105380. initializeXRLayerAsync(xrSession: any): any;
  105381. /**
  105382. * Initializes the canvas to be added/removed upon entering/exiting xr
  105383. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105384. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105385. */
  105386. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105387. /**
  105388. * Disposes of the object
  105389. */
  105390. dispose(): void;
  105391. private _setManagedOutputCanvas;
  105392. private _addCanvas;
  105393. private _removeCanvas;
  105394. }
  105395. }
  105396. declare module BABYLON {
  105397. /**
  105398. * States of the webXR experience
  105399. */
  105400. export enum WebXRState {
  105401. /**
  105402. * Transitioning to being in XR mode
  105403. */
  105404. ENTERING_XR = 0,
  105405. /**
  105406. * Transitioning to non XR mode
  105407. */
  105408. EXITING_XR = 1,
  105409. /**
  105410. * In XR mode and presenting
  105411. */
  105412. IN_XR = 2,
  105413. /**
  105414. * Not entered XR mode
  105415. */
  105416. NOT_IN_XR = 3
  105417. }
  105418. /**
  105419. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105420. * @see https://doc.babylonjs.com/how_to/webxr
  105421. */
  105422. export class WebXRExperienceHelper implements IDisposable {
  105423. private scene;
  105424. /**
  105425. * 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
  105426. */
  105427. container: AbstractMesh;
  105428. /**
  105429. * Camera used to render xr content
  105430. */
  105431. camera: WebXRCamera;
  105432. /**
  105433. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105434. */
  105435. state: WebXRState;
  105436. private _setState;
  105437. private static _TmpVector;
  105438. /**
  105439. * Fires when the state of the experience helper has changed
  105440. */
  105441. onStateChangedObservable: Observable<WebXRState>;
  105442. /** Session manager used to keep track of xr session */
  105443. sessionManager: WebXRSessionManager;
  105444. private _nonVRCamera;
  105445. private _originalSceneAutoClear;
  105446. private _supported;
  105447. /**
  105448. * Creates the experience helper
  105449. * @param scene the scene to attach the experience helper to
  105450. * @returns a promise for the experience helper
  105451. */
  105452. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105453. /**
  105454. * Creates a WebXRExperienceHelper
  105455. * @param scene The scene the helper should be created in
  105456. */
  105457. private constructor();
  105458. /**
  105459. * Exits XR mode and returns the scene to its original state
  105460. * @returns promise that resolves after xr mode has exited
  105461. */
  105462. exitXRAsync(): Promise<unknown>;
  105463. /**
  105464. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105465. * @param sessionCreationOptions options for the XR session
  105466. * @param referenceSpaceType frame of reference of the XR session
  105467. * @param outputCanvas the output canvas that will be used to enter XR mode
  105468. * @returns promise that resolves after xr mode has entered
  105469. */
  105470. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105471. /**
  105472. * Updates the global position of the camera by moving the camera's container
  105473. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  105474. * @param position The desired global position of the camera
  105475. */
  105476. setPositionOfCameraUsingContainer(position: Vector3): void;
  105477. /**
  105478. * Rotates the xr camera by rotating the camera's container around the camera's position
  105479. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105480. * @param rotation the desired quaternion rotation to apply to the camera
  105481. */
  105482. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105483. /**
  105484. * Disposes of the experience helper
  105485. */
  105486. dispose(): void;
  105487. }
  105488. }
  105489. declare module BABYLON {
  105490. /**
  105491. * Button which can be used to enter a different mode of XR
  105492. */
  105493. export class WebXREnterExitUIButton {
  105494. /** button element */
  105495. element: HTMLElement;
  105496. /** XR initialization options for the button */
  105497. sessionMode: XRSessionMode;
  105498. /** Reference space type */
  105499. referenceSpaceType: XRReferenceSpaceType;
  105500. /**
  105501. * Creates a WebXREnterExitUIButton
  105502. * @param element button element
  105503. * @param sessionMode XR initialization session mode
  105504. * @param referenceSpaceType the type of reference space to be used
  105505. */
  105506. constructor(
  105507. /** button element */
  105508. element: HTMLElement,
  105509. /** XR initialization options for the button */
  105510. sessionMode: XRSessionMode,
  105511. /** Reference space type */
  105512. referenceSpaceType: XRReferenceSpaceType);
  105513. /**
  105514. * Overwritable function which can be used to update the button's visuals when the state changes
  105515. * @param activeButton the current active button in the UI
  105516. */
  105517. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105518. }
  105519. /**
  105520. * Options to create the webXR UI
  105521. */
  105522. export class WebXREnterExitUIOptions {
  105523. /**
  105524. * Context to enter xr with
  105525. */
  105526. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105527. /**
  105528. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105529. */
  105530. customButtons?: Array<WebXREnterExitUIButton>;
  105531. }
  105532. /**
  105533. * UI to allow the user to enter/exit XR mode
  105534. */
  105535. export class WebXREnterExitUI implements IDisposable {
  105536. private scene;
  105537. private _overlay;
  105538. private _buttons;
  105539. private _activeButton;
  105540. /**
  105541. * Fired every time the active button is changed.
  105542. *
  105543. * When xr is entered via a button that launches xr that button will be the callback parameter
  105544. *
  105545. * When exiting xr the callback parameter will be null)
  105546. */
  105547. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105548. /**
  105549. * Creates UI to allow the user to enter/exit XR mode
  105550. * @param scene the scene to add the ui to
  105551. * @param helper the xr experience helper to enter/exit xr with
  105552. * @param options options to configure the UI
  105553. * @returns the created ui
  105554. */
  105555. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105556. private constructor();
  105557. private _updateButtons;
  105558. /**
  105559. * Disposes of the object
  105560. */
  105561. dispose(): void;
  105562. }
  105563. }
  105564. declare module BABYLON {
  105565. /**
  105566. * Represents an XR input
  105567. */
  105568. export class WebXRController {
  105569. private scene;
  105570. /** The underlying input source for the controller */
  105571. inputSource: XRInputSource;
  105572. private parentContainer;
  105573. /**
  105574. * 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
  105575. */
  105576. grip?: AbstractMesh;
  105577. /**
  105578. * Pointer which can be used to select objects or attach a visible laser to
  105579. */
  105580. pointer: AbstractMesh;
  105581. /**
  105582. * Event that fires when the controller is removed/disposed
  105583. */
  105584. onDisposeObservable: Observable<{}>;
  105585. private _tmpMatrix;
  105586. private _tmpQuaternion;
  105587. private _tmpVector;
  105588. /**
  105589. * Creates the controller
  105590. * @see https://doc.babylonjs.com/how_to/webxr
  105591. * @param scene the scene which the controller should be associated to
  105592. * @param inputSource the underlying input source for the controller
  105593. * @param parentContainer parent that the controller meshes should be children of
  105594. */
  105595. constructor(scene: Scene,
  105596. /** The underlying input source for the controller */
  105597. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105598. /**
  105599. * Updates the controller pose based on the given XRFrame
  105600. * @param xrFrame xr frame to update the pose with
  105601. * @param referenceSpace reference space to use
  105602. */
  105603. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105604. /**
  105605. * Gets a world space ray coming from the controller
  105606. * @param result the resulting ray
  105607. */
  105608. getWorldPointerRayToRef(result: Ray): void;
  105609. /**
  105610. * Disposes of the object
  105611. */
  105612. dispose(): void;
  105613. }
  105614. }
  105615. declare module BABYLON {
  105616. /**
  105617. * XR input used to track XR inputs such as controllers/rays
  105618. */
  105619. export class WebXRInput implements IDisposable {
  105620. /**
  105621. * Base experience the input listens to
  105622. */
  105623. baseExperience: WebXRExperienceHelper;
  105624. /**
  105625. * XR controllers being tracked
  105626. */
  105627. controllers: Array<WebXRController>;
  105628. private _frameObserver;
  105629. private _stateObserver;
  105630. /**
  105631. * Event when a controller has been connected/added
  105632. */
  105633. onControllerAddedObservable: Observable<WebXRController>;
  105634. /**
  105635. * Event when a controller has been removed/disconnected
  105636. */
  105637. onControllerRemovedObservable: Observable<WebXRController>;
  105638. /**
  105639. * Initializes the WebXRInput
  105640. * @param baseExperience experience helper which the input should be created for
  105641. */
  105642. constructor(
  105643. /**
  105644. * Base experience the input listens to
  105645. */
  105646. baseExperience: WebXRExperienceHelper);
  105647. private _onInputSourcesChange;
  105648. private _addAndRemoveControllers;
  105649. /**
  105650. * Disposes of the object
  105651. */
  105652. dispose(): void;
  105653. }
  105654. }
  105655. declare module BABYLON {
  105656. /**
  105657. * Enables teleportation
  105658. */
  105659. export class WebXRControllerTeleportation {
  105660. private _teleportationFillColor;
  105661. private _teleportationBorderColor;
  105662. private _tmpRay;
  105663. private _tmpVector;
  105664. /**
  105665. * Creates a WebXRControllerTeleportation
  105666. * @param input input manager to add teleportation to
  105667. * @param floorMeshes floormeshes which can be teleported to
  105668. */
  105669. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105670. }
  105671. }
  105672. declare module BABYLON {
  105673. /**
  105674. * Handles pointer input automatically for the pointer of XR controllers
  105675. */
  105676. export class WebXRControllerPointerSelection {
  105677. private static _idCounter;
  105678. private _tmpRay;
  105679. /**
  105680. * Creates a WebXRControllerPointerSelection
  105681. * @param input input manager to setup pointer selection
  105682. */
  105683. constructor(input: WebXRInput);
  105684. private _convertNormalToDirectionOfRay;
  105685. private _updatePointerDistance;
  105686. }
  105687. }
  105688. declare module BABYLON {
  105689. /**
  105690. * Class used to represent data loading progression
  105691. */
  105692. export class SceneLoaderProgressEvent {
  105693. /** defines if data length to load can be evaluated */
  105694. readonly lengthComputable: boolean;
  105695. /** defines the loaded data length */
  105696. readonly loaded: number;
  105697. /** defines the data length to load */
  105698. readonly total: number;
  105699. /**
  105700. * Create a new progress event
  105701. * @param lengthComputable defines if data length to load can be evaluated
  105702. * @param loaded defines the loaded data length
  105703. * @param total defines the data length to load
  105704. */
  105705. constructor(
  105706. /** defines if data length to load can be evaluated */
  105707. lengthComputable: boolean,
  105708. /** defines the loaded data length */
  105709. loaded: number,
  105710. /** defines the data length to load */
  105711. total: number);
  105712. /**
  105713. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105714. * @param event defines the source event
  105715. * @returns a new SceneLoaderProgressEvent
  105716. */
  105717. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105718. }
  105719. /**
  105720. * Interface used by SceneLoader plugins to define supported file extensions
  105721. */
  105722. export interface ISceneLoaderPluginExtensions {
  105723. /**
  105724. * Defines the list of supported extensions
  105725. */
  105726. [extension: string]: {
  105727. isBinary: boolean;
  105728. };
  105729. }
  105730. /**
  105731. * Interface used by SceneLoader plugin factory
  105732. */
  105733. export interface ISceneLoaderPluginFactory {
  105734. /**
  105735. * Defines the name of the factory
  105736. */
  105737. name: string;
  105738. /**
  105739. * Function called to create a new plugin
  105740. * @return the new plugin
  105741. */
  105742. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105743. /**
  105744. * Boolean indicating if the plugin can direct load specific data
  105745. */
  105746. canDirectLoad?: (data: string) => boolean;
  105747. }
  105748. /**
  105749. * Interface used to define a SceneLoader plugin
  105750. */
  105751. export interface ISceneLoaderPlugin {
  105752. /**
  105753. * The friendly name of this plugin.
  105754. */
  105755. name: string;
  105756. /**
  105757. * The file extensions supported by this plugin.
  105758. */
  105759. extensions: string | ISceneLoaderPluginExtensions;
  105760. /**
  105761. * Import meshes into a scene.
  105762. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105763. * @param scene The scene to import into
  105764. * @param data The data to import
  105765. * @param rootUrl The root url for scene and resources
  105766. * @param meshes The meshes array to import into
  105767. * @param particleSystems The particle systems array to import into
  105768. * @param skeletons The skeletons array to import into
  105769. * @param onError The callback when import fails
  105770. * @returns True if successful or false otherwise
  105771. */
  105772. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105773. /**
  105774. * Load into a scene.
  105775. * @param scene The scene to load into
  105776. * @param data The data to import
  105777. * @param rootUrl The root url for scene and resources
  105778. * @param onError The callback when import fails
  105779. * @returns true if successful or false otherwise
  105780. */
  105781. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105782. /**
  105783. * The callback that returns true if the data can be directly loaded.
  105784. */
  105785. canDirectLoad?: (data: string) => boolean;
  105786. /**
  105787. * The callback that allows custom handling of the root url based on the response url.
  105788. */
  105789. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105790. /**
  105791. * Load into an asset container.
  105792. * @param scene The scene to load into
  105793. * @param data The data to import
  105794. * @param rootUrl The root url for scene and resources
  105795. * @param onError The callback when import fails
  105796. * @returns The loaded asset container
  105797. */
  105798. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105799. }
  105800. /**
  105801. * Interface used to define an async SceneLoader plugin
  105802. */
  105803. export interface ISceneLoaderPluginAsync {
  105804. /**
  105805. * The friendly name of this plugin.
  105806. */
  105807. name: string;
  105808. /**
  105809. * The file extensions supported by this plugin.
  105810. */
  105811. extensions: string | ISceneLoaderPluginExtensions;
  105812. /**
  105813. * Import meshes into a scene.
  105814. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105815. * @param scene The scene to import into
  105816. * @param data The data to import
  105817. * @param rootUrl The root url for scene and resources
  105818. * @param onProgress The callback when the load progresses
  105819. * @param fileName Defines the name of the file to load
  105820. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105821. */
  105822. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105823. meshes: AbstractMesh[];
  105824. particleSystems: IParticleSystem[];
  105825. skeletons: Skeleton[];
  105826. animationGroups: AnimationGroup[];
  105827. }>;
  105828. /**
  105829. * Load into a scene.
  105830. * @param scene The scene to load into
  105831. * @param data The data to import
  105832. * @param rootUrl The root url for scene and resources
  105833. * @param onProgress The callback when the load progresses
  105834. * @param fileName Defines the name of the file to load
  105835. * @returns Nothing
  105836. */
  105837. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105838. /**
  105839. * The callback that returns true if the data can be directly loaded.
  105840. */
  105841. canDirectLoad?: (data: string) => boolean;
  105842. /**
  105843. * The callback that allows custom handling of the root url based on the response url.
  105844. */
  105845. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105846. /**
  105847. * Load into an asset container.
  105848. * @param scene The scene to load into
  105849. * @param data The data to import
  105850. * @param rootUrl The root url for scene and resources
  105851. * @param onProgress The callback when the load progresses
  105852. * @param fileName Defines the name of the file to load
  105853. * @returns The loaded asset container
  105854. */
  105855. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105856. }
  105857. /**
  105858. * Class used to load scene from various file formats using registered plugins
  105859. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105860. */
  105861. export class SceneLoader {
  105862. /**
  105863. * No logging while loading
  105864. */
  105865. static readonly NO_LOGGING: number;
  105866. /**
  105867. * Minimal logging while loading
  105868. */
  105869. static readonly MINIMAL_LOGGING: number;
  105870. /**
  105871. * Summary logging while loading
  105872. */
  105873. static readonly SUMMARY_LOGGING: number;
  105874. /**
  105875. * Detailled logging while loading
  105876. */
  105877. static readonly DETAILED_LOGGING: number;
  105878. /**
  105879. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105880. */
  105881. static ForceFullSceneLoadingForIncremental: boolean;
  105882. /**
  105883. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105884. */
  105885. static ShowLoadingScreen: boolean;
  105886. /**
  105887. * Defines the current logging level (while loading the scene)
  105888. * @ignorenaming
  105889. */
  105890. static loggingLevel: number;
  105891. /**
  105892. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105893. */
  105894. static CleanBoneMatrixWeights: boolean;
  105895. /**
  105896. * Event raised when a plugin is used to load a scene
  105897. */
  105898. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105899. private static _registeredPlugins;
  105900. private static _getDefaultPlugin;
  105901. private static _getPluginForExtension;
  105902. private static _getPluginForDirectLoad;
  105903. private static _getPluginForFilename;
  105904. private static _getDirectLoad;
  105905. private static _loadData;
  105906. private static _getFileInfo;
  105907. /**
  105908. * Gets a plugin that can load the given extension
  105909. * @param extension defines the extension to load
  105910. * @returns a plugin or null if none works
  105911. */
  105912. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105913. /**
  105914. * Gets a boolean indicating that the given extension can be loaded
  105915. * @param extension defines the extension to load
  105916. * @returns true if the extension is supported
  105917. */
  105918. static IsPluginForExtensionAvailable(extension: string): boolean;
  105919. /**
  105920. * Adds a new plugin to the list of registered plugins
  105921. * @param plugin defines the plugin to add
  105922. */
  105923. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105924. /**
  105925. * Import meshes into a scene
  105926. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105927. * @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)
  105928. * @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)
  105929. * @param scene the instance of BABYLON.Scene to append to
  105930. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105931. * @param onProgress a callback with a progress event for each file being loaded
  105932. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105933. * @param pluginExtension the extension used to determine the plugin
  105934. * @returns The loaded plugin
  105935. */
  105936. 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>;
  105937. /**
  105938. * Import meshes into a scene
  105939. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105940. * @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)
  105941. * @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)
  105942. * @param scene the instance of BABYLON.Scene to append to
  105943. * @param onProgress a callback with a progress event for each file being loaded
  105944. * @param pluginExtension the extension used to determine the plugin
  105945. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105946. */
  105947. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105948. meshes: AbstractMesh[];
  105949. particleSystems: IParticleSystem[];
  105950. skeletons: Skeleton[];
  105951. animationGroups: AnimationGroup[];
  105952. }>;
  105953. /**
  105954. * Load a scene
  105955. * @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)
  105956. * @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)
  105957. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105958. * @param onSuccess a callback with the scene when import succeeds
  105959. * @param onProgress a callback with a progress event for each file being loaded
  105960. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105961. * @param pluginExtension the extension used to determine the plugin
  105962. * @returns The loaded plugin
  105963. */
  105964. 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>;
  105965. /**
  105966. * Load a scene
  105967. * @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)
  105968. * @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)
  105969. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105970. * @param onProgress a callback with a progress event for each file being loaded
  105971. * @param pluginExtension the extension used to determine the plugin
  105972. * @returns The loaded scene
  105973. */
  105974. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105975. /**
  105976. * Append a scene
  105977. * @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)
  105978. * @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)
  105979. * @param scene is the instance of BABYLON.Scene to append to
  105980. * @param onSuccess a callback with the scene when import succeeds
  105981. * @param onProgress a callback with a progress event for each file being loaded
  105982. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105983. * @param pluginExtension the extension used to determine the plugin
  105984. * @returns The loaded plugin
  105985. */
  105986. 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>;
  105987. /**
  105988. * Append a scene
  105989. * @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)
  105990. * @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)
  105991. * @param scene is the instance of BABYLON.Scene to append to
  105992. * @param onProgress a callback with a progress event for each file being loaded
  105993. * @param pluginExtension the extension used to determine the plugin
  105994. * @returns The given scene
  105995. */
  105996. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105997. /**
  105998. * Load a scene into an asset container
  105999. * @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)
  106000. * @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)
  106001. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106002. * @param onSuccess a callback with the scene when import succeeds
  106003. * @param onProgress a callback with a progress event for each file being loaded
  106004. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106005. * @param pluginExtension the extension used to determine the plugin
  106006. * @returns The loaded plugin
  106007. */
  106008. 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>;
  106009. /**
  106010. * Load a scene into an asset container
  106011. * @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)
  106012. * @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)
  106013. * @param scene is the instance of Scene to append to
  106014. * @param onProgress a callback with a progress event for each file being loaded
  106015. * @param pluginExtension the extension used to determine the plugin
  106016. * @returns The loaded asset container
  106017. */
  106018. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106019. }
  106020. }
  106021. declare module BABYLON {
  106022. /**
  106023. * Generic Controller
  106024. */
  106025. export class GenericController extends WebVRController {
  106026. /**
  106027. * Base Url for the controller model.
  106028. */
  106029. static readonly MODEL_BASE_URL: string;
  106030. /**
  106031. * File name for the controller model.
  106032. */
  106033. static readonly MODEL_FILENAME: string;
  106034. /**
  106035. * Creates a new GenericController from a gamepad
  106036. * @param vrGamepad the gamepad that the controller should be created from
  106037. */
  106038. constructor(vrGamepad: any);
  106039. /**
  106040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106041. * @param scene scene in which to add meshes
  106042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106043. */
  106044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106045. /**
  106046. * Called once for each button that changed state since the last frame
  106047. * @param buttonIdx Which button index changed
  106048. * @param state New state of the button
  106049. * @param changes Which properties on the state changed since last frame
  106050. */
  106051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106052. }
  106053. }
  106054. declare module BABYLON {
  106055. /**
  106056. * Defines the WindowsMotionController object that the state of the windows motion controller
  106057. */
  106058. export class WindowsMotionController extends WebVRController {
  106059. /**
  106060. * The base url used to load the left and right controller models
  106061. */
  106062. static MODEL_BASE_URL: string;
  106063. /**
  106064. * The name of the left controller model file
  106065. */
  106066. static MODEL_LEFT_FILENAME: string;
  106067. /**
  106068. * The name of the right controller model file
  106069. */
  106070. static MODEL_RIGHT_FILENAME: string;
  106071. /**
  106072. * The controller name prefix for this controller type
  106073. */
  106074. static readonly GAMEPAD_ID_PREFIX: string;
  106075. /**
  106076. * The controller id pattern for this controller type
  106077. */
  106078. private static readonly GAMEPAD_ID_PATTERN;
  106079. private _loadedMeshInfo;
  106080. private readonly _mapping;
  106081. /**
  106082. * Fired when the trackpad on this controller is clicked
  106083. */
  106084. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106085. /**
  106086. * Fired when the trackpad on this controller is modified
  106087. */
  106088. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106089. /**
  106090. * The current x and y values of this controller's trackpad
  106091. */
  106092. trackpad: StickValues;
  106093. /**
  106094. * Creates a new WindowsMotionController from a gamepad
  106095. * @param vrGamepad the gamepad that the controller should be created from
  106096. */
  106097. constructor(vrGamepad: any);
  106098. /**
  106099. * Fired when the trigger on this controller is modified
  106100. */
  106101. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106102. /**
  106103. * Fired when the menu button on this controller is modified
  106104. */
  106105. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106106. /**
  106107. * Fired when the grip button on this controller is modified
  106108. */
  106109. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106110. /**
  106111. * Fired when the thumbstick button on this controller is modified
  106112. */
  106113. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106114. /**
  106115. * Fired when the touchpad button on this controller is modified
  106116. */
  106117. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106118. /**
  106119. * Fired when the touchpad values on this controller are modified
  106120. */
  106121. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106122. private _updateTrackpad;
  106123. /**
  106124. * Called once per frame by the engine.
  106125. */
  106126. update(): void;
  106127. /**
  106128. * Called once for each button that changed state since the last frame
  106129. * @param buttonIdx Which button index changed
  106130. * @param state New state of the button
  106131. * @param changes Which properties on the state changed since last frame
  106132. */
  106133. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106134. /**
  106135. * Moves the buttons on the controller mesh based on their current state
  106136. * @param buttonName the name of the button to move
  106137. * @param buttonValue the value of the button which determines the buttons new position
  106138. */
  106139. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106140. /**
  106141. * Moves the axis on the controller mesh based on its current state
  106142. * @param axis the index of the axis
  106143. * @param axisValue the value of the axis which determines the meshes new position
  106144. * @hidden
  106145. */
  106146. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106147. /**
  106148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106149. * @param scene scene in which to add meshes
  106150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106151. */
  106152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106153. /**
  106154. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106155. * can be transformed by button presses and axes values, based on this._mapping.
  106156. *
  106157. * @param scene scene in which the meshes exist
  106158. * @param meshes list of meshes that make up the controller model to process
  106159. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106160. */
  106161. private processModel;
  106162. private createMeshInfo;
  106163. /**
  106164. * Gets the ray of the controller in the direction the controller is pointing
  106165. * @param length the length the resulting ray should be
  106166. * @returns a ray in the direction the controller is pointing
  106167. */
  106168. getForwardRay(length?: number): Ray;
  106169. /**
  106170. * Disposes of the controller
  106171. */
  106172. dispose(): void;
  106173. }
  106174. }
  106175. declare module BABYLON {
  106176. /**
  106177. * Oculus Touch Controller
  106178. */
  106179. export class OculusTouchController extends WebVRController {
  106180. /**
  106181. * Base Url for the controller model.
  106182. */
  106183. static MODEL_BASE_URL: string;
  106184. /**
  106185. * File name for the left controller model.
  106186. */
  106187. static MODEL_LEFT_FILENAME: string;
  106188. /**
  106189. * File name for the right controller model.
  106190. */
  106191. static MODEL_RIGHT_FILENAME: string;
  106192. /**
  106193. * Base Url for the Quest controller model.
  106194. */
  106195. static QUEST_MODEL_BASE_URL: string;
  106196. /**
  106197. * @hidden
  106198. * If the controllers are running on a device that needs the updated Quest controller models
  106199. */
  106200. static _IsQuest: boolean;
  106201. /**
  106202. * Fired when the secondary trigger on this controller is modified
  106203. */
  106204. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106205. /**
  106206. * Fired when the thumb rest on this controller is modified
  106207. */
  106208. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106209. /**
  106210. * Creates a new OculusTouchController from a gamepad
  106211. * @param vrGamepad the gamepad that the controller should be created from
  106212. */
  106213. constructor(vrGamepad: any);
  106214. /**
  106215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106216. * @param scene scene in which to add meshes
  106217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106218. */
  106219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106220. /**
  106221. * Fired when the A button on this controller is modified
  106222. */
  106223. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106224. /**
  106225. * Fired when the B button on this controller is modified
  106226. */
  106227. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106228. /**
  106229. * Fired when the X button on this controller is modified
  106230. */
  106231. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106232. /**
  106233. * Fired when the Y button on this controller is modified
  106234. */
  106235. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106236. /**
  106237. * Called once for each button that changed state since the last frame
  106238. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106239. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106240. * 2) secondary trigger (same)
  106241. * 3) A (right) X (left), touch, pressed = value
  106242. * 4) B / Y
  106243. * 5) thumb rest
  106244. * @param buttonIdx Which button index changed
  106245. * @param state New state of the button
  106246. * @param changes Which properties on the state changed since last frame
  106247. */
  106248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106249. }
  106250. }
  106251. declare module BABYLON {
  106252. /**
  106253. * Vive Controller
  106254. */
  106255. export class ViveController extends WebVRController {
  106256. /**
  106257. * Base Url for the controller model.
  106258. */
  106259. static MODEL_BASE_URL: string;
  106260. /**
  106261. * File name for the controller model.
  106262. */
  106263. static MODEL_FILENAME: string;
  106264. /**
  106265. * Creates a new ViveController from a gamepad
  106266. * @param vrGamepad the gamepad that the controller should be created from
  106267. */
  106268. constructor(vrGamepad: any);
  106269. /**
  106270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106271. * @param scene scene in which to add meshes
  106272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106273. */
  106274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106275. /**
  106276. * Fired when the left button on this controller is modified
  106277. */
  106278. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106279. /**
  106280. * Fired when the right button on this controller is modified
  106281. */
  106282. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106283. /**
  106284. * Fired when the menu button on this controller is modified
  106285. */
  106286. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106287. /**
  106288. * Called once for each button that changed state since the last frame
  106289. * Vive mapping:
  106290. * 0: touchpad
  106291. * 1: trigger
  106292. * 2: left AND right buttons
  106293. * 3: menu button
  106294. * @param buttonIdx Which button index changed
  106295. * @param state New state of the button
  106296. * @param changes Which properties on the state changed since last frame
  106297. */
  106298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106299. }
  106300. }
  106301. declare module BABYLON {
  106302. /**
  106303. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106304. */
  106305. export class WebXRControllerModelLoader {
  106306. /**
  106307. * Creates the WebXRControllerModelLoader
  106308. * @param input xr input that creates the controllers
  106309. */
  106310. constructor(input: WebXRInput);
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. /**
  106315. * Contains an array of blocks representing the octree
  106316. */
  106317. export interface IOctreeContainer<T> {
  106318. /**
  106319. * Blocks within the octree
  106320. */
  106321. blocks: Array<OctreeBlock<T>>;
  106322. }
  106323. /**
  106324. * Class used to store a cell in an octree
  106325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106326. */
  106327. export class OctreeBlock<T> {
  106328. /**
  106329. * Gets the content of the current block
  106330. */
  106331. entries: T[];
  106332. /**
  106333. * Gets the list of block children
  106334. */
  106335. blocks: Array<OctreeBlock<T>>;
  106336. private _depth;
  106337. private _maxDepth;
  106338. private _capacity;
  106339. private _minPoint;
  106340. private _maxPoint;
  106341. private _boundingVectors;
  106342. private _creationFunc;
  106343. /**
  106344. * Creates a new block
  106345. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106346. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106347. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106348. * @param depth defines the current depth of this block in the octree
  106349. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106350. * @param creationFunc defines a callback to call when an element is added to the block
  106351. */
  106352. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106353. /**
  106354. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106355. */
  106356. readonly capacity: number;
  106357. /**
  106358. * Gets the minimum vector (in world space) of the block's bounding box
  106359. */
  106360. readonly minPoint: Vector3;
  106361. /**
  106362. * Gets the maximum vector (in world space) of the block's bounding box
  106363. */
  106364. readonly maxPoint: Vector3;
  106365. /**
  106366. * Add a new element to this block
  106367. * @param entry defines the element to add
  106368. */
  106369. addEntry(entry: T): void;
  106370. /**
  106371. * Remove an element from this block
  106372. * @param entry defines the element to remove
  106373. */
  106374. removeEntry(entry: T): void;
  106375. /**
  106376. * Add an array of elements to this block
  106377. * @param entries defines the array of elements to add
  106378. */
  106379. addEntries(entries: T[]): void;
  106380. /**
  106381. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106382. * @param frustumPlanes defines the frustum planes to test
  106383. * @param selection defines the array to store current content if selection is positive
  106384. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106385. */
  106386. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106387. /**
  106388. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106389. * @param sphereCenter defines the bounding sphere center
  106390. * @param sphereRadius defines the bounding sphere radius
  106391. * @param selection defines the array to store current content if selection is positive
  106392. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106393. */
  106394. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106395. /**
  106396. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106397. * @param ray defines the ray to test with
  106398. * @param selection defines the array to store current content if selection is positive
  106399. */
  106400. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106401. /**
  106402. * Subdivide the content into child blocks (this block will then be empty)
  106403. */
  106404. createInnerBlocks(): void;
  106405. /**
  106406. * @hidden
  106407. */
  106408. 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;
  106409. }
  106410. }
  106411. declare module BABYLON {
  106412. /**
  106413. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106414. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106415. */
  106416. export class Octree<T> {
  106417. /** 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.) */
  106418. maxDepth: number;
  106419. /**
  106420. * Blocks within the octree containing objects
  106421. */
  106422. blocks: Array<OctreeBlock<T>>;
  106423. /**
  106424. * Content stored in the octree
  106425. */
  106426. dynamicContent: T[];
  106427. private _maxBlockCapacity;
  106428. private _selectionContent;
  106429. private _creationFunc;
  106430. /**
  106431. * Creates a octree
  106432. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106433. * @param creationFunc function to be used to instatiate the octree
  106434. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106435. * @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.)
  106436. */
  106437. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106438. /** 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.) */
  106439. maxDepth?: number);
  106440. /**
  106441. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106442. * @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);
  106443. * @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);
  106444. * @param entries meshes to be added to the octree blocks
  106445. */
  106446. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106447. /**
  106448. * Adds a mesh to the octree
  106449. * @param entry Mesh to add to the octree
  106450. */
  106451. addMesh(entry: T): void;
  106452. /**
  106453. * Remove an element from the octree
  106454. * @param entry defines the element to remove
  106455. */
  106456. removeMesh(entry: T): void;
  106457. /**
  106458. * Selects an array of meshes within the frustum
  106459. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106460. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106461. * @returns array of meshes within the frustum
  106462. */
  106463. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106464. /**
  106465. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106466. * @param sphereCenter defines the bounding sphere center
  106467. * @param sphereRadius defines the bounding sphere radius
  106468. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106469. * @returns an array of objects that intersect the sphere
  106470. */
  106471. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106472. /**
  106473. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  106474. * @param ray defines the ray to test with
  106475. * @returns array of intersected objects
  106476. */
  106477. intersectsRay(ray: Ray): SmartArray<T>;
  106478. /**
  106479. * Adds a mesh into the octree block if it intersects the block
  106480. */
  106481. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106482. /**
  106483. * Adds a submesh into the octree block if it intersects the block
  106484. */
  106485. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106486. }
  106487. }
  106488. declare module BABYLON {
  106489. interface Scene {
  106490. /**
  106491. * @hidden
  106492. * Backing Filed
  106493. */
  106494. _selectionOctree: Octree<AbstractMesh>;
  106495. /**
  106496. * Gets the octree used to boost mesh selection (picking)
  106497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106498. */
  106499. selectionOctree: Octree<AbstractMesh>;
  106500. /**
  106501. * Creates or updates the octree used to boost selection (picking)
  106502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106503. * @param maxCapacity defines the maximum capacity per leaf
  106504. * @param maxDepth defines the maximum depth of the octree
  106505. * @returns an octree of AbstractMesh
  106506. */
  106507. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106508. }
  106509. interface AbstractMesh {
  106510. /**
  106511. * @hidden
  106512. * Backing Field
  106513. */
  106514. _submeshesOctree: Octree<SubMesh>;
  106515. /**
  106516. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106517. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106518. * @param maxCapacity defines the maximum size of each block (64 by default)
  106519. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106520. * @returns the new octree
  106521. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106523. */
  106524. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106525. }
  106526. /**
  106527. * Defines the octree scene component responsible to manage any octrees
  106528. * in a given scene.
  106529. */
  106530. export class OctreeSceneComponent {
  106531. /**
  106532. * The component name help to identify the component in the list of scene components.
  106533. */
  106534. readonly name: string;
  106535. /**
  106536. * The scene the component belongs to.
  106537. */
  106538. scene: Scene;
  106539. /**
  106540. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106541. */
  106542. readonly checksIsEnabled: boolean;
  106543. /**
  106544. * Creates a new instance of the component for the given scene
  106545. * @param scene Defines the scene to register the component in
  106546. */
  106547. constructor(scene: Scene);
  106548. /**
  106549. * Registers the component in a given scene
  106550. */
  106551. register(): void;
  106552. /**
  106553. * Return the list of active meshes
  106554. * @returns the list of active meshes
  106555. */
  106556. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106557. /**
  106558. * Return the list of active sub meshes
  106559. * @param mesh The mesh to get the candidates sub meshes from
  106560. * @returns the list of active sub meshes
  106561. */
  106562. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106563. private _tempRay;
  106564. /**
  106565. * Return the list of sub meshes intersecting with a given local ray
  106566. * @param mesh defines the mesh to find the submesh for
  106567. * @param localRay defines the ray in local space
  106568. * @returns the list of intersecting sub meshes
  106569. */
  106570. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106571. /**
  106572. * Return the list of sub meshes colliding with a collider
  106573. * @param mesh defines the mesh to find the submesh for
  106574. * @param collider defines the collider to evaluate the collision against
  106575. * @returns the list of colliding sub meshes
  106576. */
  106577. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106578. /**
  106579. * Rebuilds the elements related to this component in case of
  106580. * context lost for instance.
  106581. */
  106582. rebuild(): void;
  106583. /**
  106584. * Disposes the component and the associated ressources.
  106585. */
  106586. dispose(): void;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * Renders a layer on top of an existing scene
  106592. */
  106593. export class UtilityLayerRenderer implements IDisposable {
  106594. /** the original scene that will be rendered on top of */
  106595. originalScene: Scene;
  106596. private _pointerCaptures;
  106597. private _lastPointerEvents;
  106598. private static _DefaultUtilityLayer;
  106599. private static _DefaultKeepDepthUtilityLayer;
  106600. private _sharedGizmoLight;
  106601. private _renderCamera;
  106602. /**
  106603. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106604. * @returns the camera that is used when rendering the utility layer
  106605. */
  106606. getRenderCamera(): Nullable<Camera>;
  106607. /**
  106608. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106609. * @param cam the camera that should be used when rendering the utility layer
  106610. */
  106611. setRenderCamera(cam: Nullable<Camera>): void;
  106612. /**
  106613. * @hidden
  106614. * Light which used by gizmos to get light shading
  106615. */
  106616. _getSharedGizmoLight(): HemisphericLight;
  106617. /**
  106618. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106619. */
  106620. pickUtilitySceneFirst: boolean;
  106621. /**
  106622. * 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)
  106623. */
  106624. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106625. /**
  106626. * 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)
  106627. */
  106628. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106629. /**
  106630. * The scene that is rendered on top of the original scene
  106631. */
  106632. utilityLayerScene: Scene;
  106633. /**
  106634. * If the utility layer should automatically be rendered on top of existing scene
  106635. */
  106636. shouldRender: boolean;
  106637. /**
  106638. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106639. */
  106640. onlyCheckPointerDownEvents: boolean;
  106641. /**
  106642. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106643. */
  106644. processAllEvents: boolean;
  106645. /**
  106646. * Observable raised when the pointer move from the utility layer scene to the main scene
  106647. */
  106648. onPointerOutObservable: Observable<number>;
  106649. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106650. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106651. private _afterRenderObserver;
  106652. private _sceneDisposeObserver;
  106653. private _originalPointerObserver;
  106654. /**
  106655. * Instantiates a UtilityLayerRenderer
  106656. * @param originalScene the original scene that will be rendered on top of
  106657. * @param handleEvents boolean indicating if the utility layer should handle events
  106658. */
  106659. constructor(
  106660. /** the original scene that will be rendered on top of */
  106661. originalScene: Scene, handleEvents?: boolean);
  106662. private _notifyObservers;
  106663. /**
  106664. * Renders the utility layers scene on top of the original scene
  106665. */
  106666. render(): void;
  106667. /**
  106668. * Disposes of the renderer
  106669. */
  106670. dispose(): void;
  106671. private _updateCamera;
  106672. }
  106673. }
  106674. declare module BABYLON {
  106675. /**
  106676. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106677. */
  106678. export class Gizmo implements IDisposable {
  106679. /** The utility layer the gizmo will be added to */
  106680. gizmoLayer: UtilityLayerRenderer;
  106681. /**
  106682. * The root mesh of the gizmo
  106683. */
  106684. _rootMesh: Mesh;
  106685. private _attachedMesh;
  106686. /**
  106687. * Ratio for the scale of the gizmo (Default: 1)
  106688. */
  106689. scaleRatio: number;
  106690. /**
  106691. * If a custom mesh has been set (Default: false)
  106692. */
  106693. protected _customMeshSet: boolean;
  106694. /**
  106695. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106696. * * When set, interactions will be enabled
  106697. */
  106698. attachedMesh: Nullable<AbstractMesh>;
  106699. /**
  106700. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106701. * @param mesh The mesh to replace the default mesh of the gizmo
  106702. */
  106703. setCustomMesh(mesh: Mesh): void;
  106704. /**
  106705. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106706. */
  106707. updateGizmoRotationToMatchAttachedMesh: boolean;
  106708. /**
  106709. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106710. */
  106711. updateGizmoPositionToMatchAttachedMesh: boolean;
  106712. /**
  106713. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106714. */
  106715. updateScale: boolean;
  106716. protected _interactionsEnabled: boolean;
  106717. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106718. private _beforeRenderObserver;
  106719. private _tempVector;
  106720. /**
  106721. * Creates a gizmo
  106722. * @param gizmoLayer The utility layer the gizmo will be added to
  106723. */
  106724. constructor(
  106725. /** The utility layer the gizmo will be added to */
  106726. gizmoLayer?: UtilityLayerRenderer);
  106727. /**
  106728. * Updates the gizmo to match the attached mesh's position/rotation
  106729. */
  106730. protected _update(): void;
  106731. /**
  106732. * Disposes of the gizmo
  106733. */
  106734. dispose(): void;
  106735. }
  106736. }
  106737. declare module BABYLON {
  106738. /**
  106739. * Single plane drag gizmo
  106740. */
  106741. export class PlaneDragGizmo extends Gizmo {
  106742. /**
  106743. * Drag behavior responsible for the gizmos dragging interactions
  106744. */
  106745. dragBehavior: PointerDragBehavior;
  106746. private _pointerObserver;
  106747. /**
  106748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106749. */
  106750. snapDistance: number;
  106751. /**
  106752. * Event that fires each time the gizmo snaps to a new location.
  106753. * * snapDistance is the the change in distance
  106754. */
  106755. onSnapObservable: Observable<{
  106756. snapDistance: number;
  106757. }>;
  106758. private _plane;
  106759. private _coloredMaterial;
  106760. private _hoverMaterial;
  106761. private _isEnabled;
  106762. private _parent;
  106763. /** @hidden */
  106764. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106765. /** @hidden */
  106766. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106767. /**
  106768. * Creates a PlaneDragGizmo
  106769. * @param gizmoLayer The utility layer the gizmo will be added to
  106770. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106771. * @param color The color of the gizmo
  106772. */
  106773. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106774. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106775. /**
  106776. * If the gizmo is enabled
  106777. */
  106778. isEnabled: boolean;
  106779. /**
  106780. * Disposes of the gizmo
  106781. */
  106782. dispose(): void;
  106783. }
  106784. }
  106785. declare module BABYLON {
  106786. /**
  106787. * Gizmo that enables dragging a mesh along 3 axis
  106788. */
  106789. export class PositionGizmo extends Gizmo {
  106790. /**
  106791. * Internal gizmo used for interactions on the x axis
  106792. */
  106793. xGizmo: AxisDragGizmo;
  106794. /**
  106795. * Internal gizmo used for interactions on the y axis
  106796. */
  106797. yGizmo: AxisDragGizmo;
  106798. /**
  106799. * Internal gizmo used for interactions on the z axis
  106800. */
  106801. zGizmo: AxisDragGizmo;
  106802. /**
  106803. * Internal gizmo used for interactions on the yz plane
  106804. */
  106805. xPlaneGizmo: PlaneDragGizmo;
  106806. /**
  106807. * Internal gizmo used for interactions on the xz plane
  106808. */
  106809. yPlaneGizmo: PlaneDragGizmo;
  106810. /**
  106811. * Internal gizmo used for interactions on the xy plane
  106812. */
  106813. zPlaneGizmo: PlaneDragGizmo;
  106814. /**
  106815. * private variables
  106816. */
  106817. private _meshAttached;
  106818. private _updateGizmoRotationToMatchAttachedMesh;
  106819. private _snapDistance;
  106820. private _scaleRatio;
  106821. /** Fires an event when any of it's sub gizmos are dragged */
  106822. onDragStartObservable: Observable<unknown>;
  106823. /** Fires an event when any of it's sub gizmos are released from dragging */
  106824. onDragEndObservable: Observable<unknown>;
  106825. /**
  106826. * If set to true, planar drag is enabled
  106827. */
  106828. private _planarGizmoEnabled;
  106829. attachedMesh: Nullable<AbstractMesh>;
  106830. /**
  106831. * Creates a PositionGizmo
  106832. * @param gizmoLayer The utility layer the gizmo will be added to
  106833. */
  106834. constructor(gizmoLayer?: UtilityLayerRenderer);
  106835. /**
  106836. * If the planar drag gizmo is enabled
  106837. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106838. */
  106839. planarGizmoEnabled: boolean;
  106840. updateGizmoRotationToMatchAttachedMesh: boolean;
  106841. /**
  106842. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106843. */
  106844. snapDistance: number;
  106845. /**
  106846. * Ratio for the scale of the gizmo (Default: 1)
  106847. */
  106848. scaleRatio: number;
  106849. /**
  106850. * Disposes of the gizmo
  106851. */
  106852. dispose(): void;
  106853. /**
  106854. * CustomMeshes are not supported by this gizmo
  106855. * @param mesh The mesh to replace the default mesh of the gizmo
  106856. */
  106857. setCustomMesh(mesh: Mesh): void;
  106858. }
  106859. }
  106860. declare module BABYLON {
  106861. /**
  106862. * Single axis drag gizmo
  106863. */
  106864. export class AxisDragGizmo extends Gizmo {
  106865. /**
  106866. * Drag behavior responsible for the gizmos dragging interactions
  106867. */
  106868. dragBehavior: PointerDragBehavior;
  106869. private _pointerObserver;
  106870. /**
  106871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106872. */
  106873. snapDistance: number;
  106874. /**
  106875. * Event that fires each time the gizmo snaps to a new location.
  106876. * * snapDistance is the the change in distance
  106877. */
  106878. onSnapObservable: Observable<{
  106879. snapDistance: number;
  106880. }>;
  106881. private _isEnabled;
  106882. private _parent;
  106883. private _arrow;
  106884. private _coloredMaterial;
  106885. private _hoverMaterial;
  106886. /** @hidden */
  106887. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106888. /** @hidden */
  106889. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106890. /**
  106891. * Creates an AxisDragGizmo
  106892. * @param gizmoLayer The utility layer the gizmo will be added to
  106893. * @param dragAxis The axis which the gizmo will be able to drag on
  106894. * @param color The color of the gizmo
  106895. */
  106896. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106897. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106898. /**
  106899. * If the gizmo is enabled
  106900. */
  106901. isEnabled: boolean;
  106902. /**
  106903. * Disposes of the gizmo
  106904. */
  106905. dispose(): void;
  106906. }
  106907. }
  106908. declare module BABYLON.Debug {
  106909. /**
  106910. * The Axes viewer will show 3 axes in a specific point in space
  106911. */
  106912. export class AxesViewer {
  106913. private _xAxis;
  106914. private _yAxis;
  106915. private _zAxis;
  106916. private _scaleLinesFactor;
  106917. private _instanced;
  106918. /**
  106919. * Gets the hosting scene
  106920. */
  106921. scene: Scene;
  106922. /**
  106923. * Gets or sets a number used to scale line length
  106924. */
  106925. scaleLines: number;
  106926. /** Gets the node hierarchy used to render x-axis */
  106927. readonly xAxis: TransformNode;
  106928. /** Gets the node hierarchy used to render y-axis */
  106929. readonly yAxis: TransformNode;
  106930. /** Gets the node hierarchy used to render z-axis */
  106931. readonly zAxis: TransformNode;
  106932. /**
  106933. * Creates a new AxesViewer
  106934. * @param scene defines the hosting scene
  106935. * @param scaleLines defines a number used to scale line length (1 by default)
  106936. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106937. * @param xAxis defines the node hierarchy used to render the x-axis
  106938. * @param yAxis defines the node hierarchy used to render the y-axis
  106939. * @param zAxis defines the node hierarchy used to render the z-axis
  106940. */
  106941. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106942. /**
  106943. * Force the viewer to update
  106944. * @param position defines the position of the viewer
  106945. * @param xaxis defines the x axis of the viewer
  106946. * @param yaxis defines the y axis of the viewer
  106947. * @param zaxis defines the z axis of the viewer
  106948. */
  106949. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106950. /**
  106951. * Creates an instance of this axes viewer.
  106952. * @returns a new axes viewer with instanced meshes
  106953. */
  106954. createInstance(): AxesViewer;
  106955. /** Releases resources */
  106956. dispose(): void;
  106957. private static _SetRenderingGroupId;
  106958. }
  106959. }
  106960. declare module BABYLON.Debug {
  106961. /**
  106962. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106963. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106964. */
  106965. export class BoneAxesViewer extends AxesViewer {
  106966. /**
  106967. * Gets or sets the target mesh where to display the axes viewer
  106968. */
  106969. mesh: Nullable<Mesh>;
  106970. /**
  106971. * Gets or sets the target bone where to display the axes viewer
  106972. */
  106973. bone: Nullable<Bone>;
  106974. /** Gets current position */
  106975. pos: Vector3;
  106976. /** Gets direction of X axis */
  106977. xaxis: Vector3;
  106978. /** Gets direction of Y axis */
  106979. yaxis: Vector3;
  106980. /** Gets direction of Z axis */
  106981. zaxis: Vector3;
  106982. /**
  106983. * Creates a new BoneAxesViewer
  106984. * @param scene defines the hosting scene
  106985. * @param bone defines the target bone
  106986. * @param mesh defines the target mesh
  106987. * @param scaleLines defines a scaling factor for line length (1 by default)
  106988. */
  106989. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106990. /**
  106991. * Force the viewer to update
  106992. */
  106993. update(): void;
  106994. /** Releases resources */
  106995. dispose(): void;
  106996. }
  106997. }
  106998. declare module BABYLON {
  106999. /**
  107000. * Interface used to define scene explorer extensibility option
  107001. */
  107002. export interface IExplorerExtensibilityOption {
  107003. /**
  107004. * Define the option label
  107005. */
  107006. label: string;
  107007. /**
  107008. * Defines the action to execute on click
  107009. */
  107010. action: (entity: any) => void;
  107011. }
  107012. /**
  107013. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107014. */
  107015. export interface IExplorerExtensibilityGroup {
  107016. /**
  107017. * Defines a predicate to test if a given type mut be extended
  107018. */
  107019. predicate: (entity: any) => boolean;
  107020. /**
  107021. * Gets the list of options added to a type
  107022. */
  107023. entries: IExplorerExtensibilityOption[];
  107024. }
  107025. /**
  107026. * Interface used to define the options to use to create the Inspector
  107027. */
  107028. export interface IInspectorOptions {
  107029. /**
  107030. * Display in overlay mode (default: false)
  107031. */
  107032. overlay?: boolean;
  107033. /**
  107034. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107035. */
  107036. globalRoot?: HTMLElement;
  107037. /**
  107038. * Display the Scene explorer
  107039. */
  107040. showExplorer?: boolean;
  107041. /**
  107042. * Display the property inspector
  107043. */
  107044. showInspector?: boolean;
  107045. /**
  107046. * Display in embed mode (both panes on the right)
  107047. */
  107048. embedMode?: boolean;
  107049. /**
  107050. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107051. */
  107052. handleResize?: boolean;
  107053. /**
  107054. * Allow the panes to popup (default: true)
  107055. */
  107056. enablePopup?: boolean;
  107057. /**
  107058. * Allow the panes to be closed by users (default: true)
  107059. */
  107060. enableClose?: boolean;
  107061. /**
  107062. * Optional list of extensibility entries
  107063. */
  107064. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107065. /**
  107066. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107067. */
  107068. inspectorURL?: string;
  107069. }
  107070. interface Scene {
  107071. /**
  107072. * @hidden
  107073. * Backing field
  107074. */
  107075. _debugLayer: DebugLayer;
  107076. /**
  107077. * Gets the debug layer (aka Inspector) associated with the scene
  107078. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107079. */
  107080. debugLayer: DebugLayer;
  107081. }
  107082. /**
  107083. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107084. * what is happening in your scene
  107085. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107086. */
  107087. export class DebugLayer {
  107088. /**
  107089. * Define the url to get the inspector script from.
  107090. * By default it uses the babylonjs CDN.
  107091. * @ignoreNaming
  107092. */
  107093. static InspectorURL: string;
  107094. private _scene;
  107095. private BJSINSPECTOR;
  107096. private _onPropertyChangedObservable?;
  107097. /**
  107098. * Observable triggered when a property is changed through the inspector.
  107099. */
  107100. readonly onPropertyChangedObservable: any;
  107101. /**
  107102. * Instantiates a new debug layer.
  107103. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107104. * what is happening in your scene
  107105. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107106. * @param scene Defines the scene to inspect
  107107. */
  107108. constructor(scene: Scene);
  107109. /** Creates the inspector window. */
  107110. private _createInspector;
  107111. /**
  107112. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107113. * @param entity defines the entity to select
  107114. * @param lineContainerTitle defines the specific block to highlight
  107115. */
  107116. select(entity: any, lineContainerTitle?: string): void;
  107117. /** Get the inspector from bundle or global */
  107118. private _getGlobalInspector;
  107119. /**
  107120. * Get if the inspector is visible or not.
  107121. * @returns true if visible otherwise, false
  107122. */
  107123. isVisible(): boolean;
  107124. /**
  107125. * Hide the inspector and close its window.
  107126. */
  107127. hide(): void;
  107128. /**
  107129. * Launch the debugLayer.
  107130. * @param config Define the configuration of the inspector
  107131. * @return a promise fulfilled when the debug layer is visible
  107132. */
  107133. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107134. }
  107135. }
  107136. declare module BABYLON {
  107137. /**
  107138. * Class containing static functions to help procedurally build meshes
  107139. */
  107140. export class BoxBuilder {
  107141. /**
  107142. * Creates a box mesh
  107143. * * The parameter `size` sets the size (float) of each box side (default 1)
  107144. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107145. * * 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)
  107146. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107150. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107151. * @param name defines the name of the mesh
  107152. * @param options defines the options used to create the mesh
  107153. * @param scene defines the hosting scene
  107154. * @returns the box mesh
  107155. */
  107156. static CreateBox(name: string, options: {
  107157. size?: number;
  107158. width?: number;
  107159. height?: number;
  107160. depth?: number;
  107161. faceUV?: Vector4[];
  107162. faceColors?: Color4[];
  107163. sideOrientation?: number;
  107164. frontUVs?: Vector4;
  107165. backUVs?: Vector4;
  107166. wrap?: boolean;
  107167. topBaseAt?: number;
  107168. bottomBaseAt?: number;
  107169. updatable?: boolean;
  107170. }, scene?: Nullable<Scene>): Mesh;
  107171. }
  107172. }
  107173. declare module BABYLON {
  107174. /**
  107175. * Class containing static functions to help procedurally build meshes
  107176. */
  107177. export class SphereBuilder {
  107178. /**
  107179. * Creates a sphere mesh
  107180. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107181. * * 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`)
  107182. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107183. * * 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
  107184. * * 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)
  107185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107188. * @param name defines the name of the mesh
  107189. * @param options defines the options used to create the mesh
  107190. * @param scene defines the hosting scene
  107191. * @returns the sphere mesh
  107192. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107193. */
  107194. static CreateSphere(name: string, options: {
  107195. segments?: number;
  107196. diameter?: number;
  107197. diameterX?: number;
  107198. diameterY?: number;
  107199. diameterZ?: number;
  107200. arc?: number;
  107201. slice?: number;
  107202. sideOrientation?: number;
  107203. frontUVs?: Vector4;
  107204. backUVs?: Vector4;
  107205. updatable?: boolean;
  107206. }, scene: any): Mesh;
  107207. }
  107208. }
  107209. declare module BABYLON.Debug {
  107210. /**
  107211. * Used to show the physics impostor around the specific mesh
  107212. */
  107213. export class PhysicsViewer {
  107214. /** @hidden */
  107215. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107216. /** @hidden */
  107217. protected _meshes: Array<Nullable<AbstractMesh>>;
  107218. /** @hidden */
  107219. protected _scene: Nullable<Scene>;
  107220. /** @hidden */
  107221. protected _numMeshes: number;
  107222. /** @hidden */
  107223. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107224. private _renderFunction;
  107225. private _utilityLayer;
  107226. private _debugBoxMesh;
  107227. private _debugSphereMesh;
  107228. private _debugCylinderMesh;
  107229. private _debugMaterial;
  107230. private _debugMeshMeshes;
  107231. /**
  107232. * Creates a new PhysicsViewer
  107233. * @param scene defines the hosting scene
  107234. */
  107235. constructor(scene: Scene);
  107236. /** @hidden */
  107237. protected _updateDebugMeshes(): void;
  107238. /**
  107239. * Renders a specified physic impostor
  107240. * @param impostor defines the impostor to render
  107241. * @param targetMesh defines the mesh represented by the impostor
  107242. * @returns the new debug mesh used to render the impostor
  107243. */
  107244. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107245. /**
  107246. * Hides a specified physic impostor
  107247. * @param impostor defines the impostor to hide
  107248. */
  107249. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107250. private _getDebugMaterial;
  107251. private _getDebugBoxMesh;
  107252. private _getDebugSphereMesh;
  107253. private _getDebugCylinderMesh;
  107254. private _getDebugMeshMesh;
  107255. private _getDebugMesh;
  107256. /** Releases all resources */
  107257. dispose(): void;
  107258. }
  107259. }
  107260. declare module BABYLON {
  107261. /**
  107262. * Class containing static functions to help procedurally build meshes
  107263. */
  107264. export class LinesBuilder {
  107265. /**
  107266. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107267. * * 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
  107268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107269. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107270. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107271. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107273. * * 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
  107274. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107277. * @param name defines the name of the new line system
  107278. * @param options defines the options used to create the line system
  107279. * @param scene defines the hosting scene
  107280. * @returns a new line system mesh
  107281. */
  107282. static CreateLineSystem(name: string, options: {
  107283. lines: Vector3[][];
  107284. updatable?: boolean;
  107285. instance?: Nullable<LinesMesh>;
  107286. colors?: Nullable<Color4[][]>;
  107287. useVertexAlpha?: boolean;
  107288. }, scene: Nullable<Scene>): LinesMesh;
  107289. /**
  107290. * Creates a line mesh
  107291. * 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
  107292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107293. * * The parameter `points` is an array successive Vector3
  107294. * * 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
  107295. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107297. * * When updating an instance, remember that only point positions can change, not the number of points
  107298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107300. * @param name defines the name of the new line system
  107301. * @param options defines the options used to create the line system
  107302. * @param scene defines the hosting scene
  107303. * @returns a new line mesh
  107304. */
  107305. static CreateLines(name: string, options: {
  107306. points: Vector3[];
  107307. updatable?: boolean;
  107308. instance?: Nullable<LinesMesh>;
  107309. colors?: Color4[];
  107310. useVertexAlpha?: boolean;
  107311. }, scene?: Nullable<Scene>): LinesMesh;
  107312. /**
  107313. * Creates a dashed line mesh
  107314. * * 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
  107315. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107316. * * The parameter `points` is an array successive Vector3
  107317. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107318. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107319. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107320. * * 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
  107321. * * When updating an instance, remember that only point positions can change, not the number of points
  107322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107323. * @param name defines the name of the mesh
  107324. * @param options defines the options used to create the mesh
  107325. * @param scene defines the hosting scene
  107326. * @returns the dashed line mesh
  107327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107328. */
  107329. static CreateDashedLines(name: string, options: {
  107330. points: Vector3[];
  107331. dashSize?: number;
  107332. gapSize?: number;
  107333. dashNb?: number;
  107334. updatable?: boolean;
  107335. instance?: LinesMesh;
  107336. }, scene?: Nullable<Scene>): LinesMesh;
  107337. }
  107338. }
  107339. declare module BABYLON {
  107340. /**
  107341. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107342. * in order to better appreciate the issue one might have.
  107343. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107344. */
  107345. export class RayHelper {
  107346. /**
  107347. * Defines the ray we are currently tryin to visualize.
  107348. */
  107349. ray: Nullable<Ray>;
  107350. private _renderPoints;
  107351. private _renderLine;
  107352. private _renderFunction;
  107353. private _scene;
  107354. private _updateToMeshFunction;
  107355. private _attachedToMesh;
  107356. private _meshSpaceDirection;
  107357. private _meshSpaceOrigin;
  107358. /**
  107359. * Helper function to create a colored helper in a scene in one line.
  107360. * @param ray Defines the ray we are currently tryin to visualize
  107361. * @param scene Defines the scene the ray is used in
  107362. * @param color Defines the color we want to see the ray in
  107363. * @returns The newly created ray helper.
  107364. */
  107365. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107366. /**
  107367. * Instantiate a new ray helper.
  107368. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107369. * in order to better appreciate the issue one might have.
  107370. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107371. * @param ray Defines the ray we are currently tryin to visualize
  107372. */
  107373. constructor(ray: Ray);
  107374. /**
  107375. * Shows the ray we are willing to debug.
  107376. * @param scene Defines the scene the ray needs to be rendered in
  107377. * @param color Defines the color the ray needs to be rendered in
  107378. */
  107379. show(scene: Scene, color?: Color3): void;
  107380. /**
  107381. * Hides the ray we are debugging.
  107382. */
  107383. hide(): void;
  107384. private _render;
  107385. /**
  107386. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107387. * @param mesh Defines the mesh we want the helper attached to
  107388. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107389. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107390. * @param length Defines the length of the ray
  107391. */
  107392. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107393. /**
  107394. * Detach the ray helper from the mesh it has previously been attached to.
  107395. */
  107396. detachFromMesh(): void;
  107397. private _updateToMesh;
  107398. /**
  107399. * Dispose the helper and release its associated resources.
  107400. */
  107401. dispose(): void;
  107402. }
  107403. }
  107404. declare module BABYLON.Debug {
  107405. /**
  107406. * Class used to render a debug view of a given skeleton
  107407. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107408. */
  107409. export class SkeletonViewer {
  107410. /** defines the skeleton to render */
  107411. skeleton: Skeleton;
  107412. /** defines the mesh attached to the skeleton */
  107413. mesh: AbstractMesh;
  107414. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107415. autoUpdateBonesMatrices: boolean;
  107416. /** defines the rendering group id to use with the viewer */
  107417. renderingGroupId: number;
  107418. /** Gets or sets the color used to render the skeleton */
  107419. color: Color3;
  107420. private _scene;
  107421. private _debugLines;
  107422. private _debugMesh;
  107423. private _isEnabled;
  107424. private _renderFunction;
  107425. private _utilityLayer;
  107426. /**
  107427. * Returns the mesh used to render the bones
  107428. */
  107429. readonly debugMesh: Nullable<LinesMesh>;
  107430. /**
  107431. * Creates a new SkeletonViewer
  107432. * @param skeleton defines the skeleton to render
  107433. * @param mesh defines the mesh attached to the skeleton
  107434. * @param scene defines the hosting scene
  107435. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107436. * @param renderingGroupId defines the rendering group id to use with the viewer
  107437. */
  107438. constructor(
  107439. /** defines the skeleton to render */
  107440. skeleton: Skeleton,
  107441. /** defines the mesh attached to the skeleton */
  107442. mesh: AbstractMesh, scene: Scene,
  107443. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107444. autoUpdateBonesMatrices?: boolean,
  107445. /** defines the rendering group id to use with the viewer */
  107446. renderingGroupId?: number);
  107447. /** Gets or sets a boolean indicating if the viewer is enabled */
  107448. isEnabled: boolean;
  107449. private _getBonePosition;
  107450. private _getLinesForBonesWithLength;
  107451. private _getLinesForBonesNoLength;
  107452. /** Update the viewer to sync with current skeleton state */
  107453. update(): void;
  107454. /** Release associated resources */
  107455. dispose(): void;
  107456. }
  107457. }
  107458. declare module BABYLON {
  107459. /**
  107460. * Options to create the null engine
  107461. */
  107462. export class NullEngineOptions {
  107463. /**
  107464. * Render width (Default: 512)
  107465. */
  107466. renderWidth: number;
  107467. /**
  107468. * Render height (Default: 256)
  107469. */
  107470. renderHeight: number;
  107471. /**
  107472. * Texture size (Default: 512)
  107473. */
  107474. textureSize: number;
  107475. /**
  107476. * If delta time between frames should be constant
  107477. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107478. */
  107479. deterministicLockstep: boolean;
  107480. /**
  107481. * Maximum about of steps between frames (Default: 4)
  107482. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107483. */
  107484. lockstepMaxSteps: number;
  107485. }
  107486. /**
  107487. * The null engine class provides support for headless version of babylon.js.
  107488. * This can be used in server side scenario or for testing purposes
  107489. */
  107490. export class NullEngine extends Engine {
  107491. private _options;
  107492. /**
  107493. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107494. */
  107495. isDeterministicLockStep(): boolean;
  107496. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107497. getLockstepMaxSteps(): number;
  107498. /**
  107499. * Sets hardware scaling, used to save performance if needed
  107500. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107501. */
  107502. getHardwareScalingLevel(): number;
  107503. constructor(options?: NullEngineOptions);
  107504. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107505. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107506. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107507. getRenderWidth(useScreen?: boolean): number;
  107508. getRenderHeight(useScreen?: boolean): number;
  107509. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107510. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107511. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107512. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107513. bindSamplers(effect: Effect): void;
  107514. enableEffect(effect: Effect): void;
  107515. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107516. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107517. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107518. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107519. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107520. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107521. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107522. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107523. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107524. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107525. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107526. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107527. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107528. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107529. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107530. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107531. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107532. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107533. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107534. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107535. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107536. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107537. bindBuffers(vertexBuffers: {
  107538. [key: string]: VertexBuffer;
  107539. }, indexBuffer: DataBuffer, effect: Effect): void;
  107540. wipeCaches(bruteForce?: boolean): void;
  107541. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107542. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107543. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107544. /** @hidden */
  107545. _createTexture(): WebGLTexture;
  107546. /** @hidden */
  107547. _releaseTexture(texture: InternalTexture): void;
  107548. 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;
  107549. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107550. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107551. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107552. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107553. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107554. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107555. areAllEffectsReady(): boolean;
  107556. /**
  107557. * @hidden
  107558. * Get the current error code of the webGL context
  107559. * @returns the error code
  107560. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107561. */
  107562. getError(): number;
  107563. /** @hidden */
  107564. _getUnpackAlignement(): number;
  107565. /** @hidden */
  107566. _unpackFlipY(value: boolean): void;
  107567. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107568. /**
  107569. * Updates a dynamic vertex buffer.
  107570. * @param vertexBuffer the vertex buffer to update
  107571. * @param data the data used to update the vertex buffer
  107572. * @param byteOffset the byte offset of the data (optional)
  107573. * @param byteLength the byte length of the data (optional)
  107574. */
  107575. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107576. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107577. /** @hidden */
  107578. _bindTexture(channel: number, texture: InternalTexture): void;
  107579. /** @hidden */
  107580. _releaseBuffer(buffer: DataBuffer): boolean;
  107581. releaseEffects(): void;
  107582. displayLoadingUI(): void;
  107583. hideLoadingUI(): void;
  107584. /** @hidden */
  107585. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107586. /** @hidden */
  107587. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107588. /** @hidden */
  107589. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107590. /** @hidden */
  107591. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107592. }
  107593. }
  107594. declare module BABYLON {
  107595. /** @hidden */
  107596. export class _OcclusionDataStorage {
  107597. /** @hidden */
  107598. occlusionInternalRetryCounter: number;
  107599. /** @hidden */
  107600. isOcclusionQueryInProgress: boolean;
  107601. /** @hidden */
  107602. isOccluded: boolean;
  107603. /** @hidden */
  107604. occlusionRetryCount: number;
  107605. /** @hidden */
  107606. occlusionType: number;
  107607. /** @hidden */
  107608. occlusionQueryAlgorithmType: number;
  107609. }
  107610. interface Engine {
  107611. /**
  107612. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107613. * @return the new query
  107614. */
  107615. createQuery(): WebGLQuery;
  107616. /**
  107617. * Delete and release a webGL query
  107618. * @param query defines the query to delete
  107619. * @return the current engine
  107620. */
  107621. deleteQuery(query: WebGLQuery): Engine;
  107622. /**
  107623. * Check if a given query has resolved and got its value
  107624. * @param query defines the query to check
  107625. * @returns true if the query got its value
  107626. */
  107627. isQueryResultAvailable(query: WebGLQuery): boolean;
  107628. /**
  107629. * Gets the value of a given query
  107630. * @param query defines the query to check
  107631. * @returns the value of the query
  107632. */
  107633. getQueryResult(query: WebGLQuery): number;
  107634. /**
  107635. * Initiates an occlusion query
  107636. * @param algorithmType defines the algorithm to use
  107637. * @param query defines the query to use
  107638. * @returns the current engine
  107639. * @see http://doc.babylonjs.com/features/occlusionquery
  107640. */
  107641. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107642. /**
  107643. * Ends an occlusion query
  107644. * @see http://doc.babylonjs.com/features/occlusionquery
  107645. * @param algorithmType defines the algorithm to use
  107646. * @returns the current engine
  107647. */
  107648. endOcclusionQuery(algorithmType: number): Engine;
  107649. /**
  107650. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107651. * Please note that only one query can be issued at a time
  107652. * @returns a time token used to track the time span
  107653. */
  107654. startTimeQuery(): Nullable<_TimeToken>;
  107655. /**
  107656. * Ends a time query
  107657. * @param token defines the token used to measure the time span
  107658. * @returns the time spent (in ns)
  107659. */
  107660. endTimeQuery(token: _TimeToken): int;
  107661. /** @hidden */
  107662. _currentNonTimestampToken: Nullable<_TimeToken>;
  107663. /** @hidden */
  107664. _createTimeQuery(): WebGLQuery;
  107665. /** @hidden */
  107666. _deleteTimeQuery(query: WebGLQuery): void;
  107667. /** @hidden */
  107668. _getGlAlgorithmType(algorithmType: number): number;
  107669. /** @hidden */
  107670. _getTimeQueryResult(query: WebGLQuery): any;
  107671. /** @hidden */
  107672. _getTimeQueryAvailability(query: WebGLQuery): any;
  107673. }
  107674. interface AbstractMesh {
  107675. /**
  107676. * Backing filed
  107677. * @hidden
  107678. */
  107679. __occlusionDataStorage: _OcclusionDataStorage;
  107680. /**
  107681. * Access property
  107682. * @hidden
  107683. */
  107684. _occlusionDataStorage: _OcclusionDataStorage;
  107685. /**
  107686. * 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.
  107687. * The default value is -1 which means don't break the query and wait till the result
  107688. * @see http://doc.babylonjs.com/features/occlusionquery
  107689. */
  107690. occlusionRetryCount: number;
  107691. /**
  107692. * 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:
  107693. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107694. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107695. * * 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.
  107696. * @see http://doc.babylonjs.com/features/occlusionquery
  107697. */
  107698. occlusionType: number;
  107699. /**
  107700. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107701. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107702. * * 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.
  107703. * @see http://doc.babylonjs.com/features/occlusionquery
  107704. */
  107705. occlusionQueryAlgorithmType: number;
  107706. /**
  107707. * 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
  107708. * @see http://doc.babylonjs.com/features/occlusionquery
  107709. */
  107710. isOccluded: boolean;
  107711. /**
  107712. * Flag to check the progress status of the query
  107713. * @see http://doc.babylonjs.com/features/occlusionquery
  107714. */
  107715. isOcclusionQueryInProgress: boolean;
  107716. }
  107717. }
  107718. declare module BABYLON {
  107719. /** @hidden */
  107720. export var _forceTransformFeedbackToBundle: boolean;
  107721. interface Engine {
  107722. /**
  107723. * Creates a webGL transform feedback object
  107724. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107725. * @returns the webGL transform feedback object
  107726. */
  107727. createTransformFeedback(): WebGLTransformFeedback;
  107728. /**
  107729. * Delete a webGL transform feedback object
  107730. * @param value defines the webGL transform feedback object to delete
  107731. */
  107732. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107733. /**
  107734. * Bind a webGL transform feedback object to the webgl context
  107735. * @param value defines the webGL transform feedback object to bind
  107736. */
  107737. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107738. /**
  107739. * Begins a transform feedback operation
  107740. * @param usePoints defines if points or triangles must be used
  107741. */
  107742. beginTransformFeedback(usePoints: boolean): void;
  107743. /**
  107744. * Ends a transform feedback operation
  107745. */
  107746. endTransformFeedback(): void;
  107747. /**
  107748. * Specify the varyings to use with transform feedback
  107749. * @param program defines the associated webGL program
  107750. * @param value defines the list of strings representing the varying names
  107751. */
  107752. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107753. /**
  107754. * Bind a webGL buffer for a transform feedback operation
  107755. * @param value defines the webGL buffer to bind
  107756. */
  107757. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /**
  107762. * Creation options of the multi render target texture.
  107763. */
  107764. export interface IMultiRenderTargetOptions {
  107765. /**
  107766. * Define if the texture needs to create mip maps after render.
  107767. */
  107768. generateMipMaps?: boolean;
  107769. /**
  107770. * Define the types of all the draw buffers we want to create
  107771. */
  107772. types?: number[];
  107773. /**
  107774. * Define the sampling modes of all the draw buffers we want to create
  107775. */
  107776. samplingModes?: number[];
  107777. /**
  107778. * Define if a depth buffer is required
  107779. */
  107780. generateDepthBuffer?: boolean;
  107781. /**
  107782. * Define if a stencil buffer is required
  107783. */
  107784. generateStencilBuffer?: boolean;
  107785. /**
  107786. * Define if a depth texture is required instead of a depth buffer
  107787. */
  107788. generateDepthTexture?: boolean;
  107789. /**
  107790. * Define the number of desired draw buffers
  107791. */
  107792. textureCount?: number;
  107793. /**
  107794. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107795. */
  107796. doNotChangeAspectRatio?: boolean;
  107797. /**
  107798. * Define the default type of the buffers we are creating
  107799. */
  107800. defaultType?: number;
  107801. }
  107802. /**
  107803. * A multi render target, like a render target provides the ability to render to a texture.
  107804. * Unlike the render target, it can render to several draw buffers in one draw.
  107805. * This is specially interesting in deferred rendering or for any effects requiring more than
  107806. * just one color from a single pass.
  107807. */
  107808. export class MultiRenderTarget extends RenderTargetTexture {
  107809. private _internalTextures;
  107810. private _textures;
  107811. private _multiRenderTargetOptions;
  107812. /**
  107813. * Get if draw buffers are currently supported by the used hardware and browser.
  107814. */
  107815. readonly isSupported: boolean;
  107816. /**
  107817. * Get the list of textures generated by the multi render target.
  107818. */
  107819. readonly textures: Texture[];
  107820. /**
  107821. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107822. */
  107823. readonly depthTexture: Texture;
  107824. /**
  107825. * Set the wrapping mode on U of all the textures we are rendering to.
  107826. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107827. */
  107828. wrapU: number;
  107829. /**
  107830. * Set the wrapping mode on V of all the textures we are rendering to.
  107831. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107832. */
  107833. wrapV: number;
  107834. /**
  107835. * Instantiate a new multi render target texture.
  107836. * A multi render target, like a render target provides the ability to render to a texture.
  107837. * Unlike the render target, it can render to several draw buffers in one draw.
  107838. * This is specially interesting in deferred rendering or for any effects requiring more than
  107839. * just one color from a single pass.
  107840. * @param name Define the name of the texture
  107841. * @param size Define the size of the buffers to render to
  107842. * @param count Define the number of target we are rendering into
  107843. * @param scene Define the scene the texture belongs to
  107844. * @param options Define the options used to create the multi render target
  107845. */
  107846. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107847. /** @hidden */
  107848. _rebuild(): void;
  107849. private _createInternalTextures;
  107850. private _createTextures;
  107851. /**
  107852. * Define the number of samples used if MSAA is enabled.
  107853. */
  107854. samples: number;
  107855. /**
  107856. * Resize all the textures in the multi render target.
  107857. * Be carrefull as it will recreate all the data in the new texture.
  107858. * @param size Define the new size
  107859. */
  107860. resize(size: any): void;
  107861. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107862. /**
  107863. * Dispose the render targets and their associated resources
  107864. */
  107865. dispose(): void;
  107866. /**
  107867. * Release all the underlying texture used as draw buffers.
  107868. */
  107869. releaseInternalTextures(): void;
  107870. }
  107871. }
  107872. declare module BABYLON {
  107873. interface Engine {
  107874. /**
  107875. * Unbind a list of render target textures from the webGL context
  107876. * This is used only when drawBuffer extension or webGL2 are active
  107877. * @param textures defines the render target textures to unbind
  107878. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107879. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107880. */
  107881. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107882. /**
  107883. * Create a multi render target texture
  107884. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107885. * @param size defines the size of the texture
  107886. * @param options defines the creation options
  107887. * @returns the cube texture as an InternalTexture
  107888. */
  107889. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107890. /**
  107891. * Update the sample count for a given multiple render target texture
  107892. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107893. * @param textures defines the textures to update
  107894. * @param samples defines the sample count to set
  107895. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107896. */
  107897. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107898. }
  107899. }
  107900. declare module BABYLON {
  107901. /**
  107902. * Gather the list of clipboard event types as constants.
  107903. */
  107904. export class ClipboardEventTypes {
  107905. /**
  107906. * The clipboard event is fired when a copy command is active (pressed).
  107907. */
  107908. static readonly COPY: number;
  107909. /**
  107910. * The clipboard event is fired when a cut command is active (pressed).
  107911. */
  107912. static readonly CUT: number;
  107913. /**
  107914. * The clipboard event is fired when a paste command is active (pressed).
  107915. */
  107916. static readonly PASTE: number;
  107917. }
  107918. /**
  107919. * This class is used to store clipboard related info for the onClipboardObservable event.
  107920. */
  107921. export class ClipboardInfo {
  107922. /**
  107923. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107924. */
  107925. type: number;
  107926. /**
  107927. * Defines the related dom event
  107928. */
  107929. event: ClipboardEvent;
  107930. /**
  107931. *Creates an instance of ClipboardInfo.
  107932. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107933. * @param event Defines the related dom event
  107934. */
  107935. constructor(
  107936. /**
  107937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107938. */
  107939. type: number,
  107940. /**
  107941. * Defines the related dom event
  107942. */
  107943. event: ClipboardEvent);
  107944. /**
  107945. * Get the clipboard event's type from the keycode.
  107946. * @param keyCode Defines the keyCode for the current keyboard event.
  107947. * @return {number}
  107948. */
  107949. static GetTypeFromCharacter(keyCode: number): number;
  107950. }
  107951. }
  107952. declare module BABYLON {
  107953. /**
  107954. * Google Daydream controller
  107955. */
  107956. export class DaydreamController extends WebVRController {
  107957. /**
  107958. * Base Url for the controller model.
  107959. */
  107960. static MODEL_BASE_URL: string;
  107961. /**
  107962. * File name for the controller model.
  107963. */
  107964. static MODEL_FILENAME: string;
  107965. /**
  107966. * Gamepad Id prefix used to identify Daydream Controller.
  107967. */
  107968. static readonly GAMEPAD_ID_PREFIX: string;
  107969. /**
  107970. * Creates a new DaydreamController from a gamepad
  107971. * @param vrGamepad the gamepad that the controller should be created from
  107972. */
  107973. constructor(vrGamepad: any);
  107974. /**
  107975. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107976. * @param scene scene in which to add meshes
  107977. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107978. */
  107979. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107980. /**
  107981. * Called once for each button that changed state since the last frame
  107982. * @param buttonIdx Which button index changed
  107983. * @param state New state of the button
  107984. * @param changes Which properties on the state changed since last frame
  107985. */
  107986. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107987. }
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * Gear VR Controller
  107992. */
  107993. export class GearVRController extends WebVRController {
  107994. /**
  107995. * Base Url for the controller model.
  107996. */
  107997. static MODEL_BASE_URL: string;
  107998. /**
  107999. * File name for the controller model.
  108000. */
  108001. static MODEL_FILENAME: string;
  108002. /**
  108003. * Gamepad Id prefix used to identify this controller.
  108004. */
  108005. static readonly GAMEPAD_ID_PREFIX: string;
  108006. private readonly _buttonIndexToObservableNameMap;
  108007. /**
  108008. * Creates a new GearVRController from a gamepad
  108009. * @param vrGamepad the gamepad that the controller should be created from
  108010. */
  108011. constructor(vrGamepad: any);
  108012. /**
  108013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108014. * @param scene scene in which to add meshes
  108015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108016. */
  108017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108018. /**
  108019. * Called once for each button that changed state since the last frame
  108020. * @param buttonIdx Which button index changed
  108021. * @param state New state of the button
  108022. * @param changes Which properties on the state changed since last frame
  108023. */
  108024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108025. }
  108026. }
  108027. declare module BABYLON {
  108028. /**
  108029. * Class containing static functions to help procedurally build meshes
  108030. */
  108031. export class PolyhedronBuilder {
  108032. /**
  108033. * Creates a polyhedron mesh
  108034. * * 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
  108035. * * The parameter `size` (positive float, default 1) sets the polygon size
  108036. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108037. * * 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`
  108038. * * 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
  108039. * * 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)`)
  108040. * * 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
  108041. * * 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
  108042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108045. * @param name defines the name of the mesh
  108046. * @param options defines the options used to create the mesh
  108047. * @param scene defines the hosting scene
  108048. * @returns the polyhedron mesh
  108049. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108050. */
  108051. static CreatePolyhedron(name: string, options: {
  108052. type?: number;
  108053. size?: number;
  108054. sizeX?: number;
  108055. sizeY?: number;
  108056. sizeZ?: number;
  108057. custom?: any;
  108058. faceUV?: Vector4[];
  108059. faceColors?: Color4[];
  108060. flat?: boolean;
  108061. updatable?: boolean;
  108062. sideOrientation?: number;
  108063. frontUVs?: Vector4;
  108064. backUVs?: Vector4;
  108065. }, scene?: Nullable<Scene>): Mesh;
  108066. }
  108067. }
  108068. declare module BABYLON {
  108069. /**
  108070. * Gizmo that enables scaling a mesh along 3 axis
  108071. */
  108072. export class ScaleGizmo extends Gizmo {
  108073. /**
  108074. * Internal gizmo used for interactions on the x axis
  108075. */
  108076. xGizmo: AxisScaleGizmo;
  108077. /**
  108078. * Internal gizmo used for interactions on the y axis
  108079. */
  108080. yGizmo: AxisScaleGizmo;
  108081. /**
  108082. * Internal gizmo used for interactions on the z axis
  108083. */
  108084. zGizmo: AxisScaleGizmo;
  108085. /**
  108086. * Internal gizmo used to scale all axis equally
  108087. */
  108088. uniformScaleGizmo: AxisScaleGizmo;
  108089. private _meshAttached;
  108090. private _updateGizmoRotationToMatchAttachedMesh;
  108091. private _snapDistance;
  108092. private _scaleRatio;
  108093. private _uniformScalingMesh;
  108094. private _octahedron;
  108095. /** Fires an event when any of it's sub gizmos are dragged */
  108096. onDragStartObservable: Observable<unknown>;
  108097. /** Fires an event when any of it's sub gizmos are released from dragging */
  108098. onDragEndObservable: Observable<unknown>;
  108099. attachedMesh: Nullable<AbstractMesh>;
  108100. /**
  108101. * Creates a ScaleGizmo
  108102. * @param gizmoLayer The utility layer the gizmo will be added to
  108103. */
  108104. constructor(gizmoLayer?: UtilityLayerRenderer);
  108105. updateGizmoRotationToMatchAttachedMesh: boolean;
  108106. /**
  108107. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108108. */
  108109. snapDistance: number;
  108110. /**
  108111. * Ratio for the scale of the gizmo (Default: 1)
  108112. */
  108113. scaleRatio: number;
  108114. /**
  108115. * Disposes of the gizmo
  108116. */
  108117. dispose(): void;
  108118. }
  108119. }
  108120. declare module BABYLON {
  108121. /**
  108122. * Single axis scale gizmo
  108123. */
  108124. export class AxisScaleGizmo extends Gizmo {
  108125. /**
  108126. * Drag behavior responsible for the gizmos dragging interactions
  108127. */
  108128. dragBehavior: PointerDragBehavior;
  108129. private _pointerObserver;
  108130. /**
  108131. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108132. */
  108133. snapDistance: number;
  108134. /**
  108135. * Event that fires each time the gizmo snaps to a new location.
  108136. * * snapDistance is the the change in distance
  108137. */
  108138. onSnapObservable: Observable<{
  108139. snapDistance: number;
  108140. }>;
  108141. /**
  108142. * If the scaling operation should be done on all axis (default: false)
  108143. */
  108144. uniformScaling: boolean;
  108145. private _isEnabled;
  108146. private _parent;
  108147. private _arrow;
  108148. private _coloredMaterial;
  108149. private _hoverMaterial;
  108150. /**
  108151. * Creates an AxisScaleGizmo
  108152. * @param gizmoLayer The utility layer the gizmo will be added to
  108153. * @param dragAxis The axis which the gizmo will be able to scale on
  108154. * @param color The color of the gizmo
  108155. */
  108156. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108157. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108158. /**
  108159. * If the gizmo is enabled
  108160. */
  108161. isEnabled: boolean;
  108162. /**
  108163. * Disposes of the gizmo
  108164. */
  108165. dispose(): void;
  108166. /**
  108167. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108168. * @param mesh The mesh to replace the default mesh of the gizmo
  108169. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108170. */
  108171. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /**
  108176. * Bounding box gizmo
  108177. */
  108178. export class BoundingBoxGizmo extends Gizmo {
  108179. private _lineBoundingBox;
  108180. private _rotateSpheresParent;
  108181. private _scaleBoxesParent;
  108182. private _boundingDimensions;
  108183. private _renderObserver;
  108184. private _pointerObserver;
  108185. private _scaleDragSpeed;
  108186. private _tmpQuaternion;
  108187. private _tmpVector;
  108188. private _tmpRotationMatrix;
  108189. /**
  108190. * 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)
  108191. */
  108192. ignoreChildren: boolean;
  108193. /**
  108194. * 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)
  108195. */
  108196. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108197. /**
  108198. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108199. */
  108200. rotationSphereSize: number;
  108201. /**
  108202. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108203. */
  108204. scaleBoxSize: number;
  108205. /**
  108206. * 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)
  108207. */
  108208. fixedDragMeshScreenSize: boolean;
  108209. /**
  108210. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108211. */
  108212. fixedDragMeshScreenSizeDistanceFactor: number;
  108213. /**
  108214. * Fired when a rotation sphere or scale box is dragged
  108215. */
  108216. onDragStartObservable: Observable<{}>;
  108217. /**
  108218. * Fired when a scale box is dragged
  108219. */
  108220. onScaleBoxDragObservable: Observable<{}>;
  108221. /**
  108222. * Fired when a scale box drag is ended
  108223. */
  108224. onScaleBoxDragEndObservable: Observable<{}>;
  108225. /**
  108226. * Fired when a rotation sphere is dragged
  108227. */
  108228. onRotationSphereDragObservable: Observable<{}>;
  108229. /**
  108230. * Fired when a rotation sphere drag is ended
  108231. */
  108232. onRotationSphereDragEndObservable: Observable<{}>;
  108233. /**
  108234. * 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)
  108235. */
  108236. scalePivot: Nullable<Vector3>;
  108237. /**
  108238. * Mesh used as a pivot to rotate the attached mesh
  108239. */
  108240. private _anchorMesh;
  108241. private _existingMeshScale;
  108242. private _dragMesh;
  108243. private pointerDragBehavior;
  108244. private coloredMaterial;
  108245. private hoverColoredMaterial;
  108246. /**
  108247. * Sets the color of the bounding box gizmo
  108248. * @param color the color to set
  108249. */
  108250. setColor(color: Color3): void;
  108251. /**
  108252. * Creates an BoundingBoxGizmo
  108253. * @param gizmoLayer The utility layer the gizmo will be added to
  108254. * @param color The color of the gizmo
  108255. */
  108256. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108257. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108258. private _selectNode;
  108259. /**
  108260. * Updates the bounding box information for the Gizmo
  108261. */
  108262. updateBoundingBox(): void;
  108263. private _updateRotationSpheres;
  108264. private _updateScaleBoxes;
  108265. /**
  108266. * Enables rotation on the specified axis and disables rotation on the others
  108267. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108268. */
  108269. setEnabledRotationAxis(axis: string): void;
  108270. /**
  108271. * Enables/disables scaling
  108272. * @param enable if scaling should be enabled
  108273. */
  108274. setEnabledScaling(enable: boolean): void;
  108275. private _updateDummy;
  108276. /**
  108277. * Enables a pointer drag behavior on the bounding box of the gizmo
  108278. */
  108279. enableDragBehavior(): void;
  108280. /**
  108281. * Disposes of the gizmo
  108282. */
  108283. dispose(): void;
  108284. /**
  108285. * 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)
  108286. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108287. * @returns the bounding box mesh with the passed in mesh as a child
  108288. */
  108289. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108290. /**
  108291. * CustomMeshes are not supported by this gizmo
  108292. * @param mesh The mesh to replace the default mesh of the gizmo
  108293. */
  108294. setCustomMesh(mesh: Mesh): void;
  108295. }
  108296. }
  108297. declare module BABYLON {
  108298. /**
  108299. * Single plane rotation gizmo
  108300. */
  108301. export class PlaneRotationGizmo extends Gizmo {
  108302. /**
  108303. * Drag behavior responsible for the gizmos dragging interactions
  108304. */
  108305. dragBehavior: PointerDragBehavior;
  108306. private _pointerObserver;
  108307. /**
  108308. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108309. */
  108310. snapDistance: number;
  108311. /**
  108312. * Event that fires each time the gizmo snaps to a new location.
  108313. * * snapDistance is the the change in distance
  108314. */
  108315. onSnapObservable: Observable<{
  108316. snapDistance: number;
  108317. }>;
  108318. private _isEnabled;
  108319. private _parent;
  108320. /**
  108321. * Creates a PlaneRotationGizmo
  108322. * @param gizmoLayer The utility layer the gizmo will be added to
  108323. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108324. * @param color The color of the gizmo
  108325. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108326. */
  108327. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  108328. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108329. /**
  108330. * If the gizmo is enabled
  108331. */
  108332. isEnabled: boolean;
  108333. /**
  108334. * Disposes of the gizmo
  108335. */
  108336. dispose(): void;
  108337. }
  108338. }
  108339. declare module BABYLON {
  108340. /**
  108341. * Gizmo that enables rotating a mesh along 3 axis
  108342. */
  108343. export class RotationGizmo extends Gizmo {
  108344. /**
  108345. * Internal gizmo used for interactions on the x axis
  108346. */
  108347. xGizmo: PlaneRotationGizmo;
  108348. /**
  108349. * Internal gizmo used for interactions on the y axis
  108350. */
  108351. yGizmo: PlaneRotationGizmo;
  108352. /**
  108353. * Internal gizmo used for interactions on the z axis
  108354. */
  108355. zGizmo: PlaneRotationGizmo;
  108356. /** Fires an event when any of it's sub gizmos are dragged */
  108357. onDragStartObservable: Observable<unknown>;
  108358. /** Fires an event when any of it's sub gizmos are released from dragging */
  108359. onDragEndObservable: Observable<unknown>;
  108360. private _meshAttached;
  108361. attachedMesh: Nullable<AbstractMesh>;
  108362. /**
  108363. * Creates a RotationGizmo
  108364. * @param gizmoLayer The utility layer the gizmo will be added to
  108365. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108366. */
  108367. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  108368. updateGizmoRotationToMatchAttachedMesh: boolean;
  108369. /**
  108370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108371. */
  108372. snapDistance: number;
  108373. /**
  108374. * Ratio for the scale of the gizmo (Default: 1)
  108375. */
  108376. scaleRatio: number;
  108377. /**
  108378. * Disposes of the gizmo
  108379. */
  108380. dispose(): void;
  108381. /**
  108382. * CustomMeshes are not supported by this gizmo
  108383. * @param mesh The mesh to replace the default mesh of the gizmo
  108384. */
  108385. setCustomMesh(mesh: Mesh): void;
  108386. }
  108387. }
  108388. declare module BABYLON {
  108389. /**
  108390. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108391. */
  108392. export class GizmoManager implements IDisposable {
  108393. private scene;
  108394. /**
  108395. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108396. */
  108397. gizmos: {
  108398. positionGizmo: Nullable<PositionGizmo>;
  108399. rotationGizmo: Nullable<RotationGizmo>;
  108400. scaleGizmo: Nullable<ScaleGizmo>;
  108401. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108402. };
  108403. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108404. clearGizmoOnEmptyPointerEvent: boolean;
  108405. /** Fires an event when the manager is attached to a mesh */
  108406. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108407. private _gizmosEnabled;
  108408. private _pointerObserver;
  108409. private _attachedMesh;
  108410. private _boundingBoxColor;
  108411. private _defaultUtilityLayer;
  108412. private _defaultKeepDepthUtilityLayer;
  108413. /**
  108414. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108415. */
  108416. boundingBoxDragBehavior: SixDofDragBehavior;
  108417. /**
  108418. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108419. */
  108420. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108421. /**
  108422. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108423. */
  108424. usePointerToAttachGizmos: boolean;
  108425. /**
  108426. * Utility layer that the bounding box gizmo belongs to
  108427. */
  108428. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108429. /**
  108430. * Utility layer that all gizmos besides bounding box belong to
  108431. */
  108432. readonly utilityLayer: UtilityLayerRenderer;
  108433. /**
  108434. * Instatiates a gizmo manager
  108435. * @param scene the scene to overlay the gizmos on top of
  108436. */
  108437. constructor(scene: Scene);
  108438. /**
  108439. * Attaches a set of gizmos to the specified mesh
  108440. * @param mesh The mesh the gizmo's should be attached to
  108441. */
  108442. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108443. /**
  108444. * If the position gizmo is enabled
  108445. */
  108446. positionGizmoEnabled: boolean;
  108447. /**
  108448. * If the rotation gizmo is enabled
  108449. */
  108450. rotationGizmoEnabled: boolean;
  108451. /**
  108452. * If the scale gizmo is enabled
  108453. */
  108454. scaleGizmoEnabled: boolean;
  108455. /**
  108456. * If the boundingBox gizmo is enabled
  108457. */
  108458. boundingBoxGizmoEnabled: boolean;
  108459. /**
  108460. * Disposes of the gizmo manager
  108461. */
  108462. dispose(): void;
  108463. }
  108464. }
  108465. declare module BABYLON {
  108466. /**
  108467. * A directional light is defined by a direction (what a surprise!).
  108468. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108469. * 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.
  108470. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108471. */
  108472. export class DirectionalLight extends ShadowLight {
  108473. private _shadowFrustumSize;
  108474. /**
  108475. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108476. */
  108477. /**
  108478. * Specifies a fix frustum size for the shadow generation.
  108479. */
  108480. shadowFrustumSize: number;
  108481. private _shadowOrthoScale;
  108482. /**
  108483. * Gets the shadow projection scale against the optimal computed one.
  108484. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108485. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108486. */
  108487. /**
  108488. * Sets the shadow projection scale against the optimal computed one.
  108489. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108490. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108491. */
  108492. shadowOrthoScale: number;
  108493. /**
  108494. * Automatically compute the projection matrix to best fit (including all the casters)
  108495. * on each frame.
  108496. */
  108497. autoUpdateExtends: boolean;
  108498. private _orthoLeft;
  108499. private _orthoRight;
  108500. private _orthoTop;
  108501. private _orthoBottom;
  108502. /**
  108503. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108504. * The directional light is emitted from everywhere in the given direction.
  108505. * It can cast shadows.
  108506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108507. * @param name The friendly name of the light
  108508. * @param direction The direction of the light
  108509. * @param scene The scene the light belongs to
  108510. */
  108511. constructor(name: string, direction: Vector3, scene: Scene);
  108512. /**
  108513. * Returns the string "DirectionalLight".
  108514. * @return The class name
  108515. */
  108516. getClassName(): string;
  108517. /**
  108518. * Returns the integer 1.
  108519. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108520. */
  108521. getTypeID(): number;
  108522. /**
  108523. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108524. * Returns the DirectionalLight Shadow projection matrix.
  108525. */
  108526. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108527. /**
  108528. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108529. * Returns the DirectionalLight Shadow projection matrix.
  108530. */
  108531. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108532. /**
  108533. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108534. * Returns the DirectionalLight Shadow projection matrix.
  108535. */
  108536. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108537. protected _buildUniformLayout(): void;
  108538. /**
  108539. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108540. * @param effect The effect to update
  108541. * @param lightIndex The index of the light in the effect to update
  108542. * @returns The directional light
  108543. */
  108544. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108545. /**
  108546. * Gets the minZ used for shadow according to both the scene and the light.
  108547. *
  108548. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108549. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108550. * @param activeCamera The camera we are returning the min for
  108551. * @returns the depth min z
  108552. */
  108553. getDepthMinZ(activeCamera: Camera): number;
  108554. /**
  108555. * Gets the maxZ used for shadow according to both the scene and the light.
  108556. *
  108557. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108558. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108559. * @param activeCamera The camera we are returning the max for
  108560. * @returns the depth max z
  108561. */
  108562. getDepthMaxZ(activeCamera: Camera): number;
  108563. /**
  108564. * Prepares the list of defines specific to the light type.
  108565. * @param defines the list of defines
  108566. * @param lightIndex defines the index of the light for the effect
  108567. */
  108568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108569. }
  108570. }
  108571. declare module BABYLON {
  108572. /**
  108573. * Class containing static functions to help procedurally build meshes
  108574. */
  108575. export class HemisphereBuilder {
  108576. /**
  108577. * Creates a hemisphere mesh
  108578. * @param name defines the name of the mesh
  108579. * @param options defines the options used to create the mesh
  108580. * @param scene defines the hosting scene
  108581. * @returns the hemisphere mesh
  108582. */
  108583. static CreateHemisphere(name: string, options: {
  108584. segments?: number;
  108585. diameter?: number;
  108586. sideOrientation?: number;
  108587. }, scene: any): Mesh;
  108588. }
  108589. }
  108590. declare module BABYLON {
  108591. /**
  108592. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108593. * These values define a cone of light starting from the position, emitting toward the direction.
  108594. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108595. * and the exponent defines the speed of the decay of the light with distance (reach).
  108596. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108597. */
  108598. export class SpotLight extends ShadowLight {
  108599. private _angle;
  108600. private _innerAngle;
  108601. private _cosHalfAngle;
  108602. private _lightAngleScale;
  108603. private _lightAngleOffset;
  108604. /**
  108605. * Gets the cone angle of the spot light in Radians.
  108606. */
  108607. /**
  108608. * Sets the cone angle of the spot light in Radians.
  108609. */
  108610. angle: number;
  108611. /**
  108612. * Only used in gltf falloff mode, this defines the angle where
  108613. * the directional falloff will start before cutting at angle which could be seen
  108614. * as outer angle.
  108615. */
  108616. /**
  108617. * Only used in gltf falloff mode, this defines the angle where
  108618. * the directional falloff will start before cutting at angle which could be seen
  108619. * as outer angle.
  108620. */
  108621. innerAngle: number;
  108622. private _shadowAngleScale;
  108623. /**
  108624. * Allows scaling the angle of the light for shadow generation only.
  108625. */
  108626. /**
  108627. * Allows scaling the angle of the light for shadow generation only.
  108628. */
  108629. shadowAngleScale: number;
  108630. /**
  108631. * The light decay speed with the distance from the emission spot.
  108632. */
  108633. exponent: number;
  108634. private _projectionTextureMatrix;
  108635. /**
  108636. * Allows reading the projecton texture
  108637. */
  108638. readonly projectionTextureMatrix: Matrix;
  108639. protected _projectionTextureLightNear: number;
  108640. /**
  108641. * Gets the near clip of the Spotlight for texture projection.
  108642. */
  108643. /**
  108644. * Sets the near clip of the Spotlight for texture projection.
  108645. */
  108646. projectionTextureLightNear: number;
  108647. protected _projectionTextureLightFar: number;
  108648. /**
  108649. * Gets the far clip of the Spotlight for texture projection.
  108650. */
  108651. /**
  108652. * Sets the far clip of the Spotlight for texture projection.
  108653. */
  108654. projectionTextureLightFar: number;
  108655. protected _projectionTextureUpDirection: Vector3;
  108656. /**
  108657. * Gets the Up vector of the Spotlight for texture projection.
  108658. */
  108659. /**
  108660. * Sets the Up vector of the Spotlight for texture projection.
  108661. */
  108662. projectionTextureUpDirection: Vector3;
  108663. private _projectionTexture;
  108664. /**
  108665. * Gets the projection texture of the light.
  108666. */
  108667. /**
  108668. * Sets the projection texture of the light.
  108669. */
  108670. projectionTexture: Nullable<BaseTexture>;
  108671. private _projectionTextureViewLightDirty;
  108672. private _projectionTextureProjectionLightDirty;
  108673. private _projectionTextureDirty;
  108674. private _projectionTextureViewTargetVector;
  108675. private _projectionTextureViewLightMatrix;
  108676. private _projectionTextureProjectionLightMatrix;
  108677. private _projectionTextureScalingMatrix;
  108678. /**
  108679. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108680. * It can cast shadows.
  108681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108682. * @param name The light friendly name
  108683. * @param position The position of the spot light in the scene
  108684. * @param direction The direction of the light in the scene
  108685. * @param angle The cone angle of the light in Radians
  108686. * @param exponent The light decay speed with the distance from the emission spot
  108687. * @param scene The scene the lights belongs to
  108688. */
  108689. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108690. /**
  108691. * Returns the string "SpotLight".
  108692. * @returns the class name
  108693. */
  108694. getClassName(): string;
  108695. /**
  108696. * Returns the integer 2.
  108697. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108698. */
  108699. getTypeID(): number;
  108700. /**
  108701. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108702. */
  108703. protected _setDirection(value: Vector3): void;
  108704. /**
  108705. * Overrides the position setter to recompute the projection texture view light Matrix.
  108706. */
  108707. protected _setPosition(value: Vector3): void;
  108708. /**
  108709. * 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.
  108710. * Returns the SpotLight.
  108711. */
  108712. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108713. protected _computeProjectionTextureViewLightMatrix(): void;
  108714. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108715. /**
  108716. * Main function for light texture projection matrix computing.
  108717. */
  108718. protected _computeProjectionTextureMatrix(): void;
  108719. protected _buildUniformLayout(): void;
  108720. private _computeAngleValues;
  108721. /**
  108722. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108723. * @param effect The effect to update
  108724. * @param lightIndex The index of the light in the effect to update
  108725. * @returns The spot light
  108726. */
  108727. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108728. /**
  108729. * Disposes the light and the associated resources.
  108730. */
  108731. dispose(): void;
  108732. /**
  108733. * Prepares the list of defines specific to the light type.
  108734. * @param defines the list of defines
  108735. * @param lightIndex defines the index of the light for the effect
  108736. */
  108737. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108738. }
  108739. }
  108740. declare module BABYLON {
  108741. /**
  108742. * Gizmo that enables viewing a light
  108743. */
  108744. export class LightGizmo extends Gizmo {
  108745. private _lightMesh;
  108746. private _material;
  108747. private cachedPosition;
  108748. private cachedForward;
  108749. /**
  108750. * Creates a LightGizmo
  108751. * @param gizmoLayer The utility layer the gizmo will be added to
  108752. */
  108753. constructor(gizmoLayer?: UtilityLayerRenderer);
  108754. private _light;
  108755. /**
  108756. * The light that the gizmo is attached to
  108757. */
  108758. light: Nullable<Light>;
  108759. /**
  108760. * @hidden
  108761. * Updates the gizmo to match the attached mesh's position/rotation
  108762. */
  108763. protected _update(): void;
  108764. private static _Scale;
  108765. /**
  108766. * Creates the lines for a light mesh
  108767. */
  108768. private static _createLightLines;
  108769. /**
  108770. * Disposes of the light gizmo
  108771. */
  108772. dispose(): void;
  108773. private static _CreateHemisphericLightMesh;
  108774. private static _CreatePointLightMesh;
  108775. private static _CreateSpotLightMesh;
  108776. private static _CreateDirectionalLightMesh;
  108777. }
  108778. }
  108779. declare module BABYLON {
  108780. /** @hidden */
  108781. export var backgroundFragmentDeclaration: {
  108782. name: string;
  108783. shader: string;
  108784. };
  108785. }
  108786. declare module BABYLON {
  108787. /** @hidden */
  108788. export var backgroundUboDeclaration: {
  108789. name: string;
  108790. shader: string;
  108791. };
  108792. }
  108793. declare module BABYLON {
  108794. /** @hidden */
  108795. export var backgroundPixelShader: {
  108796. name: string;
  108797. shader: string;
  108798. };
  108799. }
  108800. declare module BABYLON {
  108801. /** @hidden */
  108802. export var backgroundVertexDeclaration: {
  108803. name: string;
  108804. shader: string;
  108805. };
  108806. }
  108807. declare module BABYLON {
  108808. /** @hidden */
  108809. export var backgroundVertexShader: {
  108810. name: string;
  108811. shader: string;
  108812. };
  108813. }
  108814. declare module BABYLON {
  108815. /**
  108816. * Background material used to create an efficient environement around your scene.
  108817. */
  108818. export class BackgroundMaterial extends PushMaterial {
  108819. /**
  108820. * Standard reflectance value at parallel view angle.
  108821. */
  108822. static StandardReflectance0: number;
  108823. /**
  108824. * Standard reflectance value at grazing angle.
  108825. */
  108826. static StandardReflectance90: number;
  108827. protected _primaryColor: Color3;
  108828. /**
  108829. * Key light Color (multiply against the environement texture)
  108830. */
  108831. primaryColor: Color3;
  108832. protected __perceptualColor: Nullable<Color3>;
  108833. /**
  108834. * Experimental Internal Use Only.
  108835. *
  108836. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108837. * This acts as a helper to set the primary color to a more "human friendly" value.
  108838. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108839. * output color as close as possible from the chosen value.
  108840. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108841. * part of lighting setup.)
  108842. */
  108843. _perceptualColor: Nullable<Color3>;
  108844. protected _primaryColorShadowLevel: float;
  108845. /**
  108846. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108847. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108848. */
  108849. primaryColorShadowLevel: float;
  108850. protected _primaryColorHighlightLevel: float;
  108851. /**
  108852. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108853. * The primary color is used at the level chosen to define what the white area would look.
  108854. */
  108855. primaryColorHighlightLevel: float;
  108856. protected _reflectionTexture: Nullable<BaseTexture>;
  108857. /**
  108858. * Reflection Texture used in the material.
  108859. * Should be author in a specific way for the best result (refer to the documentation).
  108860. */
  108861. reflectionTexture: Nullable<BaseTexture>;
  108862. protected _reflectionBlur: float;
  108863. /**
  108864. * Reflection Texture level of blur.
  108865. *
  108866. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108867. * texture twice.
  108868. */
  108869. reflectionBlur: float;
  108870. protected _diffuseTexture: Nullable<BaseTexture>;
  108871. /**
  108872. * Diffuse Texture used in the material.
  108873. * Should be author in a specific way for the best result (refer to the documentation).
  108874. */
  108875. diffuseTexture: Nullable<BaseTexture>;
  108876. protected _shadowLights: Nullable<IShadowLight[]>;
  108877. /**
  108878. * Specify the list of lights casting shadow on the material.
  108879. * All scene shadow lights will be included if null.
  108880. */
  108881. shadowLights: Nullable<IShadowLight[]>;
  108882. protected _shadowLevel: float;
  108883. /**
  108884. * Helps adjusting the shadow to a softer level if required.
  108885. * 0 means black shadows and 1 means no shadows.
  108886. */
  108887. shadowLevel: float;
  108888. protected _sceneCenter: Vector3;
  108889. /**
  108890. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108891. * It is usually zero but might be interesting to modify according to your setup.
  108892. */
  108893. sceneCenter: Vector3;
  108894. protected _opacityFresnel: boolean;
  108895. /**
  108896. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108897. * This helps ensuring a nice transition when the camera goes under the ground.
  108898. */
  108899. opacityFresnel: boolean;
  108900. protected _reflectionFresnel: boolean;
  108901. /**
  108902. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108903. * This helps adding a mirror texture on the ground.
  108904. */
  108905. reflectionFresnel: boolean;
  108906. protected _reflectionFalloffDistance: number;
  108907. /**
  108908. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108909. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108910. */
  108911. reflectionFalloffDistance: number;
  108912. protected _reflectionAmount: number;
  108913. /**
  108914. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108915. */
  108916. reflectionAmount: number;
  108917. protected _reflectionReflectance0: number;
  108918. /**
  108919. * This specifies the weight of the reflection at grazing angle.
  108920. */
  108921. reflectionReflectance0: number;
  108922. protected _reflectionReflectance90: number;
  108923. /**
  108924. * This specifies the weight of the reflection at a perpendicular point of view.
  108925. */
  108926. reflectionReflectance90: number;
  108927. /**
  108928. * Sets the reflection reflectance fresnel values according to the default standard
  108929. * empirically know to work well :-)
  108930. */
  108931. reflectionStandardFresnelWeight: number;
  108932. protected _useRGBColor: boolean;
  108933. /**
  108934. * Helps to directly use the maps channels instead of their level.
  108935. */
  108936. useRGBColor: boolean;
  108937. protected _enableNoise: boolean;
  108938. /**
  108939. * This helps reducing the banding effect that could occur on the background.
  108940. */
  108941. enableNoise: boolean;
  108942. /**
  108943. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108944. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108945. * Recommended to be keep at 1.0 except for special cases.
  108946. */
  108947. fovMultiplier: number;
  108948. private _fovMultiplier;
  108949. /**
  108950. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108951. */
  108952. useEquirectangularFOV: boolean;
  108953. private _maxSimultaneousLights;
  108954. /**
  108955. * Number of Simultaneous lights allowed on the material.
  108956. */
  108957. maxSimultaneousLights: int;
  108958. /**
  108959. * Default configuration related to image processing available in the Background Material.
  108960. */
  108961. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108962. /**
  108963. * Keep track of the image processing observer to allow dispose and replace.
  108964. */
  108965. private _imageProcessingObserver;
  108966. /**
  108967. * Attaches a new image processing configuration to the PBR Material.
  108968. * @param configuration (if null the scene configuration will be use)
  108969. */
  108970. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108971. /**
  108972. * Gets the image processing configuration used either in this material.
  108973. */
  108974. /**
  108975. * Sets the Default image processing configuration used either in the this material.
  108976. *
  108977. * If sets to null, the scene one is in use.
  108978. */
  108979. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108980. /**
  108981. * Gets wether the color curves effect is enabled.
  108982. */
  108983. /**
  108984. * Sets wether the color curves effect is enabled.
  108985. */
  108986. cameraColorCurvesEnabled: boolean;
  108987. /**
  108988. * Gets wether the color grading effect is enabled.
  108989. */
  108990. /**
  108991. * Gets wether the color grading effect is enabled.
  108992. */
  108993. cameraColorGradingEnabled: boolean;
  108994. /**
  108995. * Gets wether tonemapping is enabled or not.
  108996. */
  108997. /**
  108998. * Sets wether tonemapping is enabled or not
  108999. */
  109000. cameraToneMappingEnabled: boolean;
  109001. /**
  109002. * The camera exposure used on this material.
  109003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109004. * This corresponds to a photographic exposure.
  109005. */
  109006. /**
  109007. * The camera exposure used on this material.
  109008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109009. * This corresponds to a photographic exposure.
  109010. */
  109011. cameraExposure: float;
  109012. /**
  109013. * Gets The camera contrast used on this material.
  109014. */
  109015. /**
  109016. * Sets The camera contrast used on this material.
  109017. */
  109018. cameraContrast: float;
  109019. /**
  109020. * Gets the Color Grading 2D Lookup Texture.
  109021. */
  109022. /**
  109023. * Sets the Color Grading 2D Lookup Texture.
  109024. */
  109025. cameraColorGradingTexture: Nullable<BaseTexture>;
  109026. /**
  109027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109029. * 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;
  109030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109031. */
  109032. /**
  109033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109035. * 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;
  109036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109037. */
  109038. cameraColorCurves: Nullable<ColorCurves>;
  109039. /**
  109040. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109041. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109042. */
  109043. switchToBGR: boolean;
  109044. private _renderTargets;
  109045. private _reflectionControls;
  109046. private _white;
  109047. private _primaryShadowColor;
  109048. private _primaryHighlightColor;
  109049. /**
  109050. * Instantiates a Background Material in the given scene
  109051. * @param name The friendly name of the material
  109052. * @param scene The scene to add the material to
  109053. */
  109054. constructor(name: string, scene: Scene);
  109055. /**
  109056. * Gets a boolean indicating that current material needs to register RTT
  109057. */
  109058. readonly hasRenderTargetTextures: boolean;
  109059. /**
  109060. * The entire material has been created in order to prevent overdraw.
  109061. * @returns false
  109062. */
  109063. needAlphaTesting(): boolean;
  109064. /**
  109065. * The entire material has been created in order to prevent overdraw.
  109066. * @returns true if blending is enable
  109067. */
  109068. needAlphaBlending(): boolean;
  109069. /**
  109070. * Checks wether the material is ready to be rendered for a given mesh.
  109071. * @param mesh The mesh to render
  109072. * @param subMesh The submesh to check against
  109073. * @param useInstances Specify wether or not the material is used with instances
  109074. * @returns true if all the dependencies are ready (Textures, Effects...)
  109075. */
  109076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109077. /**
  109078. * Compute the primary color according to the chosen perceptual color.
  109079. */
  109080. private _computePrimaryColorFromPerceptualColor;
  109081. /**
  109082. * Compute the highlights and shadow colors according to their chosen levels.
  109083. */
  109084. private _computePrimaryColors;
  109085. /**
  109086. * Build the uniform buffer used in the material.
  109087. */
  109088. buildUniformLayout(): void;
  109089. /**
  109090. * Unbind the material.
  109091. */
  109092. unbind(): void;
  109093. /**
  109094. * Bind only the world matrix to the material.
  109095. * @param world The world matrix to bind.
  109096. */
  109097. bindOnlyWorldMatrix(world: Matrix): void;
  109098. /**
  109099. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109100. * @param world The world matrix to bind.
  109101. * @param subMesh The submesh to bind for.
  109102. */
  109103. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109104. /**
  109105. * Dispose the material.
  109106. * @param forceDisposeEffect Force disposal of the associated effect.
  109107. * @param forceDisposeTextures Force disposal of the associated textures.
  109108. */
  109109. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109110. /**
  109111. * Clones the material.
  109112. * @param name The cloned name.
  109113. * @returns The cloned material.
  109114. */
  109115. clone(name: string): BackgroundMaterial;
  109116. /**
  109117. * Serializes the current material to its JSON representation.
  109118. * @returns The JSON representation.
  109119. */
  109120. serialize(): any;
  109121. /**
  109122. * Gets the class name of the material
  109123. * @returns "BackgroundMaterial"
  109124. */
  109125. getClassName(): string;
  109126. /**
  109127. * Parse a JSON input to create back a background material.
  109128. * @param source The JSON data to parse
  109129. * @param scene The scene to create the parsed material in
  109130. * @param rootUrl The root url of the assets the material depends upon
  109131. * @returns the instantiated BackgroundMaterial.
  109132. */
  109133. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109134. }
  109135. }
  109136. declare module BABYLON {
  109137. /**
  109138. * Represents the different options available during the creation of
  109139. * a Environment helper.
  109140. *
  109141. * This can control the default ground, skybox and image processing setup of your scene.
  109142. */
  109143. export interface IEnvironmentHelperOptions {
  109144. /**
  109145. * Specifies wether or not to create a ground.
  109146. * True by default.
  109147. */
  109148. createGround: boolean;
  109149. /**
  109150. * Specifies the ground size.
  109151. * 15 by default.
  109152. */
  109153. groundSize: number;
  109154. /**
  109155. * The texture used on the ground for the main color.
  109156. * Comes from the BabylonJS CDN by default.
  109157. *
  109158. * Remarks: Can be either a texture or a url.
  109159. */
  109160. groundTexture: string | BaseTexture;
  109161. /**
  109162. * The color mixed in the ground texture by default.
  109163. * BabylonJS clearColor by default.
  109164. */
  109165. groundColor: Color3;
  109166. /**
  109167. * Specifies the ground opacity.
  109168. * 1 by default.
  109169. */
  109170. groundOpacity: number;
  109171. /**
  109172. * Enables the ground to receive shadows.
  109173. * True by default.
  109174. */
  109175. enableGroundShadow: boolean;
  109176. /**
  109177. * Helps preventing the shadow to be fully black on the ground.
  109178. * 0.5 by default.
  109179. */
  109180. groundShadowLevel: number;
  109181. /**
  109182. * Creates a mirror texture attach to the ground.
  109183. * false by default.
  109184. */
  109185. enableGroundMirror: boolean;
  109186. /**
  109187. * Specifies the ground mirror size ratio.
  109188. * 0.3 by default as the default kernel is 64.
  109189. */
  109190. groundMirrorSizeRatio: number;
  109191. /**
  109192. * Specifies the ground mirror blur kernel size.
  109193. * 64 by default.
  109194. */
  109195. groundMirrorBlurKernel: number;
  109196. /**
  109197. * Specifies the ground mirror visibility amount.
  109198. * 1 by default
  109199. */
  109200. groundMirrorAmount: number;
  109201. /**
  109202. * Specifies the ground mirror reflectance weight.
  109203. * This uses the standard weight of the background material to setup the fresnel effect
  109204. * of the mirror.
  109205. * 1 by default.
  109206. */
  109207. groundMirrorFresnelWeight: number;
  109208. /**
  109209. * Specifies the ground mirror Falloff distance.
  109210. * This can helps reducing the size of the reflection.
  109211. * 0 by Default.
  109212. */
  109213. groundMirrorFallOffDistance: number;
  109214. /**
  109215. * Specifies the ground mirror texture type.
  109216. * Unsigned Int by Default.
  109217. */
  109218. groundMirrorTextureType: number;
  109219. /**
  109220. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109221. * the shown objects.
  109222. */
  109223. groundYBias: number;
  109224. /**
  109225. * Specifies wether or not to create a skybox.
  109226. * True by default.
  109227. */
  109228. createSkybox: boolean;
  109229. /**
  109230. * Specifies the skybox size.
  109231. * 20 by default.
  109232. */
  109233. skyboxSize: number;
  109234. /**
  109235. * The texture used on the skybox for the main color.
  109236. * Comes from the BabylonJS CDN by default.
  109237. *
  109238. * Remarks: Can be either a texture or a url.
  109239. */
  109240. skyboxTexture: string | BaseTexture;
  109241. /**
  109242. * The color mixed in the skybox texture by default.
  109243. * BabylonJS clearColor by default.
  109244. */
  109245. skyboxColor: Color3;
  109246. /**
  109247. * The background rotation around the Y axis of the scene.
  109248. * This helps aligning the key lights of your scene with the background.
  109249. * 0 by default.
  109250. */
  109251. backgroundYRotation: number;
  109252. /**
  109253. * Compute automatically the size of the elements to best fit with the scene.
  109254. */
  109255. sizeAuto: boolean;
  109256. /**
  109257. * Default position of the rootMesh if autoSize is not true.
  109258. */
  109259. rootPosition: Vector3;
  109260. /**
  109261. * Sets up the image processing in the scene.
  109262. * true by default.
  109263. */
  109264. setupImageProcessing: boolean;
  109265. /**
  109266. * The texture used as your environment texture in the scene.
  109267. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109268. *
  109269. * Remarks: Can be either a texture or a url.
  109270. */
  109271. environmentTexture: string | BaseTexture;
  109272. /**
  109273. * The value of the exposure to apply to the scene.
  109274. * 0.6 by default if setupImageProcessing is true.
  109275. */
  109276. cameraExposure: number;
  109277. /**
  109278. * The value of the contrast to apply to the scene.
  109279. * 1.6 by default if setupImageProcessing is true.
  109280. */
  109281. cameraContrast: number;
  109282. /**
  109283. * Specifies wether or not tonemapping should be enabled in the scene.
  109284. * true by default if setupImageProcessing is true.
  109285. */
  109286. toneMappingEnabled: boolean;
  109287. }
  109288. /**
  109289. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109290. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109291. * It also helps with the default setup of your imageProcessing configuration.
  109292. */
  109293. export class EnvironmentHelper {
  109294. /**
  109295. * Default ground texture URL.
  109296. */
  109297. private static _groundTextureCDNUrl;
  109298. /**
  109299. * Default skybox texture URL.
  109300. */
  109301. private static _skyboxTextureCDNUrl;
  109302. /**
  109303. * Default environment texture URL.
  109304. */
  109305. private static _environmentTextureCDNUrl;
  109306. /**
  109307. * Creates the default options for the helper.
  109308. */
  109309. private static _getDefaultOptions;
  109310. private _rootMesh;
  109311. /**
  109312. * Gets the root mesh created by the helper.
  109313. */
  109314. readonly rootMesh: Mesh;
  109315. private _skybox;
  109316. /**
  109317. * Gets the skybox created by the helper.
  109318. */
  109319. readonly skybox: Nullable<Mesh>;
  109320. private _skyboxTexture;
  109321. /**
  109322. * Gets the skybox texture created by the helper.
  109323. */
  109324. readonly skyboxTexture: Nullable<BaseTexture>;
  109325. private _skyboxMaterial;
  109326. /**
  109327. * Gets the skybox material created by the helper.
  109328. */
  109329. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109330. private _ground;
  109331. /**
  109332. * Gets the ground mesh created by the helper.
  109333. */
  109334. readonly ground: Nullable<Mesh>;
  109335. private _groundTexture;
  109336. /**
  109337. * Gets the ground texture created by the helper.
  109338. */
  109339. readonly groundTexture: Nullable<BaseTexture>;
  109340. private _groundMirror;
  109341. /**
  109342. * Gets the ground mirror created by the helper.
  109343. */
  109344. readonly groundMirror: Nullable<MirrorTexture>;
  109345. /**
  109346. * Gets the ground mirror render list to helps pushing the meshes
  109347. * you wish in the ground reflection.
  109348. */
  109349. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109350. private _groundMaterial;
  109351. /**
  109352. * Gets the ground material created by the helper.
  109353. */
  109354. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109355. /**
  109356. * Stores the creation options.
  109357. */
  109358. private readonly _scene;
  109359. private _options;
  109360. /**
  109361. * This observable will be notified with any error during the creation of the environment,
  109362. * mainly texture creation errors.
  109363. */
  109364. onErrorObservable: Observable<{
  109365. message?: string;
  109366. exception?: any;
  109367. }>;
  109368. /**
  109369. * constructor
  109370. * @param options Defines the options we want to customize the helper
  109371. * @param scene The scene to add the material to
  109372. */
  109373. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109374. /**
  109375. * Updates the background according to the new options
  109376. * @param options
  109377. */
  109378. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109379. /**
  109380. * Sets the primary color of all the available elements.
  109381. * @param color the main color to affect to the ground and the background
  109382. */
  109383. setMainColor(color: Color3): void;
  109384. /**
  109385. * Setup the image processing according to the specified options.
  109386. */
  109387. private _setupImageProcessing;
  109388. /**
  109389. * Setup the environment texture according to the specified options.
  109390. */
  109391. private _setupEnvironmentTexture;
  109392. /**
  109393. * Setup the background according to the specified options.
  109394. */
  109395. private _setupBackground;
  109396. /**
  109397. * Get the scene sizes according to the setup.
  109398. */
  109399. private _getSceneSize;
  109400. /**
  109401. * Setup the ground according to the specified options.
  109402. */
  109403. private _setupGround;
  109404. /**
  109405. * Setup the ground material according to the specified options.
  109406. */
  109407. private _setupGroundMaterial;
  109408. /**
  109409. * Setup the ground diffuse texture according to the specified options.
  109410. */
  109411. private _setupGroundDiffuseTexture;
  109412. /**
  109413. * Setup the ground mirror texture according to the specified options.
  109414. */
  109415. private _setupGroundMirrorTexture;
  109416. /**
  109417. * Setup the ground to receive the mirror texture.
  109418. */
  109419. private _setupMirrorInGroundMaterial;
  109420. /**
  109421. * Setup the skybox according to the specified options.
  109422. */
  109423. private _setupSkybox;
  109424. /**
  109425. * Setup the skybox material according to the specified options.
  109426. */
  109427. private _setupSkyboxMaterial;
  109428. /**
  109429. * Setup the skybox reflection texture according to the specified options.
  109430. */
  109431. private _setupSkyboxReflectionTexture;
  109432. private _errorHandler;
  109433. /**
  109434. * Dispose all the elements created by the Helper.
  109435. */
  109436. dispose(): void;
  109437. }
  109438. }
  109439. declare module BABYLON {
  109440. /**
  109441. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109442. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109443. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109444. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109445. */
  109446. export class PhotoDome extends TransformNode {
  109447. /**
  109448. * Define the image as a Monoscopic panoramic 360 image.
  109449. */
  109450. static readonly MODE_MONOSCOPIC: number;
  109451. /**
  109452. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109453. */
  109454. static readonly MODE_TOPBOTTOM: number;
  109455. /**
  109456. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109457. */
  109458. static readonly MODE_SIDEBYSIDE: number;
  109459. private _useDirectMapping;
  109460. /**
  109461. * The texture being displayed on the sphere
  109462. */
  109463. protected _photoTexture: Texture;
  109464. /**
  109465. * Gets or sets the texture being displayed on the sphere
  109466. */
  109467. photoTexture: Texture;
  109468. /**
  109469. * Observable raised when an error occured while loading the 360 image
  109470. */
  109471. onLoadErrorObservable: Observable<string>;
  109472. /**
  109473. * The skybox material
  109474. */
  109475. protected _material: BackgroundMaterial;
  109476. /**
  109477. * The surface used for the skybox
  109478. */
  109479. protected _mesh: Mesh;
  109480. /**
  109481. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109482. * Also see the options.resolution property.
  109483. */
  109484. fovMultiplier: number;
  109485. private _imageMode;
  109486. /**
  109487. * Gets or set the current video mode for the video. It can be:
  109488. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109489. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109490. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109491. */
  109492. imageMode: number;
  109493. /**
  109494. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109495. * @param name Element's name, child elements will append suffixes for their own names.
  109496. * @param urlsOfPhoto defines the url of the photo to display
  109497. * @param options defines an object containing optional or exposed sub element properties
  109498. * @param onError defines a callback called when an error occured while loading the texture
  109499. */
  109500. constructor(name: string, urlOfPhoto: string, options: {
  109501. resolution?: number;
  109502. size?: number;
  109503. useDirectMapping?: boolean;
  109504. faceForward?: boolean;
  109505. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109506. private _onBeforeCameraRenderObserver;
  109507. private _changeImageMode;
  109508. /**
  109509. * Releases resources associated with this node.
  109510. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109511. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109512. */
  109513. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109514. }
  109515. }
  109516. declare module BABYLON {
  109517. /** @hidden */
  109518. export var rgbdDecodePixelShader: {
  109519. name: string;
  109520. shader: string;
  109521. };
  109522. }
  109523. declare module BABYLON {
  109524. /**
  109525. * Class used to host texture specific utilities
  109526. */
  109527. export class BRDFTextureTools {
  109528. /**
  109529. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109530. * @param texture the texture to expand.
  109531. */
  109532. private static _ExpandDefaultBRDFTexture;
  109533. /**
  109534. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109535. * @param scene defines the hosting scene
  109536. * @returns the environment BRDF texture
  109537. */
  109538. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109539. private static _environmentBRDFBase64Texture;
  109540. }
  109541. }
  109542. declare module BABYLON {
  109543. /**
  109544. * @hidden
  109545. */
  109546. export interface IMaterialClearCoatDefines {
  109547. CLEARCOAT: boolean;
  109548. CLEARCOAT_DEFAULTIOR: boolean;
  109549. CLEARCOAT_TEXTURE: boolean;
  109550. CLEARCOAT_TEXTUREDIRECTUV: number;
  109551. CLEARCOAT_BUMP: boolean;
  109552. CLEARCOAT_BUMPDIRECTUV: number;
  109553. CLEARCOAT_TINT: boolean;
  109554. CLEARCOAT_TINT_TEXTURE: boolean;
  109555. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109556. /** @hidden */
  109557. _areTexturesDirty: boolean;
  109558. }
  109559. /**
  109560. * Define the code related to the clear coat parameters of the pbr material.
  109561. */
  109562. export class PBRClearCoatConfiguration {
  109563. /**
  109564. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109565. * The default fits with a polyurethane material.
  109566. */
  109567. private static readonly _DefaultIndexOfRefraction;
  109568. private _isEnabled;
  109569. /**
  109570. * Defines if the clear coat is enabled in the material.
  109571. */
  109572. isEnabled: boolean;
  109573. /**
  109574. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109575. */
  109576. intensity: number;
  109577. /**
  109578. * Defines the clear coat layer roughness.
  109579. */
  109580. roughness: number;
  109581. private _indexOfRefraction;
  109582. /**
  109583. * Defines the index of refraction of the clear coat.
  109584. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109585. * The default fits with a polyurethane material.
  109586. * Changing the default value is more performance intensive.
  109587. */
  109588. indexOfRefraction: number;
  109589. private _texture;
  109590. /**
  109591. * Stores the clear coat values in a texture.
  109592. */
  109593. texture: Nullable<BaseTexture>;
  109594. private _bumpTexture;
  109595. /**
  109596. * Define the clear coat specific bump texture.
  109597. */
  109598. bumpTexture: Nullable<BaseTexture>;
  109599. private _isTintEnabled;
  109600. /**
  109601. * Defines if the clear coat tint is enabled in the material.
  109602. */
  109603. isTintEnabled: boolean;
  109604. /**
  109605. * Defines the clear coat tint of the material.
  109606. * This is only use if tint is enabled
  109607. */
  109608. tintColor: Color3;
  109609. /**
  109610. * Defines the distance at which the tint color should be found in the
  109611. * clear coat media.
  109612. * This is only use if tint is enabled
  109613. */
  109614. tintColorAtDistance: number;
  109615. /**
  109616. * Defines the clear coat layer thickness.
  109617. * This is only use if tint is enabled
  109618. */
  109619. tintThickness: number;
  109620. private _tintTexture;
  109621. /**
  109622. * Stores the clear tint values in a texture.
  109623. * rgb is tint
  109624. * a is a thickness factor
  109625. */
  109626. tintTexture: Nullable<BaseTexture>;
  109627. /** @hidden */
  109628. private _internalMarkAllSubMeshesAsTexturesDirty;
  109629. /** @hidden */
  109630. _markAllSubMeshesAsTexturesDirty(): void;
  109631. /**
  109632. * Instantiate a new istance of clear coat configuration.
  109633. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109634. */
  109635. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109636. /**
  109637. * Gets wehter the submesh is ready to be used or not.
  109638. * @param defines the list of "defines" to update.
  109639. * @param scene defines the scene the material belongs to.
  109640. * @param engine defines the engine the material belongs to.
  109641. * @param disableBumpMap defines wether the material disables bump or not.
  109642. * @returns - boolean indicating that the submesh is ready or not.
  109643. */
  109644. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109645. /**
  109646. * Checks to see if a texture is used in the material.
  109647. * @param defines the list of "defines" to update.
  109648. * @param scene defines the scene to the material belongs to.
  109649. */
  109650. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109651. /**
  109652. * Binds the material data.
  109653. * @param uniformBuffer defines the Uniform buffer to fill in.
  109654. * @param scene defines the scene the material belongs to.
  109655. * @param engine defines the engine the material belongs to.
  109656. * @param disableBumpMap defines wether the material disables bump or not.
  109657. * @param isFrozen defines wether the material is frozen or not.
  109658. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109659. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109660. */
  109661. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109662. /**
  109663. * Checks to see if a texture is used in the material.
  109664. * @param texture - Base texture to use.
  109665. * @returns - Boolean specifying if a texture is used in the material.
  109666. */
  109667. hasTexture(texture: BaseTexture): boolean;
  109668. /**
  109669. * Returns an array of the actively used textures.
  109670. * @param activeTextures Array of BaseTextures
  109671. */
  109672. getActiveTextures(activeTextures: BaseTexture[]): void;
  109673. /**
  109674. * Returns the animatable textures.
  109675. * @param animatables Array of animatable textures.
  109676. */
  109677. getAnimatables(animatables: IAnimatable[]): void;
  109678. /**
  109679. * Disposes the resources of the material.
  109680. * @param forceDisposeTextures - Forces the disposal of all textures.
  109681. */
  109682. dispose(forceDisposeTextures?: boolean): void;
  109683. /**
  109684. * Get the current class name of the texture useful for serialization or dynamic coding.
  109685. * @returns "PBRClearCoatConfiguration"
  109686. */
  109687. getClassName(): string;
  109688. /**
  109689. * Add fallbacks to the effect fallbacks list.
  109690. * @param defines defines the Base texture to use.
  109691. * @param fallbacks defines the current fallback list.
  109692. * @param currentRank defines the current fallback rank.
  109693. * @returns the new fallback rank.
  109694. */
  109695. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109696. /**
  109697. * Add the required uniforms to the current list.
  109698. * @param uniforms defines the current uniform list.
  109699. */
  109700. static AddUniforms(uniforms: string[]): void;
  109701. /**
  109702. * Add the required samplers to the current list.
  109703. * @param samplers defines the current sampler list.
  109704. */
  109705. static AddSamplers(samplers: string[]): void;
  109706. /**
  109707. * Add the required uniforms to the current buffer.
  109708. * @param uniformBuffer defines the current uniform buffer.
  109709. */
  109710. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109711. /**
  109712. * Makes a duplicate of the current configuration into another one.
  109713. * @param clearCoatConfiguration define the config where to copy the info
  109714. */
  109715. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109716. /**
  109717. * Serializes this clear coat configuration.
  109718. * @returns - An object with the serialized config.
  109719. */
  109720. serialize(): any;
  109721. /**
  109722. * Parses a anisotropy Configuration from a serialized object.
  109723. * @param source - Serialized object.
  109724. * @param scene Defines the scene we are parsing for
  109725. * @param rootUrl Defines the rootUrl to load from
  109726. */
  109727. parse(source: any, scene: Scene, rootUrl: string): void;
  109728. }
  109729. }
  109730. declare module BABYLON {
  109731. /**
  109732. * @hidden
  109733. */
  109734. export interface IMaterialAnisotropicDefines {
  109735. ANISOTROPIC: boolean;
  109736. ANISOTROPIC_TEXTURE: boolean;
  109737. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109738. MAINUV1: boolean;
  109739. _areTexturesDirty: boolean;
  109740. _needUVs: boolean;
  109741. }
  109742. /**
  109743. * Define the code related to the anisotropic parameters of the pbr material.
  109744. */
  109745. export class PBRAnisotropicConfiguration {
  109746. private _isEnabled;
  109747. /**
  109748. * Defines if the anisotropy is enabled in the material.
  109749. */
  109750. isEnabled: boolean;
  109751. /**
  109752. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109753. */
  109754. intensity: number;
  109755. /**
  109756. * Defines if the effect is along the tangents, bitangents or in between.
  109757. * By default, the effect is "strectching" the highlights along the tangents.
  109758. */
  109759. direction: Vector2;
  109760. private _texture;
  109761. /**
  109762. * Stores the anisotropy values in a texture.
  109763. * rg is direction (like normal from -1 to 1)
  109764. * b is a intensity
  109765. */
  109766. texture: Nullable<BaseTexture>;
  109767. /** @hidden */
  109768. private _internalMarkAllSubMeshesAsTexturesDirty;
  109769. /** @hidden */
  109770. _markAllSubMeshesAsTexturesDirty(): void;
  109771. /**
  109772. * Instantiate a new istance of anisotropy configuration.
  109773. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109774. */
  109775. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109776. /**
  109777. * Specifies that the submesh is ready to be used.
  109778. * @param defines the list of "defines" to update.
  109779. * @param scene defines the scene the material belongs to.
  109780. * @returns - boolean indicating that the submesh is ready or not.
  109781. */
  109782. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109783. /**
  109784. * Checks to see if a texture is used in the material.
  109785. * @param defines the list of "defines" to update.
  109786. * @param mesh the mesh we are preparing the defines for.
  109787. * @param scene defines the scene the material belongs to.
  109788. */
  109789. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109790. /**
  109791. * Binds the material data.
  109792. * @param uniformBuffer defines the Uniform buffer to fill in.
  109793. * @param scene defines the scene the material belongs to.
  109794. * @param isFrozen defines wether the material is frozen or not.
  109795. */
  109796. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109797. /**
  109798. * Checks to see if a texture is used in the material.
  109799. * @param texture - Base texture to use.
  109800. * @returns - Boolean specifying if a texture is used in the material.
  109801. */
  109802. hasTexture(texture: BaseTexture): boolean;
  109803. /**
  109804. * Returns an array of the actively used textures.
  109805. * @param activeTextures Array of BaseTextures
  109806. */
  109807. getActiveTextures(activeTextures: BaseTexture[]): void;
  109808. /**
  109809. * Returns the animatable textures.
  109810. * @param animatables Array of animatable textures.
  109811. */
  109812. getAnimatables(animatables: IAnimatable[]): void;
  109813. /**
  109814. * Disposes the resources of the material.
  109815. * @param forceDisposeTextures - Forces the disposal of all textures.
  109816. */
  109817. dispose(forceDisposeTextures?: boolean): void;
  109818. /**
  109819. * Get the current class name of the texture useful for serialization or dynamic coding.
  109820. * @returns "PBRAnisotropicConfiguration"
  109821. */
  109822. getClassName(): string;
  109823. /**
  109824. * Add fallbacks to the effect fallbacks list.
  109825. * @param defines defines the Base texture to use.
  109826. * @param fallbacks defines the current fallback list.
  109827. * @param currentRank defines the current fallback rank.
  109828. * @returns the new fallback rank.
  109829. */
  109830. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109831. /**
  109832. * Add the required uniforms to the current list.
  109833. * @param uniforms defines the current uniform list.
  109834. */
  109835. static AddUniforms(uniforms: string[]): void;
  109836. /**
  109837. * Add the required uniforms to the current buffer.
  109838. * @param uniformBuffer defines the current uniform buffer.
  109839. */
  109840. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109841. /**
  109842. * Add the required samplers to the current list.
  109843. * @param samplers defines the current sampler list.
  109844. */
  109845. static AddSamplers(samplers: string[]): void;
  109846. /**
  109847. * Makes a duplicate of the current configuration into another one.
  109848. * @param anisotropicConfiguration define the config where to copy the info
  109849. */
  109850. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109851. /**
  109852. * Serializes this anisotropy configuration.
  109853. * @returns - An object with the serialized config.
  109854. */
  109855. serialize(): any;
  109856. /**
  109857. * Parses a anisotropy Configuration from a serialized object.
  109858. * @param source - Serialized object.
  109859. * @param scene Defines the scene we are parsing for
  109860. * @param rootUrl Defines the rootUrl to load from
  109861. */
  109862. parse(source: any, scene: Scene, rootUrl: string): void;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /**
  109867. * @hidden
  109868. */
  109869. export interface IMaterialBRDFDefines {
  109870. BRDF_V_HEIGHT_CORRELATED: boolean;
  109871. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109872. SPHERICAL_HARMONICS: boolean;
  109873. /** @hidden */
  109874. _areMiscDirty: boolean;
  109875. }
  109876. /**
  109877. * Define the code related to the BRDF parameters of the pbr material.
  109878. */
  109879. export class PBRBRDFConfiguration {
  109880. /**
  109881. * Default value used for the energy conservation.
  109882. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109883. */
  109884. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109885. /**
  109886. * Default value used for the Smith Visibility Height Correlated mode.
  109887. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109888. */
  109889. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109890. /**
  109891. * Default value used for the IBL diffuse part.
  109892. * This can help switching back to the polynomials mode globally which is a tiny bit
  109893. * less GPU intensive at the drawback of a lower quality.
  109894. */
  109895. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109896. private _useEnergyConservation;
  109897. /**
  109898. * Defines if the material uses energy conservation.
  109899. */
  109900. useEnergyConservation: boolean;
  109901. private _useSmithVisibilityHeightCorrelated;
  109902. /**
  109903. * LEGACY Mode set to false
  109904. * Defines if the material uses height smith correlated visibility term.
  109905. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109906. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109907. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109908. * Not relying on height correlated will also disable energy conservation.
  109909. */
  109910. useSmithVisibilityHeightCorrelated: boolean;
  109911. private _useSphericalHarmonics;
  109912. /**
  109913. * LEGACY Mode set to false
  109914. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109915. * diffuse part of the IBL.
  109916. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109917. * to the ground truth.
  109918. */
  109919. useSphericalHarmonics: boolean;
  109920. /** @hidden */
  109921. private _internalMarkAllSubMeshesAsMiscDirty;
  109922. /** @hidden */
  109923. _markAllSubMeshesAsMiscDirty(): void;
  109924. /**
  109925. * Instantiate a new istance of clear coat configuration.
  109926. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109927. */
  109928. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109929. /**
  109930. * Checks to see if a texture is used in the material.
  109931. * @param defines the list of "defines" to update.
  109932. */
  109933. prepareDefines(defines: IMaterialBRDFDefines): void;
  109934. /**
  109935. * Get the current class name of the texture useful for serialization or dynamic coding.
  109936. * @returns "PBRClearCoatConfiguration"
  109937. */
  109938. getClassName(): string;
  109939. /**
  109940. * Makes a duplicate of the current configuration into another one.
  109941. * @param brdfConfiguration define the config where to copy the info
  109942. */
  109943. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109944. /**
  109945. * Serializes this BRDF configuration.
  109946. * @returns - An object with the serialized config.
  109947. */
  109948. serialize(): any;
  109949. /**
  109950. * Parses a anisotropy Configuration from a serialized object.
  109951. * @param source - Serialized object.
  109952. * @param scene Defines the scene we are parsing for
  109953. * @param rootUrl Defines the rootUrl to load from
  109954. */
  109955. parse(source: any, scene: Scene, rootUrl: string): void;
  109956. }
  109957. }
  109958. declare module BABYLON {
  109959. /**
  109960. * @hidden
  109961. */
  109962. export interface IMaterialSheenDefines {
  109963. SHEEN: boolean;
  109964. SHEEN_TEXTURE: boolean;
  109965. SHEEN_TEXTUREDIRECTUV: number;
  109966. SHEEN_LINKWITHALBEDO: boolean;
  109967. /** @hidden */
  109968. _areTexturesDirty: boolean;
  109969. }
  109970. /**
  109971. * Define the code related to the Sheen parameters of the pbr material.
  109972. */
  109973. export class PBRSheenConfiguration {
  109974. private _isEnabled;
  109975. /**
  109976. * Defines if the material uses sheen.
  109977. */
  109978. isEnabled: boolean;
  109979. private _linkSheenWithAlbedo;
  109980. /**
  109981. * Defines if the sheen is linked to the sheen color.
  109982. */
  109983. linkSheenWithAlbedo: boolean;
  109984. /**
  109985. * Defines the sheen intensity.
  109986. */
  109987. intensity: number;
  109988. /**
  109989. * Defines the sheen color.
  109990. */
  109991. color: Color3;
  109992. private _texture;
  109993. /**
  109994. * Stores the sheen tint values in a texture.
  109995. * rgb is tint
  109996. * a is a intensity
  109997. */
  109998. texture: Nullable<BaseTexture>;
  109999. /** @hidden */
  110000. private _internalMarkAllSubMeshesAsTexturesDirty;
  110001. /** @hidden */
  110002. _markAllSubMeshesAsTexturesDirty(): void;
  110003. /**
  110004. * Instantiate a new istance of clear coat configuration.
  110005. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110006. */
  110007. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110008. /**
  110009. * Specifies that the submesh is ready to be used.
  110010. * @param defines the list of "defines" to update.
  110011. * @param scene defines the scene the material belongs to.
  110012. * @returns - boolean indicating that the submesh is ready or not.
  110013. */
  110014. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110015. /**
  110016. * Checks to see if a texture is used in the material.
  110017. * @param defines the list of "defines" to update.
  110018. * @param scene defines the scene the material belongs to.
  110019. */
  110020. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110021. /**
  110022. * Binds the material data.
  110023. * @param uniformBuffer defines the Uniform buffer to fill in.
  110024. * @param scene defines the scene the material belongs to.
  110025. * @param isFrozen defines wether the material is frozen or not.
  110026. */
  110027. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110028. /**
  110029. * Checks to see if a texture is used in the material.
  110030. * @param texture - Base texture to use.
  110031. * @returns - Boolean specifying if a texture is used in the material.
  110032. */
  110033. hasTexture(texture: BaseTexture): boolean;
  110034. /**
  110035. * Returns an array of the actively used textures.
  110036. * @param activeTextures Array of BaseTextures
  110037. */
  110038. getActiveTextures(activeTextures: BaseTexture[]): void;
  110039. /**
  110040. * Returns the animatable textures.
  110041. * @param animatables Array of animatable textures.
  110042. */
  110043. getAnimatables(animatables: IAnimatable[]): void;
  110044. /**
  110045. * Disposes the resources of the material.
  110046. * @param forceDisposeTextures - Forces the disposal of all textures.
  110047. */
  110048. dispose(forceDisposeTextures?: boolean): void;
  110049. /**
  110050. * Get the current class name of the texture useful for serialization or dynamic coding.
  110051. * @returns "PBRSheenConfiguration"
  110052. */
  110053. getClassName(): string;
  110054. /**
  110055. * Add fallbacks to the effect fallbacks list.
  110056. * @param defines defines the Base texture to use.
  110057. * @param fallbacks defines the current fallback list.
  110058. * @param currentRank defines the current fallback rank.
  110059. * @returns the new fallback rank.
  110060. */
  110061. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110062. /**
  110063. * Add the required uniforms to the current list.
  110064. * @param uniforms defines the current uniform list.
  110065. */
  110066. static AddUniforms(uniforms: string[]): void;
  110067. /**
  110068. * Add the required uniforms to the current buffer.
  110069. * @param uniformBuffer defines the current uniform buffer.
  110070. */
  110071. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110072. /**
  110073. * Add the required samplers to the current list.
  110074. * @param samplers defines the current sampler list.
  110075. */
  110076. static AddSamplers(samplers: string[]): void;
  110077. /**
  110078. * Makes a duplicate of the current configuration into another one.
  110079. * @param sheenConfiguration define the config where to copy the info
  110080. */
  110081. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110082. /**
  110083. * Serializes this BRDF configuration.
  110084. * @returns - An object with the serialized config.
  110085. */
  110086. serialize(): any;
  110087. /**
  110088. * Parses a anisotropy Configuration from a serialized object.
  110089. * @param source - Serialized object.
  110090. * @param scene Defines the scene we are parsing for
  110091. * @param rootUrl Defines the rootUrl to load from
  110092. */
  110093. parse(source: any, scene: Scene, rootUrl: string): void;
  110094. }
  110095. }
  110096. declare module BABYLON {
  110097. /**
  110098. * @hidden
  110099. */
  110100. export interface IMaterialSubSurfaceDefines {
  110101. SUBSURFACE: boolean;
  110102. SS_REFRACTION: boolean;
  110103. SS_TRANSLUCENCY: boolean;
  110104. SS_SCATERRING: boolean;
  110105. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110106. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110107. SS_REFRACTIONMAP_3D: boolean;
  110108. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110109. SS_LODINREFRACTIONALPHA: boolean;
  110110. SS_GAMMAREFRACTION: boolean;
  110111. SS_RGBDREFRACTION: boolean;
  110112. SS_LINEARSPECULARREFRACTION: boolean;
  110113. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110114. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110115. /** @hidden */
  110116. _areTexturesDirty: boolean;
  110117. }
  110118. /**
  110119. * Define the code related to the sub surface parameters of the pbr material.
  110120. */
  110121. export class PBRSubSurfaceConfiguration {
  110122. private _isRefractionEnabled;
  110123. /**
  110124. * Defines if the refraction is enabled in the material.
  110125. */
  110126. isRefractionEnabled: boolean;
  110127. private _isTranslucencyEnabled;
  110128. /**
  110129. * Defines if the translucency is enabled in the material.
  110130. */
  110131. isTranslucencyEnabled: boolean;
  110132. private _isScatteringEnabled;
  110133. /**
  110134. * Defines the refraction intensity of the material.
  110135. * The refraction when enabled replaces the Diffuse part of the material.
  110136. * The intensity helps transitionning between diffuse and refraction.
  110137. */
  110138. refractionIntensity: number;
  110139. /**
  110140. * Defines the translucency intensity of the material.
  110141. * When translucency has been enabled, this defines how much of the "translucency"
  110142. * is addded to the diffuse part of the material.
  110143. */
  110144. translucencyIntensity: number;
  110145. /**
  110146. * Defines the scattering intensity of the material.
  110147. * When scattering has been enabled, this defines how much of the "scattered light"
  110148. * is addded to the diffuse part of the material.
  110149. */
  110150. scatteringIntensity: number;
  110151. private _thicknessTexture;
  110152. /**
  110153. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110154. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110155. * 0 would mean minimumThickness
  110156. * 1 would mean maximumThickness
  110157. * The other channels might be use as a mask to vary the different effects intensity.
  110158. */
  110159. thicknessTexture: Nullable<BaseTexture>;
  110160. private _refractionTexture;
  110161. /**
  110162. * Defines the texture to use for refraction.
  110163. */
  110164. refractionTexture: Nullable<BaseTexture>;
  110165. private _indexOfRefraction;
  110166. /**
  110167. * Defines the index of refraction used in the material.
  110168. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110169. */
  110170. indexOfRefraction: number;
  110171. private _invertRefractionY;
  110172. /**
  110173. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110174. */
  110175. invertRefractionY: boolean;
  110176. private _linkRefractionWithTransparency;
  110177. /**
  110178. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110179. * Materials half opaque for instance using refraction could benefit from this control.
  110180. */
  110181. linkRefractionWithTransparency: boolean;
  110182. /**
  110183. * Defines the minimum thickness stored in the thickness map.
  110184. * If no thickness map is defined, this value will be used to simulate thickness.
  110185. */
  110186. minimumThickness: number;
  110187. /**
  110188. * Defines the maximum thickness stored in the thickness map.
  110189. */
  110190. maximumThickness: number;
  110191. /**
  110192. * Defines the volume tint of the material.
  110193. * This is used for both translucency and scattering.
  110194. */
  110195. tintColor: Color3;
  110196. /**
  110197. * Defines the distance at which the tint color should be found in the media.
  110198. * This is used for refraction only.
  110199. */
  110200. tintColorAtDistance: number;
  110201. /**
  110202. * Defines how far each channel transmit through the media.
  110203. * It is defined as a color to simplify it selection.
  110204. */
  110205. diffusionDistance: Color3;
  110206. private _useMaskFromThicknessTexture;
  110207. /**
  110208. * Stores the intensity of the different subsurface effects in the thickness texture.
  110209. * * the green channel is the translucency intensity.
  110210. * * the blue channel is the scattering intensity.
  110211. * * the alpha channel is the refraction intensity.
  110212. */
  110213. useMaskFromThicknessTexture: boolean;
  110214. /** @hidden */
  110215. private _internalMarkAllSubMeshesAsTexturesDirty;
  110216. /** @hidden */
  110217. _markAllSubMeshesAsTexturesDirty(): void;
  110218. /**
  110219. * Instantiate a new istance of sub surface configuration.
  110220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110221. */
  110222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110223. /**
  110224. * Gets wehter the submesh is ready to be used or not.
  110225. * @param defines the list of "defines" to update.
  110226. * @param scene defines the scene the material belongs to.
  110227. * @returns - boolean indicating that the submesh is ready or not.
  110228. */
  110229. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110230. /**
  110231. * Checks to see if a texture is used in the material.
  110232. * @param defines the list of "defines" to update.
  110233. * @param scene defines the scene to the material belongs to.
  110234. */
  110235. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110236. /**
  110237. * Binds the material data.
  110238. * @param uniformBuffer defines the Uniform buffer to fill in.
  110239. * @param scene defines the scene the material belongs to.
  110240. * @param engine defines the engine the material belongs to.
  110241. * @param isFrozen defines wether the material is frozen or not.
  110242. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110243. */
  110244. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110245. /**
  110246. * Unbinds the material from the mesh.
  110247. * @param activeEffect defines the effect that should be unbound from.
  110248. * @returns true if unbound, otherwise false
  110249. */
  110250. unbind(activeEffect: Effect): boolean;
  110251. /**
  110252. * Returns the texture used for refraction or null if none is used.
  110253. * @param scene defines the scene the material belongs to.
  110254. * @returns - Refraction texture if present. If no refraction texture and refraction
  110255. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110256. */
  110257. private _getRefractionTexture;
  110258. /**
  110259. * Returns true if alpha blending should be disabled.
  110260. */
  110261. readonly disableAlphaBlending: boolean;
  110262. /**
  110263. * Fills the list of render target textures.
  110264. * @param renderTargets the list of render targets to update
  110265. */
  110266. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110267. /**
  110268. * Checks to see if a texture is used in the material.
  110269. * @param texture - Base texture to use.
  110270. * @returns - Boolean specifying if a texture is used in the material.
  110271. */
  110272. hasTexture(texture: BaseTexture): boolean;
  110273. /**
  110274. * Gets a boolean indicating that current material needs to register RTT
  110275. * @returns true if this uses a render target otherwise false.
  110276. */
  110277. hasRenderTargetTextures(): boolean;
  110278. /**
  110279. * Returns an array of the actively used textures.
  110280. * @param activeTextures Array of BaseTextures
  110281. */
  110282. getActiveTextures(activeTextures: BaseTexture[]): void;
  110283. /**
  110284. * Returns the animatable textures.
  110285. * @param animatables Array of animatable textures.
  110286. */
  110287. getAnimatables(animatables: IAnimatable[]): void;
  110288. /**
  110289. * Disposes the resources of the material.
  110290. * @param forceDisposeTextures - Forces the disposal of all textures.
  110291. */
  110292. dispose(forceDisposeTextures?: boolean): void;
  110293. /**
  110294. * Get the current class name of the texture useful for serialization or dynamic coding.
  110295. * @returns "PBRSubSurfaceConfiguration"
  110296. */
  110297. getClassName(): string;
  110298. /**
  110299. * Add fallbacks to the effect fallbacks list.
  110300. * @param defines defines the Base texture to use.
  110301. * @param fallbacks defines the current fallback list.
  110302. * @param currentRank defines the current fallback rank.
  110303. * @returns the new fallback rank.
  110304. */
  110305. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110306. /**
  110307. * Add the required uniforms to the current list.
  110308. * @param uniforms defines the current uniform list.
  110309. */
  110310. static AddUniforms(uniforms: string[]): void;
  110311. /**
  110312. * Add the required samplers to the current list.
  110313. * @param samplers defines the current sampler list.
  110314. */
  110315. static AddSamplers(samplers: string[]): void;
  110316. /**
  110317. * Add the required uniforms to the current buffer.
  110318. * @param uniformBuffer defines the current uniform buffer.
  110319. */
  110320. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110321. /**
  110322. * Makes a duplicate of the current configuration into another one.
  110323. * @param configuration define the config where to copy the info
  110324. */
  110325. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110326. /**
  110327. * Serializes this Sub Surface configuration.
  110328. * @returns - An object with the serialized config.
  110329. */
  110330. serialize(): any;
  110331. /**
  110332. * Parses a anisotropy Configuration from a serialized object.
  110333. * @param source - Serialized object.
  110334. * @param scene Defines the scene we are parsing for
  110335. * @param rootUrl Defines the rootUrl to load from
  110336. */
  110337. parse(source: any, scene: Scene, rootUrl: string): void;
  110338. }
  110339. }
  110340. declare module BABYLON {
  110341. /** @hidden */
  110342. export var pbrFragmentDeclaration: {
  110343. name: string;
  110344. shader: string;
  110345. };
  110346. }
  110347. declare module BABYLON {
  110348. /** @hidden */
  110349. export var pbrUboDeclaration: {
  110350. name: string;
  110351. shader: string;
  110352. };
  110353. }
  110354. declare module BABYLON {
  110355. /** @hidden */
  110356. export var pbrFragmentExtraDeclaration: {
  110357. name: string;
  110358. shader: string;
  110359. };
  110360. }
  110361. declare module BABYLON {
  110362. /** @hidden */
  110363. export var pbrFragmentSamplersDeclaration: {
  110364. name: string;
  110365. shader: string;
  110366. };
  110367. }
  110368. declare module BABYLON {
  110369. /** @hidden */
  110370. export var pbrHelperFunctions: {
  110371. name: string;
  110372. shader: string;
  110373. };
  110374. }
  110375. declare module BABYLON {
  110376. /** @hidden */
  110377. export var harmonicsFunctions: {
  110378. name: string;
  110379. shader: string;
  110380. };
  110381. }
  110382. declare module BABYLON {
  110383. /** @hidden */
  110384. export var pbrDirectLightingSetupFunctions: {
  110385. name: string;
  110386. shader: string;
  110387. };
  110388. }
  110389. declare module BABYLON {
  110390. /** @hidden */
  110391. export var pbrDirectLightingFalloffFunctions: {
  110392. name: string;
  110393. shader: string;
  110394. };
  110395. }
  110396. declare module BABYLON {
  110397. /** @hidden */
  110398. export var pbrBRDFFunctions: {
  110399. name: string;
  110400. shader: string;
  110401. };
  110402. }
  110403. declare module BABYLON {
  110404. /** @hidden */
  110405. export var pbrDirectLightingFunctions: {
  110406. name: string;
  110407. shader: string;
  110408. };
  110409. }
  110410. declare module BABYLON {
  110411. /** @hidden */
  110412. export var pbrIBLFunctions: {
  110413. name: string;
  110414. shader: string;
  110415. };
  110416. }
  110417. declare module BABYLON {
  110418. /** @hidden */
  110419. export var pbrDebug: {
  110420. name: string;
  110421. shader: string;
  110422. };
  110423. }
  110424. declare module BABYLON {
  110425. /** @hidden */
  110426. export var pbrPixelShader: {
  110427. name: string;
  110428. shader: string;
  110429. };
  110430. }
  110431. declare module BABYLON {
  110432. /** @hidden */
  110433. export var pbrVertexDeclaration: {
  110434. name: string;
  110435. shader: string;
  110436. };
  110437. }
  110438. declare module BABYLON {
  110439. /** @hidden */
  110440. export var pbrVertexShader: {
  110441. name: string;
  110442. shader: string;
  110443. };
  110444. }
  110445. declare module BABYLON {
  110446. /**
  110447. * Manages the defines for the PBR Material.
  110448. * @hidden
  110449. */
  110450. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110451. PBR: boolean;
  110452. MAINUV1: boolean;
  110453. MAINUV2: boolean;
  110454. UV1: boolean;
  110455. UV2: boolean;
  110456. ALBEDO: boolean;
  110457. ALBEDODIRECTUV: number;
  110458. VERTEXCOLOR: boolean;
  110459. AMBIENT: boolean;
  110460. AMBIENTDIRECTUV: number;
  110461. AMBIENTINGRAYSCALE: boolean;
  110462. OPACITY: boolean;
  110463. VERTEXALPHA: boolean;
  110464. OPACITYDIRECTUV: number;
  110465. OPACITYRGB: boolean;
  110466. ALPHATEST: boolean;
  110467. DEPTHPREPASS: boolean;
  110468. ALPHABLEND: boolean;
  110469. ALPHAFROMALBEDO: boolean;
  110470. ALPHATESTVALUE: string;
  110471. SPECULAROVERALPHA: boolean;
  110472. RADIANCEOVERALPHA: boolean;
  110473. ALPHAFRESNEL: boolean;
  110474. LINEARALPHAFRESNEL: boolean;
  110475. PREMULTIPLYALPHA: boolean;
  110476. EMISSIVE: boolean;
  110477. EMISSIVEDIRECTUV: number;
  110478. REFLECTIVITY: boolean;
  110479. REFLECTIVITYDIRECTUV: number;
  110480. SPECULARTERM: boolean;
  110481. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110482. MICROSURFACEAUTOMATIC: boolean;
  110483. LODBASEDMICROSFURACE: boolean;
  110484. MICROSURFACEMAP: boolean;
  110485. MICROSURFACEMAPDIRECTUV: number;
  110486. METALLICWORKFLOW: boolean;
  110487. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110488. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110489. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110490. AOSTOREINMETALMAPRED: boolean;
  110491. ENVIRONMENTBRDF: boolean;
  110492. ENVIRONMENTBRDF_RGBD: boolean;
  110493. NORMAL: boolean;
  110494. TANGENT: boolean;
  110495. BUMP: boolean;
  110496. BUMPDIRECTUV: number;
  110497. OBJECTSPACE_NORMALMAP: boolean;
  110498. PARALLAX: boolean;
  110499. PARALLAXOCCLUSION: boolean;
  110500. NORMALXYSCALE: boolean;
  110501. LIGHTMAP: boolean;
  110502. LIGHTMAPDIRECTUV: number;
  110503. USELIGHTMAPASSHADOWMAP: boolean;
  110504. GAMMALIGHTMAP: boolean;
  110505. REFLECTION: boolean;
  110506. REFLECTIONMAP_3D: boolean;
  110507. REFLECTIONMAP_SPHERICAL: boolean;
  110508. REFLECTIONMAP_PLANAR: boolean;
  110509. REFLECTIONMAP_CUBIC: boolean;
  110510. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110511. REFLECTIONMAP_PROJECTION: boolean;
  110512. REFLECTIONMAP_SKYBOX: boolean;
  110513. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110514. REFLECTIONMAP_EXPLICIT: boolean;
  110515. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110516. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110517. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110518. INVERTCUBICMAP: boolean;
  110519. USESPHERICALFROMREFLECTIONMAP: boolean;
  110520. USEIRRADIANCEMAP: boolean;
  110521. SPHERICAL_HARMONICS: boolean;
  110522. USESPHERICALINVERTEX: boolean;
  110523. REFLECTIONMAP_OPPOSITEZ: boolean;
  110524. LODINREFLECTIONALPHA: boolean;
  110525. GAMMAREFLECTION: boolean;
  110526. RGBDREFLECTION: boolean;
  110527. LINEARSPECULARREFLECTION: boolean;
  110528. RADIANCEOCCLUSION: boolean;
  110529. HORIZONOCCLUSION: boolean;
  110530. INSTANCES: boolean;
  110531. NUM_BONE_INFLUENCERS: number;
  110532. BonesPerMesh: number;
  110533. BONETEXTURE: boolean;
  110534. NONUNIFORMSCALING: boolean;
  110535. MORPHTARGETS: boolean;
  110536. MORPHTARGETS_NORMAL: boolean;
  110537. MORPHTARGETS_TANGENT: boolean;
  110538. MORPHTARGETS_UV: boolean;
  110539. NUM_MORPH_INFLUENCERS: number;
  110540. IMAGEPROCESSING: boolean;
  110541. VIGNETTE: boolean;
  110542. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110543. VIGNETTEBLENDMODEOPAQUE: boolean;
  110544. TONEMAPPING: boolean;
  110545. TONEMAPPING_ACES: boolean;
  110546. CONTRAST: boolean;
  110547. COLORCURVES: boolean;
  110548. COLORGRADING: boolean;
  110549. COLORGRADING3D: boolean;
  110550. SAMPLER3DGREENDEPTH: boolean;
  110551. SAMPLER3DBGRMAP: boolean;
  110552. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110553. EXPOSURE: boolean;
  110554. MULTIVIEW: boolean;
  110555. USEPHYSICALLIGHTFALLOFF: boolean;
  110556. USEGLTFLIGHTFALLOFF: boolean;
  110557. TWOSIDEDLIGHTING: boolean;
  110558. SHADOWFLOAT: boolean;
  110559. CLIPPLANE: boolean;
  110560. CLIPPLANE2: boolean;
  110561. CLIPPLANE3: boolean;
  110562. CLIPPLANE4: boolean;
  110563. POINTSIZE: boolean;
  110564. FOG: boolean;
  110565. LOGARITHMICDEPTH: boolean;
  110566. FORCENORMALFORWARD: boolean;
  110567. SPECULARAA: boolean;
  110568. CLEARCOAT: boolean;
  110569. CLEARCOAT_DEFAULTIOR: boolean;
  110570. CLEARCOAT_TEXTURE: boolean;
  110571. CLEARCOAT_TEXTUREDIRECTUV: number;
  110572. CLEARCOAT_BUMP: boolean;
  110573. CLEARCOAT_BUMPDIRECTUV: number;
  110574. CLEARCOAT_TINT: boolean;
  110575. CLEARCOAT_TINT_TEXTURE: boolean;
  110576. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110577. ANISOTROPIC: boolean;
  110578. ANISOTROPIC_TEXTURE: boolean;
  110579. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110580. BRDF_V_HEIGHT_CORRELATED: boolean;
  110581. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110582. SHEEN: boolean;
  110583. SHEEN_TEXTURE: boolean;
  110584. SHEEN_TEXTUREDIRECTUV: number;
  110585. SHEEN_LINKWITHALBEDO: boolean;
  110586. SUBSURFACE: boolean;
  110587. SS_REFRACTION: boolean;
  110588. SS_TRANSLUCENCY: boolean;
  110589. SS_SCATERRING: boolean;
  110590. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110591. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110592. SS_REFRACTIONMAP_3D: boolean;
  110593. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110594. SS_LODINREFRACTIONALPHA: boolean;
  110595. SS_GAMMAREFRACTION: boolean;
  110596. SS_RGBDREFRACTION: boolean;
  110597. SS_LINEARSPECULARREFRACTION: boolean;
  110598. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110599. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110600. UNLIT: boolean;
  110601. DEBUGMODE: number;
  110602. /**
  110603. * Initializes the PBR Material defines.
  110604. */
  110605. constructor();
  110606. /**
  110607. * Resets the PBR Material defines.
  110608. */
  110609. reset(): void;
  110610. }
  110611. /**
  110612. * The Physically based material base class of BJS.
  110613. *
  110614. * This offers the main features of a standard PBR material.
  110615. * For more information, please refer to the documentation :
  110616. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110617. */
  110618. export abstract class PBRBaseMaterial extends PushMaterial {
  110619. /**
  110620. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110621. */
  110622. static readonly PBRMATERIAL_OPAQUE: number;
  110623. /**
  110624. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110625. */
  110626. static readonly PBRMATERIAL_ALPHATEST: number;
  110627. /**
  110628. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110629. */
  110630. static readonly PBRMATERIAL_ALPHABLEND: number;
  110631. /**
  110632. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110633. * They are also discarded below the alpha cutoff threshold to improve performances.
  110634. */
  110635. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110636. /**
  110637. * Defines the default value of how much AO map is occluding the analytical lights
  110638. * (point spot...).
  110639. */
  110640. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110641. /**
  110642. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110643. */
  110644. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110645. /**
  110646. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110647. * to enhance interoperability with other engines.
  110648. */
  110649. static readonly LIGHTFALLOFF_GLTF: number;
  110650. /**
  110651. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110652. * to enhance interoperability with other materials.
  110653. */
  110654. static readonly LIGHTFALLOFF_STANDARD: number;
  110655. /**
  110656. * Intensity of the direct lights e.g. the four lights available in your scene.
  110657. * This impacts both the direct diffuse and specular highlights.
  110658. */
  110659. protected _directIntensity: number;
  110660. /**
  110661. * Intensity of the emissive part of the material.
  110662. * This helps controlling the emissive effect without modifying the emissive color.
  110663. */
  110664. protected _emissiveIntensity: number;
  110665. /**
  110666. * Intensity of the environment e.g. how much the environment will light the object
  110667. * either through harmonics for rough material or through the refelction for shiny ones.
  110668. */
  110669. protected _environmentIntensity: number;
  110670. /**
  110671. * This is a special control allowing the reduction of the specular highlights coming from the
  110672. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110673. */
  110674. protected _specularIntensity: number;
  110675. /**
  110676. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110677. */
  110678. private _lightingInfos;
  110679. /**
  110680. * Debug Control allowing disabling the bump map on this material.
  110681. */
  110682. protected _disableBumpMap: boolean;
  110683. /**
  110684. * AKA Diffuse Texture in standard nomenclature.
  110685. */
  110686. protected _albedoTexture: Nullable<BaseTexture>;
  110687. /**
  110688. * AKA Occlusion Texture in other nomenclature.
  110689. */
  110690. protected _ambientTexture: Nullable<BaseTexture>;
  110691. /**
  110692. * AKA Occlusion Texture Intensity in other nomenclature.
  110693. */
  110694. protected _ambientTextureStrength: number;
  110695. /**
  110696. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110697. * 1 means it completely occludes it
  110698. * 0 mean it has no impact
  110699. */
  110700. protected _ambientTextureImpactOnAnalyticalLights: number;
  110701. /**
  110702. * Stores the alpha values in a texture.
  110703. */
  110704. protected _opacityTexture: Nullable<BaseTexture>;
  110705. /**
  110706. * Stores the reflection values in a texture.
  110707. */
  110708. protected _reflectionTexture: Nullable<BaseTexture>;
  110709. /**
  110710. * Stores the emissive values in a texture.
  110711. */
  110712. protected _emissiveTexture: Nullable<BaseTexture>;
  110713. /**
  110714. * AKA Specular texture in other nomenclature.
  110715. */
  110716. protected _reflectivityTexture: Nullable<BaseTexture>;
  110717. /**
  110718. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110719. */
  110720. protected _metallicTexture: Nullable<BaseTexture>;
  110721. /**
  110722. * Specifies the metallic scalar of the metallic/roughness workflow.
  110723. * Can also be used to scale the metalness values of the metallic texture.
  110724. */
  110725. protected _metallic: Nullable<number>;
  110726. /**
  110727. * Specifies the roughness scalar of the metallic/roughness workflow.
  110728. * Can also be used to scale the roughness values of the metallic texture.
  110729. */
  110730. protected _roughness: Nullable<number>;
  110731. /**
  110732. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110733. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110734. */
  110735. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110736. /**
  110737. * Stores surface normal data used to displace a mesh in a texture.
  110738. */
  110739. protected _bumpTexture: Nullable<BaseTexture>;
  110740. /**
  110741. * Stores the pre-calculated light information of a mesh in a texture.
  110742. */
  110743. protected _lightmapTexture: Nullable<BaseTexture>;
  110744. /**
  110745. * The color of a material in ambient lighting.
  110746. */
  110747. protected _ambientColor: Color3;
  110748. /**
  110749. * AKA Diffuse Color in other nomenclature.
  110750. */
  110751. protected _albedoColor: Color3;
  110752. /**
  110753. * AKA Specular Color in other nomenclature.
  110754. */
  110755. protected _reflectivityColor: Color3;
  110756. /**
  110757. * The color applied when light is reflected from a material.
  110758. */
  110759. protected _reflectionColor: Color3;
  110760. /**
  110761. * The color applied when light is emitted from a material.
  110762. */
  110763. protected _emissiveColor: Color3;
  110764. /**
  110765. * AKA Glossiness in other nomenclature.
  110766. */
  110767. protected _microSurface: number;
  110768. /**
  110769. * Specifies that the material will use the light map as a show map.
  110770. */
  110771. protected _useLightmapAsShadowmap: boolean;
  110772. /**
  110773. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110774. * makes the reflect vector face the model (under horizon).
  110775. */
  110776. protected _useHorizonOcclusion: boolean;
  110777. /**
  110778. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110779. * too much the area relying on ambient texture to define their ambient occlusion.
  110780. */
  110781. protected _useRadianceOcclusion: boolean;
  110782. /**
  110783. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110784. */
  110785. protected _useAlphaFromAlbedoTexture: boolean;
  110786. /**
  110787. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110788. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110789. */
  110790. protected _useSpecularOverAlpha: boolean;
  110791. /**
  110792. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110793. */
  110794. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110795. /**
  110796. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110797. */
  110798. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110799. /**
  110800. * Specifies if the metallic texture contains the roughness information in its green channel.
  110801. */
  110802. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110803. /**
  110804. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110805. */
  110806. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110807. /**
  110808. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110809. */
  110810. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110811. /**
  110812. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110813. */
  110814. protected _useAmbientInGrayScale: boolean;
  110815. /**
  110816. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110817. * The material will try to infer what glossiness each pixel should be.
  110818. */
  110819. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110820. /**
  110821. * Defines the falloff type used in this material.
  110822. * It by default is Physical.
  110823. */
  110824. protected _lightFalloff: number;
  110825. /**
  110826. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110827. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110828. */
  110829. protected _useRadianceOverAlpha: boolean;
  110830. /**
  110831. * Allows using an object space normal map (instead of tangent space).
  110832. */
  110833. protected _useObjectSpaceNormalMap: boolean;
  110834. /**
  110835. * Allows using the bump map in parallax mode.
  110836. */
  110837. protected _useParallax: boolean;
  110838. /**
  110839. * Allows using the bump map in parallax occlusion mode.
  110840. */
  110841. protected _useParallaxOcclusion: boolean;
  110842. /**
  110843. * Controls the scale bias of the parallax mode.
  110844. */
  110845. protected _parallaxScaleBias: number;
  110846. /**
  110847. * If sets to true, disables all the lights affecting the material.
  110848. */
  110849. protected _disableLighting: boolean;
  110850. /**
  110851. * Number of Simultaneous lights allowed on the material.
  110852. */
  110853. protected _maxSimultaneousLights: number;
  110854. /**
  110855. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110856. */
  110857. protected _invertNormalMapX: boolean;
  110858. /**
  110859. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110860. */
  110861. protected _invertNormalMapY: boolean;
  110862. /**
  110863. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110864. */
  110865. protected _twoSidedLighting: boolean;
  110866. /**
  110867. * Defines the alpha limits in alpha test mode.
  110868. */
  110869. protected _alphaCutOff: number;
  110870. /**
  110871. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110872. */
  110873. protected _forceAlphaTest: boolean;
  110874. /**
  110875. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110876. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110877. */
  110878. protected _useAlphaFresnel: boolean;
  110879. /**
  110880. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110881. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110882. */
  110883. protected _useLinearAlphaFresnel: boolean;
  110884. /**
  110885. * The transparency mode of the material.
  110886. */
  110887. protected _transparencyMode: Nullable<number>;
  110888. /**
  110889. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110890. * from cos thetav and roughness:
  110891. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110892. */
  110893. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110894. /**
  110895. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110896. */
  110897. protected _forceIrradianceInFragment: boolean;
  110898. /**
  110899. * Force normal to face away from face.
  110900. */
  110901. protected _forceNormalForward: boolean;
  110902. /**
  110903. * Enables specular anti aliasing in the PBR shader.
  110904. * It will both interacts on the Geometry for analytical and IBL lighting.
  110905. * It also prefilter the roughness map based on the bump values.
  110906. */
  110907. protected _enableSpecularAntiAliasing: boolean;
  110908. /**
  110909. * Default configuration related to image processing available in the PBR Material.
  110910. */
  110911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110912. /**
  110913. * Keep track of the image processing observer to allow dispose and replace.
  110914. */
  110915. private _imageProcessingObserver;
  110916. /**
  110917. * Attaches a new image processing configuration to the PBR Material.
  110918. * @param configuration
  110919. */
  110920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110921. /**
  110922. * Stores the available render targets.
  110923. */
  110924. private _renderTargets;
  110925. /**
  110926. * Sets the global ambient color for the material used in lighting calculations.
  110927. */
  110928. private _globalAmbientColor;
  110929. /**
  110930. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110931. */
  110932. private _useLogarithmicDepth;
  110933. /**
  110934. * If set to true, no lighting calculations will be applied.
  110935. */
  110936. private _unlit;
  110937. private _debugMode;
  110938. /**
  110939. * @hidden
  110940. * This is reserved for the inspector.
  110941. * Defines the material debug mode.
  110942. * It helps seeing only some components of the material while troubleshooting.
  110943. */
  110944. debugMode: number;
  110945. /**
  110946. * @hidden
  110947. * This is reserved for the inspector.
  110948. * Specify from where on screen the debug mode should start.
  110949. * The value goes from -1 (full screen) to 1 (not visible)
  110950. * It helps with side by side comparison against the final render
  110951. * This defaults to -1
  110952. */
  110953. private debugLimit;
  110954. /**
  110955. * @hidden
  110956. * This is reserved for the inspector.
  110957. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110958. * You can use the factor to better multiply the final value.
  110959. */
  110960. private debugFactor;
  110961. /**
  110962. * Defines the clear coat layer parameters for the material.
  110963. */
  110964. readonly clearCoat: PBRClearCoatConfiguration;
  110965. /**
  110966. * Defines the anisotropic parameters for the material.
  110967. */
  110968. readonly anisotropy: PBRAnisotropicConfiguration;
  110969. /**
  110970. * Defines the BRDF parameters for the material.
  110971. */
  110972. readonly brdf: PBRBRDFConfiguration;
  110973. /**
  110974. * Defines the Sheen parameters for the material.
  110975. */
  110976. readonly sheen: PBRSheenConfiguration;
  110977. /**
  110978. * Defines the SubSurface parameters for the material.
  110979. */
  110980. readonly subSurface: PBRSubSurfaceConfiguration;
  110981. /**
  110982. * Custom callback helping to override the default shader used in the material.
  110983. */
  110984. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110985. /**
  110986. * Instantiates a new PBRMaterial instance.
  110987. *
  110988. * @param name The material name
  110989. * @param scene The scene the material will be use in.
  110990. */
  110991. constructor(name: string, scene: Scene);
  110992. /**
  110993. * Gets a boolean indicating that current material needs to register RTT
  110994. */
  110995. readonly hasRenderTargetTextures: boolean;
  110996. /**
  110997. * Gets the name of the material class.
  110998. */
  110999. getClassName(): string;
  111000. /**
  111001. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111002. */
  111003. /**
  111004. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111005. */
  111006. useLogarithmicDepth: boolean;
  111007. /**
  111008. * Gets the current transparency mode.
  111009. */
  111010. /**
  111011. * Sets the transparency mode of the material.
  111012. *
  111013. * | Value | Type | Description |
  111014. * | ----- | ----------------------------------- | ----------- |
  111015. * | 0 | OPAQUE | |
  111016. * | 1 | ALPHATEST | |
  111017. * | 2 | ALPHABLEND | |
  111018. * | 3 | ALPHATESTANDBLEND | |
  111019. *
  111020. */
  111021. transparencyMode: Nullable<number>;
  111022. /**
  111023. * Returns true if alpha blending should be disabled.
  111024. */
  111025. private readonly _disableAlphaBlending;
  111026. /**
  111027. * Specifies whether or not this material should be rendered in alpha blend mode.
  111028. */
  111029. needAlphaBlending(): boolean;
  111030. /**
  111031. * Specifies if the mesh will require alpha blending.
  111032. * @param mesh - BJS mesh.
  111033. */
  111034. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111035. /**
  111036. * Specifies whether or not this material should be rendered in alpha test mode.
  111037. */
  111038. needAlphaTesting(): boolean;
  111039. /**
  111040. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111041. */
  111042. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111043. /**
  111044. * Gets the texture used for the alpha test.
  111045. */
  111046. getAlphaTestTexture(): Nullable<BaseTexture>;
  111047. /**
  111048. * Specifies that the submesh is ready to be used.
  111049. * @param mesh - BJS mesh.
  111050. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111051. * @param useInstances - Specifies that instances should be used.
  111052. * @returns - boolean indicating that the submesh is ready or not.
  111053. */
  111054. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111055. /**
  111056. * Specifies if the material uses metallic roughness workflow.
  111057. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111058. */
  111059. isMetallicWorkflow(): boolean;
  111060. private _prepareEffect;
  111061. private _prepareDefines;
  111062. /**
  111063. * Force shader compilation
  111064. */
  111065. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111066. clipPlane: boolean;
  111067. }>): void;
  111068. /**
  111069. * Initializes the uniform buffer layout for the shader.
  111070. */
  111071. buildUniformLayout(): void;
  111072. /**
  111073. * Unbinds the material from the mesh
  111074. */
  111075. unbind(): void;
  111076. /**
  111077. * Binds the submesh data.
  111078. * @param world - The world matrix.
  111079. * @param mesh - The BJS mesh.
  111080. * @param subMesh - A submesh of the BJS mesh.
  111081. */
  111082. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111083. /**
  111084. * Returns the animatable textures.
  111085. * @returns - Array of animatable textures.
  111086. */
  111087. getAnimatables(): IAnimatable[];
  111088. /**
  111089. * Returns the texture used for reflections.
  111090. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111091. */
  111092. private _getReflectionTexture;
  111093. /**
  111094. * Returns an array of the actively used textures.
  111095. * @returns - Array of BaseTextures
  111096. */
  111097. getActiveTextures(): BaseTexture[];
  111098. /**
  111099. * Checks to see if a texture is used in the material.
  111100. * @param texture - Base texture to use.
  111101. * @returns - Boolean specifying if a texture is used in the material.
  111102. */
  111103. hasTexture(texture: BaseTexture): boolean;
  111104. /**
  111105. * Disposes the resources of the material.
  111106. * @param forceDisposeEffect - Forces the disposal of effects.
  111107. * @param forceDisposeTextures - Forces the disposal of all textures.
  111108. */
  111109. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111110. }
  111111. }
  111112. declare module BABYLON {
  111113. /**
  111114. * The Physically based material of BJS.
  111115. *
  111116. * This offers the main features of a standard PBR material.
  111117. * For more information, please refer to the documentation :
  111118. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111119. */
  111120. export class PBRMaterial extends PBRBaseMaterial {
  111121. /**
  111122. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111123. */
  111124. static readonly PBRMATERIAL_OPAQUE: number;
  111125. /**
  111126. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111127. */
  111128. static readonly PBRMATERIAL_ALPHATEST: number;
  111129. /**
  111130. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111131. */
  111132. static readonly PBRMATERIAL_ALPHABLEND: number;
  111133. /**
  111134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111135. * They are also discarded below the alpha cutoff threshold to improve performances.
  111136. */
  111137. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111138. /**
  111139. * Defines the default value of how much AO map is occluding the analytical lights
  111140. * (point spot...).
  111141. */
  111142. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111143. /**
  111144. * Intensity of the direct lights e.g. the four lights available in your scene.
  111145. * This impacts both the direct diffuse and specular highlights.
  111146. */
  111147. directIntensity: number;
  111148. /**
  111149. * Intensity of the emissive part of the material.
  111150. * This helps controlling the emissive effect without modifying the emissive color.
  111151. */
  111152. emissiveIntensity: number;
  111153. /**
  111154. * Intensity of the environment e.g. how much the environment will light the object
  111155. * either through harmonics for rough material or through the refelction for shiny ones.
  111156. */
  111157. environmentIntensity: number;
  111158. /**
  111159. * This is a special control allowing the reduction of the specular highlights coming from the
  111160. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111161. */
  111162. specularIntensity: number;
  111163. /**
  111164. * Debug Control allowing disabling the bump map on this material.
  111165. */
  111166. disableBumpMap: boolean;
  111167. /**
  111168. * AKA Diffuse Texture in standard nomenclature.
  111169. */
  111170. albedoTexture: BaseTexture;
  111171. /**
  111172. * AKA Occlusion Texture in other nomenclature.
  111173. */
  111174. ambientTexture: BaseTexture;
  111175. /**
  111176. * AKA Occlusion Texture Intensity in other nomenclature.
  111177. */
  111178. ambientTextureStrength: number;
  111179. /**
  111180. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111181. * 1 means it completely occludes it
  111182. * 0 mean it has no impact
  111183. */
  111184. ambientTextureImpactOnAnalyticalLights: number;
  111185. /**
  111186. * Stores the alpha values in a texture.
  111187. */
  111188. opacityTexture: BaseTexture;
  111189. /**
  111190. * Stores the reflection values in a texture.
  111191. */
  111192. reflectionTexture: Nullable<BaseTexture>;
  111193. /**
  111194. * Stores the emissive values in a texture.
  111195. */
  111196. emissiveTexture: BaseTexture;
  111197. /**
  111198. * AKA Specular texture in other nomenclature.
  111199. */
  111200. reflectivityTexture: BaseTexture;
  111201. /**
  111202. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111203. */
  111204. metallicTexture: BaseTexture;
  111205. /**
  111206. * Specifies the metallic scalar of the metallic/roughness workflow.
  111207. * Can also be used to scale the metalness values of the metallic texture.
  111208. */
  111209. metallic: Nullable<number>;
  111210. /**
  111211. * Specifies the roughness scalar of the metallic/roughness workflow.
  111212. * Can also be used to scale the roughness values of the metallic texture.
  111213. */
  111214. roughness: Nullable<number>;
  111215. /**
  111216. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111217. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111218. */
  111219. microSurfaceTexture: BaseTexture;
  111220. /**
  111221. * Stores surface normal data used to displace a mesh in a texture.
  111222. */
  111223. bumpTexture: BaseTexture;
  111224. /**
  111225. * Stores the pre-calculated light information of a mesh in a texture.
  111226. */
  111227. lightmapTexture: BaseTexture;
  111228. /**
  111229. * Stores the refracted light information in a texture.
  111230. */
  111231. refractionTexture: Nullable<BaseTexture>;
  111232. /**
  111233. * The color of a material in ambient lighting.
  111234. */
  111235. ambientColor: Color3;
  111236. /**
  111237. * AKA Diffuse Color in other nomenclature.
  111238. */
  111239. albedoColor: Color3;
  111240. /**
  111241. * AKA Specular Color in other nomenclature.
  111242. */
  111243. reflectivityColor: Color3;
  111244. /**
  111245. * The color reflected from the material.
  111246. */
  111247. reflectionColor: Color3;
  111248. /**
  111249. * The color emitted from the material.
  111250. */
  111251. emissiveColor: Color3;
  111252. /**
  111253. * AKA Glossiness in other nomenclature.
  111254. */
  111255. microSurface: number;
  111256. /**
  111257. * source material index of refraction (IOR)' / 'destination material IOR.
  111258. */
  111259. indexOfRefraction: number;
  111260. /**
  111261. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111262. */
  111263. invertRefractionY: boolean;
  111264. /**
  111265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111266. * Materials half opaque for instance using refraction could benefit from this control.
  111267. */
  111268. linkRefractionWithTransparency: boolean;
  111269. /**
  111270. * If true, the light map contains occlusion information instead of lighting info.
  111271. */
  111272. useLightmapAsShadowmap: boolean;
  111273. /**
  111274. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111275. */
  111276. useAlphaFromAlbedoTexture: boolean;
  111277. /**
  111278. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111279. */
  111280. forceAlphaTest: boolean;
  111281. /**
  111282. * Defines the alpha limits in alpha test mode.
  111283. */
  111284. alphaCutOff: number;
  111285. /**
  111286. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111287. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111288. */
  111289. useSpecularOverAlpha: boolean;
  111290. /**
  111291. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111292. */
  111293. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111294. /**
  111295. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111296. */
  111297. useRoughnessFromMetallicTextureAlpha: boolean;
  111298. /**
  111299. * Specifies if the metallic texture contains the roughness information in its green channel.
  111300. */
  111301. useRoughnessFromMetallicTextureGreen: boolean;
  111302. /**
  111303. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111304. */
  111305. useMetallnessFromMetallicTextureBlue: boolean;
  111306. /**
  111307. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111308. */
  111309. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111310. /**
  111311. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111312. */
  111313. useAmbientInGrayScale: boolean;
  111314. /**
  111315. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111316. * The material will try to infer what glossiness each pixel should be.
  111317. */
  111318. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111319. /**
  111320. * BJS is using an harcoded light falloff based on a manually sets up range.
  111321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111323. */
  111324. /**
  111325. * BJS is using an harcoded light falloff based on a manually sets up range.
  111326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111328. */
  111329. usePhysicalLightFalloff: boolean;
  111330. /**
  111331. * In order to support the falloff compatibility with gltf, a special mode has been added
  111332. * to reproduce the gltf light falloff.
  111333. */
  111334. /**
  111335. * In order to support the falloff compatibility with gltf, a special mode has been added
  111336. * to reproduce the gltf light falloff.
  111337. */
  111338. useGLTFLightFalloff: boolean;
  111339. /**
  111340. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111341. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111342. */
  111343. useRadianceOverAlpha: boolean;
  111344. /**
  111345. * Allows using an object space normal map (instead of tangent space).
  111346. */
  111347. useObjectSpaceNormalMap: boolean;
  111348. /**
  111349. * Allows using the bump map in parallax mode.
  111350. */
  111351. useParallax: boolean;
  111352. /**
  111353. * Allows using the bump map in parallax occlusion mode.
  111354. */
  111355. useParallaxOcclusion: boolean;
  111356. /**
  111357. * Controls the scale bias of the parallax mode.
  111358. */
  111359. parallaxScaleBias: number;
  111360. /**
  111361. * If sets to true, disables all the lights affecting the material.
  111362. */
  111363. disableLighting: boolean;
  111364. /**
  111365. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111366. */
  111367. forceIrradianceInFragment: boolean;
  111368. /**
  111369. * Number of Simultaneous lights allowed on the material.
  111370. */
  111371. maxSimultaneousLights: number;
  111372. /**
  111373. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111374. */
  111375. invertNormalMapX: boolean;
  111376. /**
  111377. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111378. */
  111379. invertNormalMapY: boolean;
  111380. /**
  111381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111382. */
  111383. twoSidedLighting: boolean;
  111384. /**
  111385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111386. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111387. */
  111388. useAlphaFresnel: boolean;
  111389. /**
  111390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111391. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111392. */
  111393. useLinearAlphaFresnel: boolean;
  111394. /**
  111395. * Let user defines the brdf lookup texture used for IBL.
  111396. * A default 8bit version is embedded but you could point at :
  111397. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111398. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111399. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111400. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111401. */
  111402. environmentBRDFTexture: Nullable<BaseTexture>;
  111403. /**
  111404. * Force normal to face away from face.
  111405. */
  111406. forceNormalForward: boolean;
  111407. /**
  111408. * Enables specular anti aliasing in the PBR shader.
  111409. * It will both interacts on the Geometry for analytical and IBL lighting.
  111410. * It also prefilter the roughness map based on the bump values.
  111411. */
  111412. enableSpecularAntiAliasing: boolean;
  111413. /**
  111414. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111415. * makes the reflect vector face the model (under horizon).
  111416. */
  111417. useHorizonOcclusion: boolean;
  111418. /**
  111419. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111420. * too much the area relying on ambient texture to define their ambient occlusion.
  111421. */
  111422. useRadianceOcclusion: boolean;
  111423. /**
  111424. * If set to true, no lighting calculations will be applied.
  111425. */
  111426. unlit: boolean;
  111427. /**
  111428. * Gets the image processing configuration used either in this material.
  111429. */
  111430. /**
  111431. * Sets the Default image processing configuration used either in the this material.
  111432. *
  111433. * If sets to null, the scene one is in use.
  111434. */
  111435. imageProcessingConfiguration: ImageProcessingConfiguration;
  111436. /**
  111437. * Gets wether the color curves effect is enabled.
  111438. */
  111439. /**
  111440. * Sets wether the color curves effect is enabled.
  111441. */
  111442. cameraColorCurvesEnabled: boolean;
  111443. /**
  111444. * Gets wether the color grading effect is enabled.
  111445. */
  111446. /**
  111447. * Gets wether the color grading effect is enabled.
  111448. */
  111449. cameraColorGradingEnabled: boolean;
  111450. /**
  111451. * Gets wether tonemapping is enabled or not.
  111452. */
  111453. /**
  111454. * Sets wether tonemapping is enabled or not
  111455. */
  111456. cameraToneMappingEnabled: boolean;
  111457. /**
  111458. * The camera exposure used on this material.
  111459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111460. * This corresponds to a photographic exposure.
  111461. */
  111462. /**
  111463. * The camera exposure used on this material.
  111464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111465. * This corresponds to a photographic exposure.
  111466. */
  111467. cameraExposure: number;
  111468. /**
  111469. * Gets The camera contrast used on this material.
  111470. */
  111471. /**
  111472. * Sets The camera contrast used on this material.
  111473. */
  111474. cameraContrast: number;
  111475. /**
  111476. * Gets the Color Grading 2D Lookup Texture.
  111477. */
  111478. /**
  111479. * Sets the Color Grading 2D Lookup Texture.
  111480. */
  111481. cameraColorGradingTexture: Nullable<BaseTexture>;
  111482. /**
  111483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111485. * 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;
  111486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111487. */
  111488. /**
  111489. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111490. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111491. * 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;
  111492. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111493. */
  111494. cameraColorCurves: Nullable<ColorCurves>;
  111495. /**
  111496. * Instantiates a new PBRMaterial instance.
  111497. *
  111498. * @param name The material name
  111499. * @param scene The scene the material will be use in.
  111500. */
  111501. constructor(name: string, scene: Scene);
  111502. /**
  111503. * Returns the name of this material class.
  111504. */
  111505. getClassName(): string;
  111506. /**
  111507. * Makes a duplicate of the current material.
  111508. * @param name - name to use for the new material.
  111509. */
  111510. clone(name: string): PBRMaterial;
  111511. /**
  111512. * Serializes this PBR Material.
  111513. * @returns - An object with the serialized material.
  111514. */
  111515. serialize(): any;
  111516. /**
  111517. * Parses a PBR Material from a serialized object.
  111518. * @param source - Serialized object.
  111519. * @param scene - BJS scene instance.
  111520. * @param rootUrl - url for the scene object
  111521. * @returns - PBRMaterial
  111522. */
  111523. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111524. }
  111525. }
  111526. declare module BABYLON {
  111527. /**
  111528. * Direct draw surface info
  111529. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111530. */
  111531. export interface DDSInfo {
  111532. /**
  111533. * Width of the texture
  111534. */
  111535. width: number;
  111536. /**
  111537. * Width of the texture
  111538. */
  111539. height: number;
  111540. /**
  111541. * Number of Mipmaps for the texture
  111542. * @see https://en.wikipedia.org/wiki/Mipmap
  111543. */
  111544. mipmapCount: number;
  111545. /**
  111546. * If the textures format is a known fourCC format
  111547. * @see https://www.fourcc.org/
  111548. */
  111549. isFourCC: boolean;
  111550. /**
  111551. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111552. */
  111553. isRGB: boolean;
  111554. /**
  111555. * If the texture is a lumincance format
  111556. */
  111557. isLuminance: boolean;
  111558. /**
  111559. * If this is a cube texture
  111560. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111561. */
  111562. isCube: boolean;
  111563. /**
  111564. * If the texture is a compressed format eg. FOURCC_DXT1
  111565. */
  111566. isCompressed: boolean;
  111567. /**
  111568. * The dxgiFormat of the texture
  111569. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111570. */
  111571. dxgiFormat: number;
  111572. /**
  111573. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111574. */
  111575. textureType: number;
  111576. /**
  111577. * Sphericle polynomial created for the dds texture
  111578. */
  111579. sphericalPolynomial?: SphericalPolynomial;
  111580. }
  111581. /**
  111582. * Class used to provide DDS decompression tools
  111583. */
  111584. export class DDSTools {
  111585. /**
  111586. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111587. */
  111588. static StoreLODInAlphaChannel: boolean;
  111589. /**
  111590. * Gets DDS information from an array buffer
  111591. * @param arrayBuffer defines the array buffer to read data from
  111592. * @returns the DDS information
  111593. */
  111594. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111595. private static _FloatView;
  111596. private static _Int32View;
  111597. private static _ToHalfFloat;
  111598. private static _FromHalfFloat;
  111599. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111600. private static _GetHalfFloatRGBAArrayBuffer;
  111601. private static _GetFloatRGBAArrayBuffer;
  111602. private static _GetFloatAsUIntRGBAArrayBuffer;
  111603. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111604. private static _GetRGBAArrayBuffer;
  111605. private static _ExtractLongWordOrder;
  111606. private static _GetRGBArrayBuffer;
  111607. private static _GetLuminanceArrayBuffer;
  111608. /**
  111609. * Uploads DDS Levels to a Babylon Texture
  111610. * @hidden
  111611. */
  111612. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111613. }
  111614. interface Engine {
  111615. /**
  111616. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111617. * @param rootUrl defines the url where the file to load is located
  111618. * @param scene defines the current scene
  111619. * @param lodScale defines scale to apply to the mip map selection
  111620. * @param lodOffset defines offset to apply to the mip map selection
  111621. * @param onLoad defines an optional callback raised when the texture is loaded
  111622. * @param onError defines an optional callback raised if there is an issue to load the texture
  111623. * @param format defines the format of the data
  111624. * @param forcedExtension defines the extension to use to pick the right loader
  111625. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111626. * @returns the cube texture as an InternalTexture
  111627. */
  111628. 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;
  111629. }
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Implementation of the DDS Texture Loader.
  111634. * @hidden
  111635. */
  111636. export class _DDSTextureLoader implements IInternalTextureLoader {
  111637. /**
  111638. * Defines wether the loader supports cascade loading the different faces.
  111639. */
  111640. readonly supportCascades: boolean;
  111641. /**
  111642. * This returns if the loader support the current file information.
  111643. * @param extension defines the file extension of the file being loaded
  111644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111645. * @param fallback defines the fallback internal texture if any
  111646. * @param isBase64 defines whether the texture is encoded as a base64
  111647. * @param isBuffer defines whether the texture data are stored as a buffer
  111648. * @returns true if the loader can load the specified file
  111649. */
  111650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111651. /**
  111652. * Transform the url before loading if required.
  111653. * @param rootUrl the url of the texture
  111654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111655. * @returns the transformed texture
  111656. */
  111657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111658. /**
  111659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111660. * @param rootUrl the url of the texture
  111661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111662. * @returns the fallback texture
  111663. */
  111664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111665. /**
  111666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111667. * @param data contains the texture data
  111668. * @param texture defines the BabylonJS internal texture
  111669. * @param createPolynomials will be true if polynomials have been requested
  111670. * @param onLoad defines the callback to trigger once the texture is ready
  111671. * @param onError defines the callback to trigger in case of error
  111672. */
  111673. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111674. /**
  111675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111676. * @param data contains the texture data
  111677. * @param texture defines the BabylonJS internal texture
  111678. * @param callback defines the method to call once ready to upload
  111679. */
  111680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. /** @hidden */
  111685. export var rgbdEncodePixelShader: {
  111686. name: string;
  111687. shader: string;
  111688. };
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * Raw texture data and descriptor sufficient for WebGL texture upload
  111693. */
  111694. export interface EnvironmentTextureInfo {
  111695. /**
  111696. * Version of the environment map
  111697. */
  111698. version: number;
  111699. /**
  111700. * Width of image
  111701. */
  111702. width: number;
  111703. /**
  111704. * Irradiance information stored in the file.
  111705. */
  111706. irradiance: any;
  111707. /**
  111708. * Specular information stored in the file.
  111709. */
  111710. specular: any;
  111711. }
  111712. /**
  111713. * Sets of helpers addressing the serialization and deserialization of environment texture
  111714. * stored in a BabylonJS env file.
  111715. * Those files are usually stored as .env files.
  111716. */
  111717. export class EnvironmentTextureTools {
  111718. /**
  111719. * Magic number identifying the env file.
  111720. */
  111721. private static _MagicBytes;
  111722. /**
  111723. * Gets the environment info from an env file.
  111724. * @param data The array buffer containing the .env bytes.
  111725. * @returns the environment file info (the json header) if successfully parsed.
  111726. */
  111727. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111728. /**
  111729. * Creates an environment texture from a loaded cube texture.
  111730. * @param texture defines the cube texture to convert in env file
  111731. * @return a promise containing the environment data if succesfull.
  111732. */
  111733. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111734. /**
  111735. * Creates a JSON representation of the spherical data.
  111736. * @param texture defines the texture containing the polynomials
  111737. * @return the JSON representation of the spherical info
  111738. */
  111739. private static _CreateEnvTextureIrradiance;
  111740. /**
  111741. * Uploads the texture info contained in the env file to the GPU.
  111742. * @param texture defines the internal texture to upload to
  111743. * @param arrayBuffer defines the buffer cotaining the data to load
  111744. * @param info defines the texture info retrieved through the GetEnvInfo method
  111745. * @returns a promise
  111746. */
  111747. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111748. /**
  111749. * Uploads the levels of image data to the GPU.
  111750. * @param texture defines the internal texture to upload to
  111751. * @param imageData defines the array buffer views of image data [mipmap][face]
  111752. * @returns a promise
  111753. */
  111754. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111755. /**
  111756. * Uploads spherical polynomials information to the texture.
  111757. * @param texture defines the texture we are trying to upload the information to
  111758. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111759. */
  111760. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111761. /** @hidden */
  111762. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111763. }
  111764. }
  111765. declare module BABYLON {
  111766. /**
  111767. * Implementation of the ENV Texture Loader.
  111768. * @hidden
  111769. */
  111770. export class _ENVTextureLoader implements IInternalTextureLoader {
  111771. /**
  111772. * Defines wether the loader supports cascade loading the different faces.
  111773. */
  111774. readonly supportCascades: boolean;
  111775. /**
  111776. * This returns if the loader support the current file information.
  111777. * @param extension defines the file extension of the file being loaded
  111778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111779. * @param fallback defines the fallback internal texture if any
  111780. * @param isBase64 defines whether the texture is encoded as a base64
  111781. * @param isBuffer defines whether the texture data are stored as a buffer
  111782. * @returns true if the loader can load the specified file
  111783. */
  111784. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111785. /**
  111786. * Transform the url before loading if required.
  111787. * @param rootUrl the url of the texture
  111788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111789. * @returns the transformed texture
  111790. */
  111791. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111792. /**
  111793. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111794. * @param rootUrl the url of the texture
  111795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111796. * @returns the fallback texture
  111797. */
  111798. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111799. /**
  111800. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111801. * @param data contains the texture data
  111802. * @param texture defines the BabylonJS internal texture
  111803. * @param createPolynomials will be true if polynomials have been requested
  111804. * @param onLoad defines the callback to trigger once the texture is ready
  111805. * @param onError defines the callback to trigger in case of error
  111806. */
  111807. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111808. /**
  111809. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111810. * @param data contains the texture data
  111811. * @param texture defines the BabylonJS internal texture
  111812. * @param callback defines the method to call once ready to upload
  111813. */
  111814. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111815. }
  111816. }
  111817. declare module BABYLON {
  111818. /**
  111819. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111820. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111821. */
  111822. export class KhronosTextureContainer {
  111823. /** contents of the KTX container file */
  111824. arrayBuffer: any;
  111825. private static HEADER_LEN;
  111826. private static COMPRESSED_2D;
  111827. private static COMPRESSED_3D;
  111828. private static TEX_2D;
  111829. private static TEX_3D;
  111830. /**
  111831. * Gets the openGL type
  111832. */
  111833. glType: number;
  111834. /**
  111835. * Gets the openGL type size
  111836. */
  111837. glTypeSize: number;
  111838. /**
  111839. * Gets the openGL format
  111840. */
  111841. glFormat: number;
  111842. /**
  111843. * Gets the openGL internal format
  111844. */
  111845. glInternalFormat: number;
  111846. /**
  111847. * Gets the base internal format
  111848. */
  111849. glBaseInternalFormat: number;
  111850. /**
  111851. * Gets image width in pixel
  111852. */
  111853. pixelWidth: number;
  111854. /**
  111855. * Gets image height in pixel
  111856. */
  111857. pixelHeight: number;
  111858. /**
  111859. * Gets image depth in pixels
  111860. */
  111861. pixelDepth: number;
  111862. /**
  111863. * Gets the number of array elements
  111864. */
  111865. numberOfArrayElements: number;
  111866. /**
  111867. * Gets the number of faces
  111868. */
  111869. numberOfFaces: number;
  111870. /**
  111871. * Gets the number of mipmap levels
  111872. */
  111873. numberOfMipmapLevels: number;
  111874. /**
  111875. * Gets the bytes of key value data
  111876. */
  111877. bytesOfKeyValueData: number;
  111878. /**
  111879. * Gets the load type
  111880. */
  111881. loadType: number;
  111882. /**
  111883. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111884. */
  111885. isInvalid: boolean;
  111886. /**
  111887. * Creates a new KhronosTextureContainer
  111888. * @param arrayBuffer contents of the KTX container file
  111889. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111890. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111891. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111892. */
  111893. constructor(
  111894. /** contents of the KTX container file */
  111895. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111896. /**
  111897. * Uploads KTX content to a Babylon Texture.
  111898. * It is assumed that the texture has already been created & is currently bound
  111899. * @hidden
  111900. */
  111901. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111902. private _upload2DCompressedLevels;
  111903. }
  111904. }
  111905. declare module BABYLON {
  111906. /**
  111907. * Implementation of the KTX Texture Loader.
  111908. * @hidden
  111909. */
  111910. export class _KTXTextureLoader implements IInternalTextureLoader {
  111911. /**
  111912. * Defines wether the loader supports cascade loading the different faces.
  111913. */
  111914. readonly supportCascades: boolean;
  111915. /**
  111916. * This returns if the loader support the current file information.
  111917. * @param extension defines the file extension of the file being loaded
  111918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111919. * @param fallback defines the fallback internal texture if any
  111920. * @param isBase64 defines whether the texture is encoded as a base64
  111921. * @param isBuffer defines whether the texture data are stored as a buffer
  111922. * @returns true if the loader can load the specified file
  111923. */
  111924. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111925. /**
  111926. * Transform the url before loading if required.
  111927. * @param rootUrl the url of the texture
  111928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111929. * @returns the transformed texture
  111930. */
  111931. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111932. /**
  111933. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111934. * @param rootUrl the url of the texture
  111935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111936. * @returns the fallback texture
  111937. */
  111938. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111939. /**
  111940. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111941. * @param data contains the texture data
  111942. * @param texture defines the BabylonJS internal texture
  111943. * @param createPolynomials will be true if polynomials have been requested
  111944. * @param onLoad defines the callback to trigger once the texture is ready
  111945. * @param onError defines the callback to trigger in case of error
  111946. */
  111947. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111948. /**
  111949. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111950. * @param data contains the texture data
  111951. * @param texture defines the BabylonJS internal texture
  111952. * @param callback defines the method to call once ready to upload
  111953. */
  111954. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111955. }
  111956. }
  111957. declare module BABYLON {
  111958. /**
  111959. * Options for the default xr helper
  111960. */
  111961. export class WebXRDefaultExperienceOptions {
  111962. /**
  111963. * Floor meshes that should be used for teleporting
  111964. */
  111965. floorMeshes: Array<AbstractMesh>;
  111966. }
  111967. /**
  111968. * Default experience which provides a similar setup to the previous webVRExperience
  111969. */
  111970. export class WebXRDefaultExperience {
  111971. /**
  111972. * Base experience
  111973. */
  111974. baseExperience: WebXRExperienceHelper;
  111975. /**
  111976. * Input experience extension
  111977. */
  111978. input: WebXRInput;
  111979. /**
  111980. * Loads the controller models
  111981. */
  111982. controllerModelLoader: WebXRControllerModelLoader;
  111983. /**
  111984. * Enables laser pointer and selection
  111985. */
  111986. pointerSelection: WebXRControllerPointerSelection;
  111987. /**
  111988. * Enables teleportation
  111989. */
  111990. teleportation: WebXRControllerTeleportation;
  111991. /**
  111992. * Enables ui for enetering/exiting xr
  111993. */
  111994. enterExitUI: WebXREnterExitUI;
  111995. /**
  111996. * Default output canvas xr should render to
  111997. */
  111998. outputCanvas: WebXRManagedOutputCanvas;
  111999. /**
  112000. * Creates the default xr experience
  112001. * @param scene scene
  112002. * @param options options for basic configuration
  112003. * @returns resulting WebXRDefaultExperience
  112004. */
  112005. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112006. private constructor();
  112007. /**
  112008. * DIsposes of the experience helper
  112009. */
  112010. dispose(): void;
  112011. }
  112012. }
  112013. declare module BABYLON {
  112014. /** @hidden */
  112015. export var _forceSceneHelpersToBundle: boolean;
  112016. interface Scene {
  112017. /**
  112018. * Creates a default light for the scene.
  112019. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112020. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112021. */
  112022. createDefaultLight(replace?: boolean): void;
  112023. /**
  112024. * Creates a default camera for the scene.
  112025. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112026. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112027. * @param replace has default false, when true replaces the active camera in the scene
  112028. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112029. */
  112030. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112031. /**
  112032. * Creates a default camera and a default light.
  112033. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112034. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112035. * @param replace has the default false, when true replaces the active camera/light in the scene
  112036. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112037. */
  112038. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112039. /**
  112040. * Creates a new sky box
  112041. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112042. * @param environmentTexture defines the texture to use as environment texture
  112043. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112044. * @param scale defines the overall scale of the skybox
  112045. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112046. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112047. * @returns a new mesh holding the sky box
  112048. */
  112049. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112050. /**
  112051. * Creates a new environment
  112052. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112053. * @param options defines the options you can use to configure the environment
  112054. * @returns the new EnvironmentHelper
  112055. */
  112056. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112057. /**
  112058. * Creates a new VREXperienceHelper
  112059. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112060. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112061. * @returns a new VREXperienceHelper
  112062. */
  112063. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112064. /**
  112065. * Creates a new WebXRDefaultExperience
  112066. * @see http://doc.babylonjs.com/how_to/webxr
  112067. * @param options experience options
  112068. * @returns a promise for a new WebXRDefaultExperience
  112069. */
  112070. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112071. }
  112072. }
  112073. declare module BABYLON {
  112074. /**
  112075. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112076. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112077. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112078. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112079. */
  112080. export class VideoDome extends TransformNode {
  112081. /**
  112082. * Define the video source as a Monoscopic panoramic 360 video.
  112083. */
  112084. static readonly MODE_MONOSCOPIC: number;
  112085. /**
  112086. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112087. */
  112088. static readonly MODE_TOPBOTTOM: number;
  112089. /**
  112090. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112091. */
  112092. static readonly MODE_SIDEBYSIDE: number;
  112093. private _useDirectMapping;
  112094. /**
  112095. * The video texture being displayed on the sphere
  112096. */
  112097. protected _videoTexture: VideoTexture;
  112098. /**
  112099. * Gets the video texture being displayed on the sphere
  112100. */
  112101. readonly videoTexture: VideoTexture;
  112102. /**
  112103. * The skybox material
  112104. */
  112105. protected _material: BackgroundMaterial;
  112106. /**
  112107. * The surface used for the skybox
  112108. */
  112109. protected _mesh: Mesh;
  112110. /**
  112111. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112112. * Also see the options.resolution property.
  112113. */
  112114. fovMultiplier: number;
  112115. private _videoMode;
  112116. /**
  112117. * Gets or set the current video mode for the video. It can be:
  112118. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112119. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112120. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112121. */
  112122. videoMode: number;
  112123. /**
  112124. * Oberserver used in Stereoscopic VR Mode.
  112125. */
  112126. private _onBeforeCameraRenderObserver;
  112127. /**
  112128. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112129. * @param name Element's name, child elements will append suffixes for their own names.
  112130. * @param urlsOrVideo defines the url(s) or the video element to use
  112131. * @param options An object containing optional or exposed sub element properties
  112132. */
  112133. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112134. resolution?: number;
  112135. clickToPlay?: boolean;
  112136. autoPlay?: boolean;
  112137. loop?: boolean;
  112138. size?: number;
  112139. poster?: string;
  112140. faceForward?: boolean;
  112141. useDirectMapping?: boolean;
  112142. }, scene: Scene);
  112143. private _changeVideoMode;
  112144. /**
  112145. * Releases resources associated with this node.
  112146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112148. */
  112149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112150. }
  112151. }
  112152. declare module BABYLON {
  112153. /**
  112154. * This class can be used to get instrumentation data from a Babylon engine
  112155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112156. */
  112157. export class EngineInstrumentation implements IDisposable {
  112158. /**
  112159. * Define the instrumented engine.
  112160. */
  112161. engine: Engine;
  112162. private _captureGPUFrameTime;
  112163. private _gpuFrameTimeToken;
  112164. private _gpuFrameTime;
  112165. private _captureShaderCompilationTime;
  112166. private _shaderCompilationTime;
  112167. private _onBeginFrameObserver;
  112168. private _onEndFrameObserver;
  112169. private _onBeforeShaderCompilationObserver;
  112170. private _onAfterShaderCompilationObserver;
  112171. /**
  112172. * Gets the perf counter used for GPU frame time
  112173. */
  112174. readonly gpuFrameTimeCounter: PerfCounter;
  112175. /**
  112176. * Gets the GPU frame time capture status
  112177. */
  112178. /**
  112179. * Enable or disable the GPU frame time capture
  112180. */
  112181. captureGPUFrameTime: boolean;
  112182. /**
  112183. * Gets the perf counter used for shader compilation time
  112184. */
  112185. readonly shaderCompilationTimeCounter: PerfCounter;
  112186. /**
  112187. * Gets the shader compilation time capture status
  112188. */
  112189. /**
  112190. * Enable or disable the shader compilation time capture
  112191. */
  112192. captureShaderCompilationTime: boolean;
  112193. /**
  112194. * Instantiates a new engine instrumentation.
  112195. * This class can be used to get instrumentation data from a Babylon engine
  112196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112197. * @param engine Defines the engine to instrument
  112198. */
  112199. constructor(
  112200. /**
  112201. * Define the instrumented engine.
  112202. */
  112203. engine: Engine);
  112204. /**
  112205. * Dispose and release associated resources.
  112206. */
  112207. dispose(): void;
  112208. }
  112209. }
  112210. declare module BABYLON {
  112211. /**
  112212. * This class can be used to get instrumentation data from a Babylon engine
  112213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112214. */
  112215. export class SceneInstrumentation implements IDisposable {
  112216. /**
  112217. * Defines the scene to instrument
  112218. */
  112219. scene: Scene;
  112220. private _captureActiveMeshesEvaluationTime;
  112221. private _activeMeshesEvaluationTime;
  112222. private _captureRenderTargetsRenderTime;
  112223. private _renderTargetsRenderTime;
  112224. private _captureFrameTime;
  112225. private _frameTime;
  112226. private _captureRenderTime;
  112227. private _renderTime;
  112228. private _captureInterFrameTime;
  112229. private _interFrameTime;
  112230. private _captureParticlesRenderTime;
  112231. private _particlesRenderTime;
  112232. private _captureSpritesRenderTime;
  112233. private _spritesRenderTime;
  112234. private _capturePhysicsTime;
  112235. private _physicsTime;
  112236. private _captureAnimationsTime;
  112237. private _animationsTime;
  112238. private _captureCameraRenderTime;
  112239. private _cameraRenderTime;
  112240. private _onBeforeActiveMeshesEvaluationObserver;
  112241. private _onAfterActiveMeshesEvaluationObserver;
  112242. private _onBeforeRenderTargetsRenderObserver;
  112243. private _onAfterRenderTargetsRenderObserver;
  112244. private _onAfterRenderObserver;
  112245. private _onBeforeDrawPhaseObserver;
  112246. private _onAfterDrawPhaseObserver;
  112247. private _onBeforeAnimationsObserver;
  112248. private _onBeforeParticlesRenderingObserver;
  112249. private _onAfterParticlesRenderingObserver;
  112250. private _onBeforeSpritesRenderingObserver;
  112251. private _onAfterSpritesRenderingObserver;
  112252. private _onBeforePhysicsObserver;
  112253. private _onAfterPhysicsObserver;
  112254. private _onAfterAnimationsObserver;
  112255. private _onBeforeCameraRenderObserver;
  112256. private _onAfterCameraRenderObserver;
  112257. /**
  112258. * Gets the perf counter used for active meshes evaluation time
  112259. */
  112260. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112261. /**
  112262. * Gets the active meshes evaluation time capture status
  112263. */
  112264. /**
  112265. * Enable or disable the active meshes evaluation time capture
  112266. */
  112267. captureActiveMeshesEvaluationTime: boolean;
  112268. /**
  112269. * Gets the perf counter used for render targets render time
  112270. */
  112271. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112272. /**
  112273. * Gets the render targets render time capture status
  112274. */
  112275. /**
  112276. * Enable or disable the render targets render time capture
  112277. */
  112278. captureRenderTargetsRenderTime: boolean;
  112279. /**
  112280. * Gets the perf counter used for particles render time
  112281. */
  112282. readonly particlesRenderTimeCounter: PerfCounter;
  112283. /**
  112284. * Gets the particles render time capture status
  112285. */
  112286. /**
  112287. * Enable or disable the particles render time capture
  112288. */
  112289. captureParticlesRenderTime: boolean;
  112290. /**
  112291. * Gets the perf counter used for sprites render time
  112292. */
  112293. readonly spritesRenderTimeCounter: PerfCounter;
  112294. /**
  112295. * Gets the sprites render time capture status
  112296. */
  112297. /**
  112298. * Enable or disable the sprites render time capture
  112299. */
  112300. captureSpritesRenderTime: boolean;
  112301. /**
  112302. * Gets the perf counter used for physics time
  112303. */
  112304. readonly physicsTimeCounter: PerfCounter;
  112305. /**
  112306. * Gets the physics time capture status
  112307. */
  112308. /**
  112309. * Enable or disable the physics time capture
  112310. */
  112311. capturePhysicsTime: boolean;
  112312. /**
  112313. * Gets the perf counter used for animations time
  112314. */
  112315. readonly animationsTimeCounter: PerfCounter;
  112316. /**
  112317. * Gets the animations time capture status
  112318. */
  112319. /**
  112320. * Enable or disable the animations time capture
  112321. */
  112322. captureAnimationsTime: boolean;
  112323. /**
  112324. * Gets the perf counter used for frame time capture
  112325. */
  112326. readonly frameTimeCounter: PerfCounter;
  112327. /**
  112328. * Gets the frame time capture status
  112329. */
  112330. /**
  112331. * Enable or disable the frame time capture
  112332. */
  112333. captureFrameTime: boolean;
  112334. /**
  112335. * Gets the perf counter used for inter-frames time capture
  112336. */
  112337. readonly interFrameTimeCounter: PerfCounter;
  112338. /**
  112339. * Gets the inter-frames time capture status
  112340. */
  112341. /**
  112342. * Enable or disable the inter-frames time capture
  112343. */
  112344. captureInterFrameTime: boolean;
  112345. /**
  112346. * Gets the perf counter used for render time capture
  112347. */
  112348. readonly renderTimeCounter: PerfCounter;
  112349. /**
  112350. * Gets the render time capture status
  112351. */
  112352. /**
  112353. * Enable or disable the render time capture
  112354. */
  112355. captureRenderTime: boolean;
  112356. /**
  112357. * Gets the perf counter used for camera render time capture
  112358. */
  112359. readonly cameraRenderTimeCounter: PerfCounter;
  112360. /**
  112361. * Gets the camera render time capture status
  112362. */
  112363. /**
  112364. * Enable or disable the camera render time capture
  112365. */
  112366. captureCameraRenderTime: boolean;
  112367. /**
  112368. * Gets the perf counter used for draw calls
  112369. */
  112370. readonly drawCallsCounter: PerfCounter;
  112371. /**
  112372. * Instantiates a new scene instrumentation.
  112373. * This class can be used to get instrumentation data from a Babylon engine
  112374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112375. * @param scene Defines the scene to instrument
  112376. */
  112377. constructor(
  112378. /**
  112379. * Defines the scene to instrument
  112380. */
  112381. scene: Scene);
  112382. /**
  112383. * Dispose and release associated resources.
  112384. */
  112385. dispose(): void;
  112386. }
  112387. }
  112388. declare module BABYLON {
  112389. /** @hidden */
  112390. export var glowMapGenerationPixelShader: {
  112391. name: string;
  112392. shader: string;
  112393. };
  112394. }
  112395. declare module BABYLON {
  112396. /** @hidden */
  112397. export var glowMapGenerationVertexShader: {
  112398. name: string;
  112399. shader: string;
  112400. };
  112401. }
  112402. declare module BABYLON {
  112403. /**
  112404. * Effect layer options. This helps customizing the behaviour
  112405. * of the effect layer.
  112406. */
  112407. export interface IEffectLayerOptions {
  112408. /**
  112409. * Multiplication factor apply to the canvas size to compute the render target size
  112410. * used to generated the objects (the smaller the faster).
  112411. */
  112412. mainTextureRatio: number;
  112413. /**
  112414. * Enforces a fixed size texture to ensure effect stability across devices.
  112415. */
  112416. mainTextureFixedSize?: number;
  112417. /**
  112418. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  112419. */
  112420. alphaBlendingMode: number;
  112421. /**
  112422. * The camera attached to the layer.
  112423. */
  112424. camera: Nullable<Camera>;
  112425. /**
  112426. * The rendering group to draw the layer in.
  112427. */
  112428. renderingGroupId: number;
  112429. }
  112430. /**
  112431. * The effect layer Helps adding post process effect blended with the main pass.
  112432. *
  112433. * This can be for instance use to generate glow or higlight effects on the scene.
  112434. *
  112435. * The effect layer class can not be used directly and is intented to inherited from to be
  112436. * customized per effects.
  112437. */
  112438. export abstract class EffectLayer {
  112439. private _vertexBuffers;
  112440. private _indexBuffer;
  112441. private _cachedDefines;
  112442. private _effectLayerMapGenerationEffect;
  112443. private _effectLayerOptions;
  112444. private _mergeEffect;
  112445. protected _scene: Scene;
  112446. protected _engine: Engine;
  112447. protected _maxSize: number;
  112448. protected _mainTextureDesiredSize: ISize;
  112449. protected _mainTexture: RenderTargetTexture;
  112450. protected _shouldRender: boolean;
  112451. protected _postProcesses: PostProcess[];
  112452. protected _textures: BaseTexture[];
  112453. protected _emissiveTextureAndColor: {
  112454. texture: Nullable<BaseTexture>;
  112455. color: Color4;
  112456. };
  112457. /**
  112458. * The name of the layer
  112459. */
  112460. name: string;
  112461. /**
  112462. * The clear color of the texture used to generate the glow map.
  112463. */
  112464. neutralColor: Color4;
  112465. /**
  112466. * Specifies wether the highlight layer is enabled or not.
  112467. */
  112468. isEnabled: boolean;
  112469. /**
  112470. * Gets the camera attached to the layer.
  112471. */
  112472. readonly camera: Nullable<Camera>;
  112473. /**
  112474. * Gets the rendering group id the layer should render in.
  112475. */
  112476. renderingGroupId: number;
  112477. /**
  112478. * An event triggered when the effect layer has been disposed.
  112479. */
  112480. onDisposeObservable: Observable<EffectLayer>;
  112481. /**
  112482. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112483. */
  112484. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112485. /**
  112486. * An event triggered when the generated texture is being merged in the scene.
  112487. */
  112488. onBeforeComposeObservable: Observable<EffectLayer>;
  112489. /**
  112490. * An event triggered when the generated texture has been merged in the scene.
  112491. */
  112492. onAfterComposeObservable: Observable<EffectLayer>;
  112493. /**
  112494. * An event triggered when the efffect layer changes its size.
  112495. */
  112496. onSizeChangedObservable: Observable<EffectLayer>;
  112497. /** @hidden */
  112498. static _SceneComponentInitialization: (scene: Scene) => void;
  112499. /**
  112500. * Instantiates a new effect Layer and references it in the scene.
  112501. * @param name The name of the layer
  112502. * @param scene The scene to use the layer in
  112503. */
  112504. constructor(
  112505. /** The Friendly of the effect in the scene */
  112506. name: string, scene: Scene);
  112507. /**
  112508. * Get the effect name of the layer.
  112509. * @return The effect name
  112510. */
  112511. abstract getEffectName(): string;
  112512. /**
  112513. * Checks for the readiness of the element composing the layer.
  112514. * @param subMesh the mesh to check for
  112515. * @param useInstances specify wether or not to use instances to render the mesh
  112516. * @return true if ready otherwise, false
  112517. */
  112518. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112519. /**
  112520. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112521. * @returns true if the effect requires stencil during the main canvas render pass.
  112522. */
  112523. abstract needStencil(): boolean;
  112524. /**
  112525. * Create the merge effect. This is the shader use to blit the information back
  112526. * to the main canvas at the end of the scene rendering.
  112527. * @returns The effect containing the shader used to merge the effect on the main canvas
  112528. */
  112529. protected abstract _createMergeEffect(): Effect;
  112530. /**
  112531. * Creates the render target textures and post processes used in the effect layer.
  112532. */
  112533. protected abstract _createTextureAndPostProcesses(): void;
  112534. /**
  112535. * Implementation specific of rendering the generating effect on the main canvas.
  112536. * @param effect The effect used to render through
  112537. */
  112538. protected abstract _internalRender(effect: Effect): void;
  112539. /**
  112540. * Sets the required values for both the emissive texture and and the main color.
  112541. */
  112542. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112543. /**
  112544. * Free any resources and references associated to a mesh.
  112545. * Internal use
  112546. * @param mesh The mesh to free.
  112547. */
  112548. abstract _disposeMesh(mesh: Mesh): void;
  112549. /**
  112550. * Serializes this layer (Glow or Highlight for example)
  112551. * @returns a serialized layer object
  112552. */
  112553. abstract serialize?(): any;
  112554. /**
  112555. * Initializes the effect layer with the required options.
  112556. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112557. */
  112558. protected _init(options: Partial<IEffectLayerOptions>): void;
  112559. /**
  112560. * Generates the index buffer of the full screen quad blending to the main canvas.
  112561. */
  112562. private _generateIndexBuffer;
  112563. /**
  112564. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112565. */
  112566. private _generateVertexBuffer;
  112567. /**
  112568. * Sets the main texture desired size which is the closest power of two
  112569. * of the engine canvas size.
  112570. */
  112571. private _setMainTextureSize;
  112572. /**
  112573. * Creates the main texture for the effect layer.
  112574. */
  112575. protected _createMainTexture(): void;
  112576. /**
  112577. * Adds specific effects defines.
  112578. * @param defines The defines to add specifics to.
  112579. */
  112580. protected _addCustomEffectDefines(defines: string[]): void;
  112581. /**
  112582. * Checks for the readiness of the element composing the layer.
  112583. * @param subMesh the mesh to check for
  112584. * @param useInstances specify wether or not to use instances to render the mesh
  112585. * @param emissiveTexture the associated emissive texture used to generate the glow
  112586. * @return true if ready otherwise, false
  112587. */
  112588. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112589. /**
  112590. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112591. */
  112592. render(): void;
  112593. /**
  112594. * Determine if a given mesh will be used in the current effect.
  112595. * @param mesh mesh to test
  112596. * @returns true if the mesh will be used
  112597. */
  112598. hasMesh(mesh: AbstractMesh): boolean;
  112599. /**
  112600. * Returns true if the layer contains information to display, otherwise false.
  112601. * @returns true if the glow layer should be rendered
  112602. */
  112603. shouldRender(): boolean;
  112604. /**
  112605. * Returns true if the mesh should render, otherwise false.
  112606. * @param mesh The mesh to render
  112607. * @returns true if it should render otherwise false
  112608. */
  112609. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112610. /**
  112611. * Returns true if the mesh can be rendered, otherwise false.
  112612. * @param mesh The mesh to render
  112613. * @param material The material used on the mesh
  112614. * @returns true if it can be rendered otherwise false
  112615. */
  112616. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112617. /**
  112618. * Returns true if the mesh should render, otherwise false.
  112619. * @param mesh The mesh to render
  112620. * @returns true if it should render otherwise false
  112621. */
  112622. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112623. /**
  112624. * Renders the submesh passed in parameter to the generation map.
  112625. */
  112626. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112627. /**
  112628. * Rebuild the required buffers.
  112629. * @hidden Internal use only.
  112630. */
  112631. _rebuild(): void;
  112632. /**
  112633. * Dispose only the render target textures and post process.
  112634. */
  112635. private _disposeTextureAndPostProcesses;
  112636. /**
  112637. * Dispose the highlight layer and free resources.
  112638. */
  112639. dispose(): void;
  112640. /**
  112641. * Gets the class name of the effect layer
  112642. * @returns the string with the class name of the effect layer
  112643. */
  112644. getClassName(): string;
  112645. /**
  112646. * Creates an effect layer from parsed effect layer data
  112647. * @param parsedEffectLayer defines effect layer data
  112648. * @param scene defines the current scene
  112649. * @param rootUrl defines the root URL containing the effect layer information
  112650. * @returns a parsed effect Layer
  112651. */
  112652. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112653. }
  112654. }
  112655. declare module BABYLON {
  112656. interface AbstractScene {
  112657. /**
  112658. * The list of effect layers (highlights/glow) added to the scene
  112659. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112660. * @see http://doc.babylonjs.com/how_to/glow_layer
  112661. */
  112662. effectLayers: Array<EffectLayer>;
  112663. /**
  112664. * Removes the given effect layer from this scene.
  112665. * @param toRemove defines the effect layer to remove
  112666. * @returns the index of the removed effect layer
  112667. */
  112668. removeEffectLayer(toRemove: EffectLayer): number;
  112669. /**
  112670. * Adds the given effect layer to this scene
  112671. * @param newEffectLayer defines the effect layer to add
  112672. */
  112673. addEffectLayer(newEffectLayer: EffectLayer): void;
  112674. }
  112675. /**
  112676. * Defines the layer scene component responsible to manage any effect layers
  112677. * in a given scene.
  112678. */
  112679. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112680. /**
  112681. * The component name helpfull to identify the component in the list of scene components.
  112682. */
  112683. readonly name: string;
  112684. /**
  112685. * The scene the component belongs to.
  112686. */
  112687. scene: Scene;
  112688. private _engine;
  112689. private _renderEffects;
  112690. private _needStencil;
  112691. private _previousStencilState;
  112692. /**
  112693. * Creates a new instance of the component for the given scene
  112694. * @param scene Defines the scene to register the component in
  112695. */
  112696. constructor(scene: Scene);
  112697. /**
  112698. * Registers the component in a given scene
  112699. */
  112700. register(): void;
  112701. /**
  112702. * Rebuilds the elements related to this component in case of
  112703. * context lost for instance.
  112704. */
  112705. rebuild(): void;
  112706. /**
  112707. * Serializes the component data to the specified json object
  112708. * @param serializationObject The object to serialize to
  112709. */
  112710. serialize(serializationObject: any): void;
  112711. /**
  112712. * Adds all the elements from the container to the scene
  112713. * @param container the container holding the elements
  112714. */
  112715. addFromContainer(container: AbstractScene): void;
  112716. /**
  112717. * Removes all the elements in the container from the scene
  112718. * @param container contains the elements to remove
  112719. * @param dispose if the removed element should be disposed (default: false)
  112720. */
  112721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112722. /**
  112723. * Disposes the component and the associated ressources.
  112724. */
  112725. dispose(): void;
  112726. private _isReadyForMesh;
  112727. private _renderMainTexture;
  112728. private _setStencil;
  112729. private _setStencilBack;
  112730. private _draw;
  112731. private _drawCamera;
  112732. private _drawRenderingGroup;
  112733. }
  112734. }
  112735. declare module BABYLON {
  112736. /** @hidden */
  112737. export var glowMapMergePixelShader: {
  112738. name: string;
  112739. shader: string;
  112740. };
  112741. }
  112742. declare module BABYLON {
  112743. /** @hidden */
  112744. export var glowMapMergeVertexShader: {
  112745. name: string;
  112746. shader: string;
  112747. };
  112748. }
  112749. declare module BABYLON {
  112750. interface AbstractScene {
  112751. /**
  112752. * Return a the first highlight layer of the scene with a given name.
  112753. * @param name The name of the highlight layer to look for.
  112754. * @return The highlight layer if found otherwise null.
  112755. */
  112756. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112757. }
  112758. /**
  112759. * Glow layer options. This helps customizing the behaviour
  112760. * of the glow layer.
  112761. */
  112762. export interface IGlowLayerOptions {
  112763. /**
  112764. * Multiplication factor apply to the canvas size to compute the render target size
  112765. * used to generated the glowing objects (the smaller the faster).
  112766. */
  112767. mainTextureRatio: number;
  112768. /**
  112769. * Enforces a fixed size texture to ensure resize independant blur.
  112770. */
  112771. mainTextureFixedSize?: number;
  112772. /**
  112773. * How big is the kernel of the blur texture.
  112774. */
  112775. blurKernelSize: number;
  112776. /**
  112777. * The camera attached to the layer.
  112778. */
  112779. camera: Nullable<Camera>;
  112780. /**
  112781. * Enable MSAA by chosing the number of samples.
  112782. */
  112783. mainTextureSamples?: number;
  112784. /**
  112785. * The rendering group to draw the layer in.
  112786. */
  112787. renderingGroupId: number;
  112788. }
  112789. /**
  112790. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112791. *
  112792. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112793. * glowy meshes to your scene.
  112794. *
  112795. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112796. */
  112797. export class GlowLayer extends EffectLayer {
  112798. /**
  112799. * Effect Name of the layer.
  112800. */
  112801. static readonly EffectName: string;
  112802. /**
  112803. * The default blur kernel size used for the glow.
  112804. */
  112805. static DefaultBlurKernelSize: number;
  112806. /**
  112807. * The default texture size ratio used for the glow.
  112808. */
  112809. static DefaultTextureRatio: number;
  112810. /**
  112811. * Sets the kernel size of the blur.
  112812. */
  112813. /**
  112814. * Gets the kernel size of the blur.
  112815. */
  112816. blurKernelSize: number;
  112817. /**
  112818. * Sets the glow intensity.
  112819. */
  112820. /**
  112821. * Gets the glow intensity.
  112822. */
  112823. intensity: number;
  112824. private _options;
  112825. private _intensity;
  112826. private _horizontalBlurPostprocess1;
  112827. private _verticalBlurPostprocess1;
  112828. private _horizontalBlurPostprocess2;
  112829. private _verticalBlurPostprocess2;
  112830. private _blurTexture1;
  112831. private _blurTexture2;
  112832. private _postProcesses1;
  112833. private _postProcesses2;
  112834. private _includedOnlyMeshes;
  112835. private _excludedMeshes;
  112836. /**
  112837. * Callback used to let the user override the color selection on a per mesh basis
  112838. */
  112839. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112840. /**
  112841. * Callback used to let the user override the texture selection on a per mesh basis
  112842. */
  112843. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112844. /**
  112845. * Instantiates a new glow Layer and references it to the scene.
  112846. * @param name The name of the layer
  112847. * @param scene The scene to use the layer in
  112848. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112849. */
  112850. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112851. /**
  112852. * Get the effect name of the layer.
  112853. * @return The effect name
  112854. */
  112855. getEffectName(): string;
  112856. /**
  112857. * Create the merge effect. This is the shader use to blit the information back
  112858. * to the main canvas at the end of the scene rendering.
  112859. */
  112860. protected _createMergeEffect(): Effect;
  112861. /**
  112862. * Creates the render target textures and post processes used in the glow layer.
  112863. */
  112864. protected _createTextureAndPostProcesses(): void;
  112865. /**
  112866. * Checks for the readiness of the element composing the layer.
  112867. * @param subMesh the mesh to check for
  112868. * @param useInstances specify wether or not to use instances to render the mesh
  112869. * @param emissiveTexture the associated emissive texture used to generate the glow
  112870. * @return true if ready otherwise, false
  112871. */
  112872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112873. /**
  112874. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112875. */
  112876. needStencil(): boolean;
  112877. /**
  112878. * Returns true if the mesh can be rendered, otherwise false.
  112879. * @param mesh The mesh to render
  112880. * @param material The material used on the mesh
  112881. * @returns true if it can be rendered otherwise false
  112882. */
  112883. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112884. /**
  112885. * Implementation specific of rendering the generating effect on the main canvas.
  112886. * @param effect The effect used to render through
  112887. */
  112888. protected _internalRender(effect: Effect): void;
  112889. /**
  112890. * Sets the required values for both the emissive texture and and the main color.
  112891. */
  112892. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112893. /**
  112894. * Returns true if the mesh should render, otherwise false.
  112895. * @param mesh The mesh to render
  112896. * @returns true if it should render otherwise false
  112897. */
  112898. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112899. /**
  112900. * Adds specific effects defines.
  112901. * @param defines The defines to add specifics to.
  112902. */
  112903. protected _addCustomEffectDefines(defines: string[]): void;
  112904. /**
  112905. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112906. * @param mesh The mesh to exclude from the glow layer
  112907. */
  112908. addExcludedMesh(mesh: Mesh): void;
  112909. /**
  112910. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112911. * @param mesh The mesh to remove
  112912. */
  112913. removeExcludedMesh(mesh: Mesh): void;
  112914. /**
  112915. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112916. * @param mesh The mesh to include in the glow layer
  112917. */
  112918. addIncludedOnlyMesh(mesh: Mesh): void;
  112919. /**
  112920. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112921. * @param mesh The mesh to remove
  112922. */
  112923. removeIncludedOnlyMesh(mesh: Mesh): void;
  112924. /**
  112925. * Determine if a given mesh will be used in the glow layer
  112926. * @param mesh The mesh to test
  112927. * @returns true if the mesh will be highlighted by the current glow layer
  112928. */
  112929. hasMesh(mesh: AbstractMesh): boolean;
  112930. /**
  112931. * Free any resources and references associated to a mesh.
  112932. * Internal use
  112933. * @param mesh The mesh to free.
  112934. * @hidden
  112935. */
  112936. _disposeMesh(mesh: Mesh): void;
  112937. /**
  112938. * Gets the class name of the effect layer
  112939. * @returns the string with the class name of the effect layer
  112940. */
  112941. getClassName(): string;
  112942. /**
  112943. * Serializes this glow layer
  112944. * @returns a serialized glow layer object
  112945. */
  112946. serialize(): any;
  112947. /**
  112948. * Creates a Glow Layer from parsed glow layer data
  112949. * @param parsedGlowLayer defines glow layer data
  112950. * @param scene defines the current scene
  112951. * @param rootUrl defines the root URL containing the glow layer information
  112952. * @returns a parsed Glow Layer
  112953. */
  112954. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112955. }
  112956. }
  112957. declare module BABYLON {
  112958. /** @hidden */
  112959. export var glowBlurPostProcessPixelShader: {
  112960. name: string;
  112961. shader: string;
  112962. };
  112963. }
  112964. declare module BABYLON {
  112965. interface AbstractScene {
  112966. /**
  112967. * Return a the first highlight layer of the scene with a given name.
  112968. * @param name The name of the highlight layer to look for.
  112969. * @return The highlight layer if found otherwise null.
  112970. */
  112971. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112972. }
  112973. /**
  112974. * Highlight layer options. This helps customizing the behaviour
  112975. * of the highlight layer.
  112976. */
  112977. export interface IHighlightLayerOptions {
  112978. /**
  112979. * Multiplication factor apply to the canvas size to compute the render target size
  112980. * used to generated the glowing objects (the smaller the faster).
  112981. */
  112982. mainTextureRatio: number;
  112983. /**
  112984. * Enforces a fixed size texture to ensure resize independant blur.
  112985. */
  112986. mainTextureFixedSize?: number;
  112987. /**
  112988. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112989. * of the picture to blur (the smaller the faster).
  112990. */
  112991. blurTextureSizeRatio: number;
  112992. /**
  112993. * How big in texel of the blur texture is the vertical blur.
  112994. */
  112995. blurVerticalSize: number;
  112996. /**
  112997. * How big in texel of the blur texture is the horizontal blur.
  112998. */
  112999. blurHorizontalSize: number;
  113000. /**
  113001. * Alpha blending mode used to apply the blur. Default is combine.
  113002. */
  113003. alphaBlendingMode: number;
  113004. /**
  113005. * The camera attached to the layer.
  113006. */
  113007. camera: Nullable<Camera>;
  113008. /**
  113009. * Should we display highlight as a solid stroke?
  113010. */
  113011. isStroke?: boolean;
  113012. /**
  113013. * The rendering group to draw the layer in.
  113014. */
  113015. renderingGroupId: number;
  113016. }
  113017. /**
  113018. * The highlight layer Helps adding a glow effect around a mesh.
  113019. *
  113020. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113021. * glowy meshes to your scene.
  113022. *
  113023. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113024. */
  113025. export class HighlightLayer extends EffectLayer {
  113026. name: string;
  113027. /**
  113028. * Effect Name of the highlight layer.
  113029. */
  113030. static readonly EffectName: string;
  113031. /**
  113032. * The neutral color used during the preparation of the glow effect.
  113033. * This is black by default as the blend operation is a blend operation.
  113034. */
  113035. static NeutralColor: Color4;
  113036. /**
  113037. * Stencil value used for glowing meshes.
  113038. */
  113039. static GlowingMeshStencilReference: number;
  113040. /**
  113041. * Stencil value used for the other meshes in the scene.
  113042. */
  113043. static NormalMeshStencilReference: number;
  113044. /**
  113045. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113046. */
  113047. innerGlow: boolean;
  113048. /**
  113049. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113050. */
  113051. outerGlow: boolean;
  113052. /**
  113053. * Specifies the horizontal size of the blur.
  113054. */
  113055. /**
  113056. * Gets the horizontal size of the blur.
  113057. */
  113058. blurHorizontalSize: number;
  113059. /**
  113060. * Specifies the vertical size of the blur.
  113061. */
  113062. /**
  113063. * Gets the vertical size of the blur.
  113064. */
  113065. blurVerticalSize: number;
  113066. /**
  113067. * An event triggered when the highlight layer is being blurred.
  113068. */
  113069. onBeforeBlurObservable: Observable<HighlightLayer>;
  113070. /**
  113071. * An event triggered when the highlight layer has been blurred.
  113072. */
  113073. onAfterBlurObservable: Observable<HighlightLayer>;
  113074. private _instanceGlowingMeshStencilReference;
  113075. private _options;
  113076. private _downSamplePostprocess;
  113077. private _horizontalBlurPostprocess;
  113078. private _verticalBlurPostprocess;
  113079. private _blurTexture;
  113080. private _meshes;
  113081. private _excludedMeshes;
  113082. /**
  113083. * Instantiates a new highlight Layer and references it to the scene..
  113084. * @param name The name of the layer
  113085. * @param scene The scene to use the layer in
  113086. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113087. */
  113088. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113089. /**
  113090. * Get the effect name of the layer.
  113091. * @return The effect name
  113092. */
  113093. getEffectName(): string;
  113094. /**
  113095. * Create the merge effect. This is the shader use to blit the information back
  113096. * to the main canvas at the end of the scene rendering.
  113097. */
  113098. protected _createMergeEffect(): Effect;
  113099. /**
  113100. * Creates the render target textures and post processes used in the highlight layer.
  113101. */
  113102. protected _createTextureAndPostProcesses(): void;
  113103. /**
  113104. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113105. */
  113106. needStencil(): boolean;
  113107. /**
  113108. * Checks for the readiness of the element composing the layer.
  113109. * @param subMesh the mesh to check for
  113110. * @param useInstances specify wether or not to use instances to render the mesh
  113111. * @param emissiveTexture the associated emissive texture used to generate the glow
  113112. * @return true if ready otherwise, false
  113113. */
  113114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113115. /**
  113116. * Implementation specific of rendering the generating effect on the main canvas.
  113117. * @param effect The effect used to render through
  113118. */
  113119. protected _internalRender(effect: Effect): void;
  113120. /**
  113121. * Returns true if the layer contains information to display, otherwise false.
  113122. */
  113123. shouldRender(): boolean;
  113124. /**
  113125. * Returns true if the mesh should render, otherwise false.
  113126. * @param mesh The mesh to render
  113127. * @returns true if it should render otherwise false
  113128. */
  113129. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113130. /**
  113131. * Sets the required values for both the emissive texture and and the main color.
  113132. */
  113133. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113134. /**
  113135. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113136. * @param mesh The mesh to exclude from the highlight layer
  113137. */
  113138. addExcludedMesh(mesh: Mesh): void;
  113139. /**
  113140. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113141. * @param mesh The mesh to highlight
  113142. */
  113143. removeExcludedMesh(mesh: Mesh): void;
  113144. /**
  113145. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113146. * @param mesh mesh to test
  113147. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113148. */
  113149. hasMesh(mesh: AbstractMesh): boolean;
  113150. /**
  113151. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113152. * @param mesh The mesh to highlight
  113153. * @param color The color of the highlight
  113154. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113155. */
  113156. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113157. /**
  113158. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113159. * @param mesh The mesh to highlight
  113160. */
  113161. removeMesh(mesh: Mesh): void;
  113162. /**
  113163. * Force the stencil to the normal expected value for none glowing parts
  113164. */
  113165. private _defaultStencilReference;
  113166. /**
  113167. * Free any resources and references associated to a mesh.
  113168. * Internal use
  113169. * @param mesh The mesh to free.
  113170. * @hidden
  113171. */
  113172. _disposeMesh(mesh: Mesh): void;
  113173. /**
  113174. * Dispose the highlight layer and free resources.
  113175. */
  113176. dispose(): void;
  113177. /**
  113178. * Gets the class name of the effect layer
  113179. * @returns the string with the class name of the effect layer
  113180. */
  113181. getClassName(): string;
  113182. /**
  113183. * Serializes this Highlight layer
  113184. * @returns a serialized Highlight layer object
  113185. */
  113186. serialize(): any;
  113187. /**
  113188. * Creates a Highlight layer from parsed Highlight layer data
  113189. * @param parsedHightlightLayer defines the Highlight layer data
  113190. * @param scene defines the current scene
  113191. * @param rootUrl defines the root URL containing the Highlight layer information
  113192. * @returns a parsed Highlight layer
  113193. */
  113194. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113195. }
  113196. }
  113197. declare module BABYLON {
  113198. interface AbstractScene {
  113199. /**
  113200. * The list of layers (background and foreground) of the scene
  113201. */
  113202. layers: Array<Layer>;
  113203. }
  113204. /**
  113205. * Defines the layer scene component responsible to manage any layers
  113206. * in a given scene.
  113207. */
  113208. export class LayerSceneComponent implements ISceneComponent {
  113209. /**
  113210. * The component name helpfull to identify the component in the list of scene components.
  113211. */
  113212. readonly name: string;
  113213. /**
  113214. * The scene the component belongs to.
  113215. */
  113216. scene: Scene;
  113217. private _engine;
  113218. /**
  113219. * Creates a new instance of the component for the given scene
  113220. * @param scene Defines the scene to register the component in
  113221. */
  113222. constructor(scene: Scene);
  113223. /**
  113224. * Registers the component in a given scene
  113225. */
  113226. register(): void;
  113227. /**
  113228. * Rebuilds the elements related to this component in case of
  113229. * context lost for instance.
  113230. */
  113231. rebuild(): void;
  113232. /**
  113233. * Disposes the component and the associated ressources.
  113234. */
  113235. dispose(): void;
  113236. private _draw;
  113237. private _drawCameraPredicate;
  113238. private _drawCameraBackground;
  113239. private _drawCameraForeground;
  113240. private _drawRenderTargetPredicate;
  113241. private _drawRenderTargetBackground;
  113242. private _drawRenderTargetForeground;
  113243. /**
  113244. * Adds all the elements from the container to the scene
  113245. * @param container the container holding the elements
  113246. */
  113247. addFromContainer(container: AbstractScene): void;
  113248. /**
  113249. * Removes all the elements in the container from the scene
  113250. * @param container contains the elements to remove
  113251. * @param dispose if the removed element should be disposed (default: false)
  113252. */
  113253. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113254. }
  113255. }
  113256. declare module BABYLON {
  113257. /** @hidden */
  113258. export var layerPixelShader: {
  113259. name: string;
  113260. shader: string;
  113261. };
  113262. }
  113263. declare module BABYLON {
  113264. /** @hidden */
  113265. export var layerVertexShader: {
  113266. name: string;
  113267. shader: string;
  113268. };
  113269. }
  113270. declare module BABYLON {
  113271. /**
  113272. * This represents a full screen 2d layer.
  113273. * This can be useful to display a picture in the background of your scene for instance.
  113274. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113275. */
  113276. export class Layer {
  113277. /**
  113278. * Define the name of the layer.
  113279. */
  113280. name: string;
  113281. /**
  113282. * Define the texture the layer should display.
  113283. */
  113284. texture: Nullable<Texture>;
  113285. /**
  113286. * Is the layer in background or foreground.
  113287. */
  113288. isBackground: boolean;
  113289. /**
  113290. * Define the color of the layer (instead of texture).
  113291. */
  113292. color: Color4;
  113293. /**
  113294. * Define the scale of the layer in order to zoom in out of the texture.
  113295. */
  113296. scale: Vector2;
  113297. /**
  113298. * Define an offset for the layer in order to shift the texture.
  113299. */
  113300. offset: Vector2;
  113301. /**
  113302. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113303. */
  113304. alphaBlendingMode: number;
  113305. /**
  113306. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113307. * Alpha test will not mix with the background color in case of transparency.
  113308. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113309. */
  113310. alphaTest: boolean;
  113311. /**
  113312. * Define a mask to restrict the layer to only some of the scene cameras.
  113313. */
  113314. layerMask: number;
  113315. /**
  113316. * Define the list of render target the layer is visible into.
  113317. */
  113318. renderTargetTextures: RenderTargetTexture[];
  113319. /**
  113320. * Define if the layer is only used in renderTarget or if it also
  113321. * renders in the main frame buffer of the canvas.
  113322. */
  113323. renderOnlyInRenderTargetTextures: boolean;
  113324. private _scene;
  113325. private _vertexBuffers;
  113326. private _indexBuffer;
  113327. private _effect;
  113328. private _alphaTestEffect;
  113329. /**
  113330. * An event triggered when the layer is disposed.
  113331. */
  113332. onDisposeObservable: Observable<Layer>;
  113333. private _onDisposeObserver;
  113334. /**
  113335. * Back compatibility with callback before the onDisposeObservable existed.
  113336. * The set callback will be triggered when the layer has been disposed.
  113337. */
  113338. onDispose: () => void;
  113339. /**
  113340. * An event triggered before rendering the scene
  113341. */
  113342. onBeforeRenderObservable: Observable<Layer>;
  113343. private _onBeforeRenderObserver;
  113344. /**
  113345. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113346. * The set callback will be triggered just before rendering the layer.
  113347. */
  113348. onBeforeRender: () => void;
  113349. /**
  113350. * An event triggered after rendering the scene
  113351. */
  113352. onAfterRenderObservable: Observable<Layer>;
  113353. private _onAfterRenderObserver;
  113354. /**
  113355. * Back compatibility with callback before the onAfterRenderObservable existed.
  113356. * The set callback will be triggered just after rendering the layer.
  113357. */
  113358. onAfterRender: () => void;
  113359. /**
  113360. * Instantiates a new layer.
  113361. * This represents a full screen 2d layer.
  113362. * This can be useful to display a picture in the background of your scene for instance.
  113363. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113364. * @param name Define the name of the layer in the scene
  113365. * @param imgUrl Define the url of the texture to display in the layer
  113366. * @param scene Define the scene the layer belongs to
  113367. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113368. * @param color Defines a color for the layer
  113369. */
  113370. constructor(
  113371. /**
  113372. * Define the name of the layer.
  113373. */
  113374. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113375. private _createIndexBuffer;
  113376. /** @hidden */
  113377. _rebuild(): void;
  113378. /**
  113379. * Renders the layer in the scene.
  113380. */
  113381. render(): void;
  113382. /**
  113383. * Disposes and releases the associated ressources.
  113384. */
  113385. dispose(): void;
  113386. }
  113387. }
  113388. declare module BABYLON {
  113389. /** @hidden */
  113390. export var lensFlarePixelShader: {
  113391. name: string;
  113392. shader: string;
  113393. };
  113394. }
  113395. declare module BABYLON {
  113396. /** @hidden */
  113397. export var lensFlareVertexShader: {
  113398. name: string;
  113399. shader: string;
  113400. };
  113401. }
  113402. declare module BABYLON {
  113403. /**
  113404. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113405. * It is usually composed of several `lensFlare`.
  113406. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113407. */
  113408. export class LensFlareSystem {
  113409. /**
  113410. * Define the name of the lens flare system
  113411. */
  113412. name: string;
  113413. /**
  113414. * List of lens flares used in this system.
  113415. */
  113416. lensFlares: LensFlare[];
  113417. /**
  113418. * Define a limit from the border the lens flare can be visible.
  113419. */
  113420. borderLimit: number;
  113421. /**
  113422. * Define a viewport border we do not want to see the lens flare in.
  113423. */
  113424. viewportBorder: number;
  113425. /**
  113426. * Define a predicate which could limit the list of meshes able to occlude the effect.
  113427. */
  113428. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113429. /**
  113430. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  113431. */
  113432. layerMask: number;
  113433. /**
  113434. * Define the id of the lens flare system in the scene.
  113435. * (equal to name by default)
  113436. */
  113437. id: string;
  113438. private _scene;
  113439. private _emitter;
  113440. private _vertexBuffers;
  113441. private _indexBuffer;
  113442. private _effect;
  113443. private _positionX;
  113444. private _positionY;
  113445. private _isEnabled;
  113446. /** @hidden */
  113447. static _SceneComponentInitialization: (scene: Scene) => void;
  113448. /**
  113449. * Instantiates a lens flare system.
  113450. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113451. * It is usually composed of several `lensFlare`.
  113452. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113453. * @param name Define the name of the lens flare system in the scene
  113454. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  113455. * @param scene Define the scene the lens flare system belongs to
  113456. */
  113457. constructor(
  113458. /**
  113459. * Define the name of the lens flare system
  113460. */
  113461. name: string, emitter: any, scene: Scene);
  113462. /**
  113463. * Define if the lens flare system is enabled.
  113464. */
  113465. isEnabled: boolean;
  113466. /**
  113467. * Get the scene the effects belongs to.
  113468. * @returns the scene holding the lens flare system
  113469. */
  113470. getScene(): Scene;
  113471. /**
  113472. * Get the emitter of the lens flare system.
  113473. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113474. * @returns the emitter of the lens flare system
  113475. */
  113476. getEmitter(): any;
  113477. /**
  113478. * Set the emitter of the lens flare system.
  113479. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113480. * @param newEmitter Define the new emitter of the system
  113481. */
  113482. setEmitter(newEmitter: any): void;
  113483. /**
  113484. * Get the lens flare system emitter position.
  113485. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113486. * @returns the position
  113487. */
  113488. getEmitterPosition(): Vector3;
  113489. /**
  113490. * @hidden
  113491. */
  113492. computeEffectivePosition(globalViewport: Viewport): boolean;
  113493. /** @hidden */
  113494. _isVisible(): boolean;
  113495. /**
  113496. * @hidden
  113497. */
  113498. render(): boolean;
  113499. /**
  113500. * Dispose and release the lens flare with its associated resources.
  113501. */
  113502. dispose(): void;
  113503. /**
  113504. * Parse a lens flare system from a JSON repressentation
  113505. * @param parsedLensFlareSystem Define the JSON to parse
  113506. * @param scene Define the scene the parsed system should be instantiated in
  113507. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113508. * @returns the parsed system
  113509. */
  113510. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113511. /**
  113512. * Serialize the current Lens Flare System into a JSON representation.
  113513. * @returns the serialized JSON
  113514. */
  113515. serialize(): any;
  113516. }
  113517. }
  113518. declare module BABYLON {
  113519. /**
  113520. * This represents one of the lens effect in a `lensFlareSystem`.
  113521. * It controls one of the indiviual texture used in the effect.
  113522. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113523. */
  113524. export class LensFlare {
  113525. /**
  113526. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113527. */
  113528. size: number;
  113529. /**
  113530. * 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.
  113531. */
  113532. position: number;
  113533. /**
  113534. * Define the lens color.
  113535. */
  113536. color: Color3;
  113537. /**
  113538. * Define the lens texture.
  113539. */
  113540. texture: Nullable<Texture>;
  113541. /**
  113542. * Define the alpha mode to render this particular lens.
  113543. */
  113544. alphaMode: number;
  113545. private _system;
  113546. /**
  113547. * Creates a new Lens Flare.
  113548. * This represents one of the lens effect in a `lensFlareSystem`.
  113549. * It controls one of the indiviual texture used in the effect.
  113550. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113551. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113552. * @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.
  113553. * @param color Define the lens color
  113554. * @param imgUrl Define the lens texture url
  113555. * @param system Define the `lensFlareSystem` this flare is part of
  113556. * @returns The newly created Lens Flare
  113557. */
  113558. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113559. /**
  113560. * Instantiates a new Lens Flare.
  113561. * This represents one of the lens effect in a `lensFlareSystem`.
  113562. * It controls one of the indiviual texture used in the effect.
  113563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113564. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113565. * @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.
  113566. * @param color Define the lens color
  113567. * @param imgUrl Define the lens texture url
  113568. * @param system Define the `lensFlareSystem` this flare is part of
  113569. */
  113570. constructor(
  113571. /**
  113572. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113573. */
  113574. size: number,
  113575. /**
  113576. * 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.
  113577. */
  113578. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  113579. /**
  113580. * Dispose and release the lens flare with its associated resources.
  113581. */
  113582. dispose(): void;
  113583. }
  113584. }
  113585. declare module BABYLON {
  113586. interface AbstractScene {
  113587. /**
  113588. * The list of lens flare system added to the scene
  113589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113590. */
  113591. lensFlareSystems: Array<LensFlareSystem>;
  113592. /**
  113593. * Removes the given lens flare system from this scene.
  113594. * @param toRemove The lens flare system to remove
  113595. * @returns The index of the removed lens flare system
  113596. */
  113597. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113598. /**
  113599. * Adds the given lens flare system to this scene
  113600. * @param newLensFlareSystem The lens flare system to add
  113601. */
  113602. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113603. /**
  113604. * Gets a lens flare system using its name
  113605. * @param name defines the name to look for
  113606. * @returns the lens flare system or null if not found
  113607. */
  113608. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113609. /**
  113610. * Gets a lens flare system using its id
  113611. * @param id defines the id to look for
  113612. * @returns the lens flare system or null if not found
  113613. */
  113614. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113615. }
  113616. /**
  113617. * Defines the lens flare scene component responsible to manage any lens flares
  113618. * in a given scene.
  113619. */
  113620. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113621. /**
  113622. * The component name helpfull to identify the component in the list of scene components.
  113623. */
  113624. readonly name: string;
  113625. /**
  113626. * The scene the component belongs to.
  113627. */
  113628. scene: Scene;
  113629. /**
  113630. * Creates a new instance of the component for the given scene
  113631. * @param scene Defines the scene to register the component in
  113632. */
  113633. constructor(scene: Scene);
  113634. /**
  113635. * Registers the component in a given scene
  113636. */
  113637. register(): void;
  113638. /**
  113639. * Rebuilds the elements related to this component in case of
  113640. * context lost for instance.
  113641. */
  113642. rebuild(): void;
  113643. /**
  113644. * Adds all the elements from the container to the scene
  113645. * @param container the container holding the elements
  113646. */
  113647. addFromContainer(container: AbstractScene): void;
  113648. /**
  113649. * Removes all the elements in the container from the scene
  113650. * @param container contains the elements to remove
  113651. * @param dispose if the removed element should be disposed (default: false)
  113652. */
  113653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113654. /**
  113655. * Serializes the component data to the specified json object
  113656. * @param serializationObject The object to serialize to
  113657. */
  113658. serialize(serializationObject: any): void;
  113659. /**
  113660. * Disposes the component and the associated ressources.
  113661. */
  113662. dispose(): void;
  113663. private _draw;
  113664. }
  113665. }
  113666. declare module BABYLON {
  113667. /**
  113668. * Defines the shadow generator component responsible to manage any shadow generators
  113669. * in a given scene.
  113670. */
  113671. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113672. /**
  113673. * The component name helpfull to identify the component in the list of scene components.
  113674. */
  113675. readonly name: string;
  113676. /**
  113677. * The scene the component belongs to.
  113678. */
  113679. scene: Scene;
  113680. /**
  113681. * Creates a new instance of the component for the given scene
  113682. * @param scene Defines the scene to register the component in
  113683. */
  113684. constructor(scene: Scene);
  113685. /**
  113686. * Registers the component in a given scene
  113687. */
  113688. register(): void;
  113689. /**
  113690. * Rebuilds the elements related to this component in case of
  113691. * context lost for instance.
  113692. */
  113693. rebuild(): void;
  113694. /**
  113695. * Serializes the component data to the specified json object
  113696. * @param serializationObject The object to serialize to
  113697. */
  113698. serialize(serializationObject: any): void;
  113699. /**
  113700. * Adds all the elements from the container to the scene
  113701. * @param container the container holding the elements
  113702. */
  113703. addFromContainer(container: AbstractScene): void;
  113704. /**
  113705. * Removes all the elements in the container from the scene
  113706. * @param container contains the elements to remove
  113707. * @param dispose if the removed element should be disposed (default: false)
  113708. */
  113709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113710. /**
  113711. * Rebuilds the elements related to this component in case of
  113712. * context lost for instance.
  113713. */
  113714. dispose(): void;
  113715. private _gatherRenderTargets;
  113716. }
  113717. }
  113718. declare module BABYLON {
  113719. /**
  113720. * A point light is a light defined by an unique point in world space.
  113721. * The light is emitted in every direction from this point.
  113722. * A good example of a point light is a standard light bulb.
  113723. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113724. */
  113725. export class PointLight extends ShadowLight {
  113726. private _shadowAngle;
  113727. /**
  113728. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113729. * This specifies what angle the shadow will use to be created.
  113730. *
  113731. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113732. */
  113733. /**
  113734. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113735. * This specifies what angle the shadow will use to be created.
  113736. *
  113737. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113738. */
  113739. shadowAngle: number;
  113740. /**
  113741. * Gets the direction if it has been set.
  113742. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113743. */
  113744. /**
  113745. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113746. */
  113747. direction: Vector3;
  113748. /**
  113749. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113750. * A PointLight emits the light in every direction.
  113751. * It can cast shadows.
  113752. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113753. * ```javascript
  113754. * var pointLight = new PointLight("pl", camera.position, scene);
  113755. * ```
  113756. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113757. * @param name The light friendly name
  113758. * @param position The position of the point light in the scene
  113759. * @param scene The scene the lights belongs to
  113760. */
  113761. constructor(name: string, position: Vector3, scene: Scene);
  113762. /**
  113763. * Returns the string "PointLight"
  113764. * @returns the class name
  113765. */
  113766. getClassName(): string;
  113767. /**
  113768. * Returns the integer 0.
  113769. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113770. */
  113771. getTypeID(): number;
  113772. /**
  113773. * Specifies wether or not the shadowmap should be a cube texture.
  113774. * @returns true if the shadowmap needs to be a cube texture.
  113775. */
  113776. needCube(): boolean;
  113777. /**
  113778. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113779. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113780. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113781. */
  113782. getShadowDirection(faceIndex?: number): Vector3;
  113783. /**
  113784. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113785. * - fov = PI / 2
  113786. * - aspect ratio : 1.0
  113787. * - z-near and far equal to the active camera minZ and maxZ.
  113788. * Returns the PointLight.
  113789. */
  113790. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113791. protected _buildUniformLayout(): void;
  113792. /**
  113793. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113794. * @param effect The effect to update
  113795. * @param lightIndex The index of the light in the effect to update
  113796. * @returns The point light
  113797. */
  113798. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113799. /**
  113800. * Prepares the list of defines specific to the light type.
  113801. * @param defines the list of defines
  113802. * @param lightIndex defines the index of the light for the effect
  113803. */
  113804. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113805. }
  113806. }
  113807. declare module BABYLON {
  113808. /**
  113809. * Header information of HDR texture files.
  113810. */
  113811. export interface HDRInfo {
  113812. /**
  113813. * The height of the texture in pixels.
  113814. */
  113815. height: number;
  113816. /**
  113817. * The width of the texture in pixels.
  113818. */
  113819. width: number;
  113820. /**
  113821. * The index of the beginning of the data in the binary file.
  113822. */
  113823. dataPosition: number;
  113824. }
  113825. /**
  113826. * This groups tools to convert HDR texture to native colors array.
  113827. */
  113828. export class HDRTools {
  113829. private static Ldexp;
  113830. private static Rgbe2float;
  113831. private static readStringLine;
  113832. /**
  113833. * Reads header information from an RGBE texture stored in a native array.
  113834. * More information on this format are available here:
  113835. * https://en.wikipedia.org/wiki/RGBE_image_format
  113836. *
  113837. * @param uint8array The binary file stored in native array.
  113838. * @return The header information.
  113839. */
  113840. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113841. /**
  113842. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113843. * This RGBE texture needs to store the information as a panorama.
  113844. *
  113845. * More information on this format are available here:
  113846. * https://en.wikipedia.org/wiki/RGBE_image_format
  113847. *
  113848. * @param buffer The binary file stored in an array buffer.
  113849. * @param size The expected size of the extracted cubemap.
  113850. * @return The Cube Map information.
  113851. */
  113852. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113853. /**
  113854. * Returns the pixels data extracted from an RGBE texture.
  113855. * This pixels will be stored left to right up to down in the R G B order in one array.
  113856. *
  113857. * More information on this format are available here:
  113858. * https://en.wikipedia.org/wiki/RGBE_image_format
  113859. *
  113860. * @param uint8array The binary file stored in an array buffer.
  113861. * @param hdrInfo The header information of the file.
  113862. * @return The pixels data in RGB right to left up to down order.
  113863. */
  113864. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113865. private static RGBE_ReadPixels_RLE;
  113866. }
  113867. }
  113868. declare module BABYLON {
  113869. /**
  113870. * This represents a texture coming from an HDR input.
  113871. *
  113872. * The only supported format is currently panorama picture stored in RGBE format.
  113873. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113874. */
  113875. export class HDRCubeTexture extends BaseTexture {
  113876. private static _facesMapping;
  113877. private _generateHarmonics;
  113878. private _noMipmap;
  113879. private _textureMatrix;
  113880. private _size;
  113881. private _onLoad;
  113882. private _onError;
  113883. /**
  113884. * The texture URL.
  113885. */
  113886. url: string;
  113887. /**
  113888. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113889. */
  113890. coordinatesMode: number;
  113891. protected _isBlocking: boolean;
  113892. /**
  113893. * Sets wether or not the texture is blocking during loading.
  113894. */
  113895. /**
  113896. * Gets wether or not the texture is blocking during loading.
  113897. */
  113898. isBlocking: boolean;
  113899. protected _rotationY: number;
  113900. /**
  113901. * Sets texture matrix rotation angle around Y axis in radians.
  113902. */
  113903. /**
  113904. * Gets texture matrix rotation angle around Y axis radians.
  113905. */
  113906. rotationY: number;
  113907. /**
  113908. * Gets or sets the center of the bounding box associated with the cube texture
  113909. * It must define where the camera used to render the texture was set
  113910. */
  113911. boundingBoxPosition: Vector3;
  113912. private _boundingBoxSize;
  113913. /**
  113914. * Gets or sets the size of the bounding box associated with the cube texture
  113915. * When defined, the cubemap will switch to local mode
  113916. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113917. * @example https://www.babylonjs-playground.com/#RNASML
  113918. */
  113919. boundingBoxSize: Vector3;
  113920. /**
  113921. * Instantiates an HDRTexture from the following parameters.
  113922. *
  113923. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113924. * @param scene The scene the texture will be used in
  113925. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113926. * @param noMipmap Forces to not generate the mipmap if true
  113927. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113928. * @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)
  113929. * @param reserved Reserved flag for internal use.
  113930. */
  113931. 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>);
  113932. /**
  113933. * Get the current class name of the texture useful for serialization or dynamic coding.
  113934. * @returns "HDRCubeTexture"
  113935. */
  113936. getClassName(): string;
  113937. /**
  113938. * Occurs when the file is raw .hdr file.
  113939. */
  113940. private loadTexture;
  113941. clone(): HDRCubeTexture;
  113942. delayLoad(): void;
  113943. /**
  113944. * Get the texture reflection matrix used to rotate/transform the reflection.
  113945. * @returns the reflection matrix
  113946. */
  113947. getReflectionTextureMatrix(): Matrix;
  113948. /**
  113949. * Set the texture reflection matrix used to rotate/transform the reflection.
  113950. * @param value Define the reflection matrix to set
  113951. */
  113952. setReflectionTextureMatrix(value: Matrix): void;
  113953. /**
  113954. * Parses a JSON representation of an HDR Texture in order to create the texture
  113955. * @param parsedTexture Define the JSON representation
  113956. * @param scene Define the scene the texture should be created in
  113957. * @param rootUrl Define the root url in case we need to load relative dependencies
  113958. * @returns the newly created texture after parsing
  113959. */
  113960. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113961. serialize(): any;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * Class used to control physics engine
  113967. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113968. */
  113969. export class PhysicsEngine implements IPhysicsEngine {
  113970. private _physicsPlugin;
  113971. /**
  113972. * Global value used to control the smallest number supported by the simulation
  113973. */
  113974. static Epsilon: number;
  113975. private _impostors;
  113976. private _joints;
  113977. /**
  113978. * Gets the gravity vector used by the simulation
  113979. */
  113980. gravity: Vector3;
  113981. /**
  113982. * Factory used to create the default physics plugin.
  113983. * @returns The default physics plugin
  113984. */
  113985. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113986. /**
  113987. * Creates a new Physics Engine
  113988. * @param gravity defines the gravity vector used by the simulation
  113989. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113990. */
  113991. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113992. /**
  113993. * Sets the gravity vector used by the simulation
  113994. * @param gravity defines the gravity vector to use
  113995. */
  113996. setGravity(gravity: Vector3): void;
  113997. /**
  113998. * Set the time step of the physics engine.
  113999. * Default is 1/60.
  114000. * To slow it down, enter 1/600 for example.
  114001. * To speed it up, 1/30
  114002. * @param newTimeStep defines the new timestep to apply to this world.
  114003. */
  114004. setTimeStep(newTimeStep?: number): void;
  114005. /**
  114006. * Get the time step of the physics engine.
  114007. * @returns the current time step
  114008. */
  114009. getTimeStep(): number;
  114010. /**
  114011. * Release all resources
  114012. */
  114013. dispose(): void;
  114014. /**
  114015. * Gets the name of the current physics plugin
  114016. * @returns the name of the plugin
  114017. */
  114018. getPhysicsPluginName(): string;
  114019. /**
  114020. * Adding a new impostor for the impostor tracking.
  114021. * This will be done by the impostor itself.
  114022. * @param impostor the impostor to add
  114023. */
  114024. addImpostor(impostor: PhysicsImpostor): void;
  114025. /**
  114026. * Remove an impostor from the engine.
  114027. * This impostor and its mesh will not longer be updated by the physics engine.
  114028. * @param impostor the impostor to remove
  114029. */
  114030. removeImpostor(impostor: PhysicsImpostor): void;
  114031. /**
  114032. * Add a joint to the physics engine
  114033. * @param mainImpostor defines the main impostor to which the joint is added.
  114034. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114035. * @param joint defines the joint that will connect both impostors.
  114036. */
  114037. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114038. /**
  114039. * Removes a joint from the simulation
  114040. * @param mainImpostor defines the impostor used with the joint
  114041. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114042. * @param joint defines the joint to remove
  114043. */
  114044. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114045. /**
  114046. * Called by the scene. No need to call it.
  114047. * @param delta defines the timespam between frames
  114048. */
  114049. _step(delta: number): void;
  114050. /**
  114051. * Gets the current plugin used to run the simulation
  114052. * @returns current plugin
  114053. */
  114054. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114055. /**
  114056. * Gets the list of physic impostors
  114057. * @returns an array of PhysicsImpostor
  114058. */
  114059. getImpostors(): Array<PhysicsImpostor>;
  114060. /**
  114061. * Gets the impostor for a physics enabled object
  114062. * @param object defines the object impersonated by the impostor
  114063. * @returns the PhysicsImpostor or null if not found
  114064. */
  114065. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114066. /**
  114067. * Gets the impostor for a physics body object
  114068. * @param body defines physics body used by the impostor
  114069. * @returns the PhysicsImpostor or null if not found
  114070. */
  114071. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114072. /**
  114073. * Does a raycast in the physics world
  114074. * @param from when should the ray start?
  114075. * @param to when should the ray end?
  114076. * @returns PhysicsRaycastResult
  114077. */
  114078. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114079. }
  114080. }
  114081. declare module BABYLON {
  114082. /** @hidden */
  114083. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114084. private _useDeltaForWorldStep;
  114085. world: any;
  114086. name: string;
  114087. private _physicsMaterials;
  114088. private _fixedTimeStep;
  114089. private _cannonRaycastResult;
  114090. private _raycastResult;
  114091. private _physicsBodysToRemoveAfterStep;
  114092. BJSCANNON: any;
  114093. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114094. setGravity(gravity: Vector3): void;
  114095. setTimeStep(timeStep: number): void;
  114096. getTimeStep(): number;
  114097. executeStep(delta: number): void;
  114098. private _removeMarkedPhysicsBodiesFromWorld;
  114099. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114100. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114101. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114102. private _processChildMeshes;
  114103. removePhysicsBody(impostor: PhysicsImpostor): void;
  114104. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114105. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114106. private _addMaterial;
  114107. private _checkWithEpsilon;
  114108. private _createShape;
  114109. private _createHeightmap;
  114110. private _minus90X;
  114111. private _plus90X;
  114112. private _tmpPosition;
  114113. private _tmpDeltaPosition;
  114114. private _tmpUnityRotation;
  114115. private _updatePhysicsBodyTransformation;
  114116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114117. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114118. isSupported(): boolean;
  114119. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114120. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114121. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114122. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114123. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114124. getBodyMass(impostor: PhysicsImpostor): number;
  114125. getBodyFriction(impostor: PhysicsImpostor): number;
  114126. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114127. getBodyRestitution(impostor: PhysicsImpostor): number;
  114128. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114129. sleepBody(impostor: PhysicsImpostor): void;
  114130. wakeUpBody(impostor: PhysicsImpostor): void;
  114131. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114132. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114133. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114135. getRadius(impostor: PhysicsImpostor): number;
  114136. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114137. dispose(): void;
  114138. private _extendNamespace;
  114139. /**
  114140. * Does a raycast in the physics world
  114141. * @param from when should the ray start?
  114142. * @param to when should the ray end?
  114143. * @returns PhysicsRaycastResult
  114144. */
  114145. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114146. }
  114147. }
  114148. declare module BABYLON {
  114149. /** @hidden */
  114150. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114151. world: any;
  114152. name: string;
  114153. BJSOIMO: any;
  114154. private _raycastResult;
  114155. constructor(iterations?: number, oimoInjection?: any);
  114156. setGravity(gravity: Vector3): void;
  114157. setTimeStep(timeStep: number): void;
  114158. getTimeStep(): number;
  114159. private _tmpImpostorsArray;
  114160. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114161. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114162. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114163. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114164. private _tmpPositionVector;
  114165. removePhysicsBody(impostor: PhysicsImpostor): void;
  114166. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114167. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114168. isSupported(): boolean;
  114169. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114170. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114171. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114172. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114173. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114174. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114175. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114176. getBodyMass(impostor: PhysicsImpostor): number;
  114177. getBodyFriction(impostor: PhysicsImpostor): number;
  114178. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114179. getBodyRestitution(impostor: PhysicsImpostor): number;
  114180. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114181. sleepBody(impostor: PhysicsImpostor): void;
  114182. wakeUpBody(impostor: PhysicsImpostor): void;
  114183. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114184. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114185. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114186. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114187. getRadius(impostor: PhysicsImpostor): number;
  114188. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114189. dispose(): void;
  114190. /**
  114191. * Does a raycast in the physics world
  114192. * @param from when should the ray start?
  114193. * @param to when should the ray end?
  114194. * @returns PhysicsRaycastResult
  114195. */
  114196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114197. }
  114198. }
  114199. declare module BABYLON {
  114200. /**
  114201. * Class containing static functions to help procedurally build meshes
  114202. */
  114203. export class RibbonBuilder {
  114204. /**
  114205. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114206. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114207. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114208. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114209. * * 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
  114210. * * 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
  114211. * * 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
  114212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114215. * * 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
  114216. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114217. * * 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
  114218. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114220. * @param name defines the name of the mesh
  114221. * @param options defines the options used to create the mesh
  114222. * @param scene defines the hosting scene
  114223. * @returns the ribbon mesh
  114224. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114226. */
  114227. static CreateRibbon(name: string, options: {
  114228. pathArray: Vector3[][];
  114229. closeArray?: boolean;
  114230. closePath?: boolean;
  114231. offset?: number;
  114232. updatable?: boolean;
  114233. sideOrientation?: number;
  114234. frontUVs?: Vector4;
  114235. backUVs?: Vector4;
  114236. instance?: Mesh;
  114237. invertUV?: boolean;
  114238. uvs?: Vector2[];
  114239. colors?: Color4[];
  114240. }, scene?: Nullable<Scene>): Mesh;
  114241. }
  114242. }
  114243. declare module BABYLON {
  114244. /**
  114245. * Class containing static functions to help procedurally build meshes
  114246. */
  114247. export class ShapeBuilder {
  114248. /**
  114249. * 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.
  114250. * * 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.
  114251. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114252. * * 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.
  114253. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114254. * * 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
  114255. * * 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
  114256. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114261. * @param name defines the name of the mesh
  114262. * @param options defines the options used to create the mesh
  114263. * @param scene defines the hosting scene
  114264. * @returns the extruded shape mesh
  114265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114267. */
  114268. static ExtrudeShape(name: string, options: {
  114269. shape: Vector3[];
  114270. path: Vector3[];
  114271. scale?: number;
  114272. rotation?: number;
  114273. cap?: number;
  114274. updatable?: boolean;
  114275. sideOrientation?: number;
  114276. frontUVs?: Vector4;
  114277. backUVs?: Vector4;
  114278. instance?: Mesh;
  114279. invertUV?: boolean;
  114280. }, scene?: Nullable<Scene>): Mesh;
  114281. /**
  114282. * Creates an custom extruded shape mesh.
  114283. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114284. * * 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.
  114285. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114286. * * 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
  114287. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114288. * * 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
  114289. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114290. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114291. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114292. * * 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
  114293. * * 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
  114294. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114299. * @param name defines the name of the mesh
  114300. * @param options defines the options used to create the mesh
  114301. * @param scene defines the hosting scene
  114302. * @returns the custom extruded shape mesh
  114303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114306. */
  114307. static ExtrudeShapeCustom(name: string, options: {
  114308. shape: Vector3[];
  114309. path: Vector3[];
  114310. scaleFunction?: any;
  114311. rotationFunction?: any;
  114312. ribbonCloseArray?: boolean;
  114313. ribbonClosePath?: boolean;
  114314. cap?: number;
  114315. updatable?: boolean;
  114316. sideOrientation?: number;
  114317. frontUVs?: Vector4;
  114318. backUVs?: Vector4;
  114319. instance?: Mesh;
  114320. invertUV?: boolean;
  114321. }, scene?: Nullable<Scene>): Mesh;
  114322. private static _ExtrudeShapeGeneric;
  114323. }
  114324. }
  114325. declare module BABYLON {
  114326. /**
  114327. * AmmoJS Physics plugin
  114328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114329. * @see https://github.com/kripken/ammo.js/
  114330. */
  114331. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114332. private _useDeltaForWorldStep;
  114333. /**
  114334. * Reference to the Ammo library
  114335. */
  114336. bjsAMMO: any;
  114337. /**
  114338. * Created ammoJS world which physics bodies are added to
  114339. */
  114340. world: any;
  114341. /**
  114342. * Name of the plugin
  114343. */
  114344. name: string;
  114345. private _timeStep;
  114346. private _fixedTimeStep;
  114347. private _maxSteps;
  114348. private _tmpQuaternion;
  114349. private _tmpAmmoTransform;
  114350. private _tmpAmmoQuaternion;
  114351. private _tmpAmmoConcreteContactResultCallback;
  114352. private _collisionConfiguration;
  114353. private _dispatcher;
  114354. private _overlappingPairCache;
  114355. private _solver;
  114356. private _softBodySolver;
  114357. private _tmpAmmoVectorA;
  114358. private _tmpAmmoVectorB;
  114359. private _tmpAmmoVectorC;
  114360. private _tmpAmmoVectorD;
  114361. private _tmpContactCallbackResult;
  114362. private _tmpAmmoVectorRCA;
  114363. private _tmpAmmoVectorRCB;
  114364. private _raycastResult;
  114365. private static readonly DISABLE_COLLISION_FLAG;
  114366. private static readonly KINEMATIC_FLAG;
  114367. private static readonly DISABLE_DEACTIVATION_FLAG;
  114368. /**
  114369. * Initializes the ammoJS plugin
  114370. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114371. * @param ammoInjection can be used to inject your own ammo reference
  114372. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114373. */
  114374. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114375. /**
  114376. * Sets the gravity of the physics world (m/(s^2))
  114377. * @param gravity Gravity to set
  114378. */
  114379. setGravity(gravity: Vector3): void;
  114380. /**
  114381. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114382. * @param timeStep timestep to use in seconds
  114383. */
  114384. setTimeStep(timeStep: number): void;
  114385. /**
  114386. * 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)
  114387. * @param fixedTimeStep fixedTimeStep to use in seconds
  114388. */
  114389. setFixedTimeStep(fixedTimeStep: number): void;
  114390. /**
  114391. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114392. * @param maxSteps the maximum number of steps by the physics engine per frame
  114393. */
  114394. setMaxSteps(maxSteps: number): void;
  114395. /**
  114396. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114397. * @returns the current timestep in seconds
  114398. */
  114399. getTimeStep(): number;
  114400. private _isImpostorInContact;
  114401. private _isImpostorPairInContact;
  114402. private _stepSimulation;
  114403. /**
  114404. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114405. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114406. * After the step the babylon meshes are set to the position of the physics imposters
  114407. * @param delta amount of time to step forward
  114408. * @param impostors array of imposters to update before/after the step
  114409. */
  114410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114411. /**
  114412. * Update babylon mesh to match physics world object
  114413. * @param impostor imposter to match
  114414. */
  114415. private _afterSoftStep;
  114416. /**
  114417. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114418. * @param impostor imposter to match
  114419. */
  114420. private _ropeStep;
  114421. /**
  114422. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114423. * @param impostor imposter to match
  114424. */
  114425. private _softbodyOrClothStep;
  114426. private _tmpVector;
  114427. private _tmpMatrix;
  114428. /**
  114429. * Applies an impulse on the imposter
  114430. * @param impostor imposter to apply impulse to
  114431. * @param force amount of force to be applied to the imposter
  114432. * @param contactPoint the location to apply the impulse on the imposter
  114433. */
  114434. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114435. /**
  114436. * Applies a force on the imposter
  114437. * @param impostor imposter to apply force
  114438. * @param force amount of force to be applied to the imposter
  114439. * @param contactPoint the location to apply the force on the imposter
  114440. */
  114441. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114442. /**
  114443. * Creates a physics body using the plugin
  114444. * @param impostor the imposter to create the physics body on
  114445. */
  114446. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114447. /**
  114448. * Removes the physics body from the imposter and disposes of the body's memory
  114449. * @param impostor imposter to remove the physics body from
  114450. */
  114451. removePhysicsBody(impostor: PhysicsImpostor): void;
  114452. /**
  114453. * Generates a joint
  114454. * @param impostorJoint the imposter joint to create the joint with
  114455. */
  114456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114457. /**
  114458. * Removes a joint
  114459. * @param impostorJoint the imposter joint to remove the joint from
  114460. */
  114461. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114462. private _addMeshVerts;
  114463. /**
  114464. * Initialise the soft body vertices to match its object's (mesh) vertices
  114465. * Softbody vertices (nodes) are in world space and to match this
  114466. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114467. * @param impostor to create the softbody for
  114468. */
  114469. private _softVertexData;
  114470. /**
  114471. * Create an impostor's soft body
  114472. * @param impostor to create the softbody for
  114473. */
  114474. private _createSoftbody;
  114475. /**
  114476. * Create cloth for an impostor
  114477. * @param impostor to create the softbody for
  114478. */
  114479. private _createCloth;
  114480. /**
  114481. * Create rope for an impostor
  114482. * @param impostor to create the softbody for
  114483. */
  114484. private _createRope;
  114485. private _addHullVerts;
  114486. private _createShape;
  114487. /**
  114488. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114489. * @param impostor imposter containing the physics body and babylon object
  114490. */
  114491. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114492. /**
  114493. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114494. * @param impostor imposter containing the physics body and babylon object
  114495. * @param newPosition new position
  114496. * @param newRotation new rotation
  114497. */
  114498. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114499. /**
  114500. * If this plugin is supported
  114501. * @returns true if its supported
  114502. */
  114503. isSupported(): boolean;
  114504. /**
  114505. * Sets the linear velocity of the physics body
  114506. * @param impostor imposter to set the velocity on
  114507. * @param velocity velocity to set
  114508. */
  114509. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114510. /**
  114511. * Sets the angular velocity of the physics body
  114512. * @param impostor imposter to set the velocity on
  114513. * @param velocity velocity to set
  114514. */
  114515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114516. /**
  114517. * gets the linear velocity
  114518. * @param impostor imposter to get linear velocity from
  114519. * @returns linear velocity
  114520. */
  114521. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114522. /**
  114523. * gets the angular velocity
  114524. * @param impostor imposter to get angular velocity from
  114525. * @returns angular velocity
  114526. */
  114527. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114528. /**
  114529. * Sets the mass of physics body
  114530. * @param impostor imposter to set the mass on
  114531. * @param mass mass to set
  114532. */
  114533. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114534. /**
  114535. * Gets the mass of the physics body
  114536. * @param impostor imposter to get the mass from
  114537. * @returns mass
  114538. */
  114539. getBodyMass(impostor: PhysicsImpostor): number;
  114540. /**
  114541. * Gets friction of the impostor
  114542. * @param impostor impostor to get friction from
  114543. * @returns friction value
  114544. */
  114545. getBodyFriction(impostor: PhysicsImpostor): number;
  114546. /**
  114547. * Sets friction of the impostor
  114548. * @param impostor impostor to set friction on
  114549. * @param friction friction value
  114550. */
  114551. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114552. /**
  114553. * Gets restitution of the impostor
  114554. * @param impostor impostor to get restitution from
  114555. * @returns restitution value
  114556. */
  114557. getBodyRestitution(impostor: PhysicsImpostor): number;
  114558. /**
  114559. * Sets resitution of the impostor
  114560. * @param impostor impostor to set resitution on
  114561. * @param restitution resitution value
  114562. */
  114563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114564. /**
  114565. * Gets pressure inside the impostor
  114566. * @param impostor impostor to get pressure from
  114567. * @returns pressure value
  114568. */
  114569. getBodyPressure(impostor: PhysicsImpostor): number;
  114570. /**
  114571. * Sets pressure inside a soft body impostor
  114572. * Cloth and rope must remain 0 pressure
  114573. * @param impostor impostor to set pressure on
  114574. * @param pressure pressure value
  114575. */
  114576. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  114577. /**
  114578. * Gets stiffness of the impostor
  114579. * @param impostor impostor to get stiffness from
  114580. * @returns pressure value
  114581. */
  114582. getBodyStiffness(impostor: PhysicsImpostor): number;
  114583. /**
  114584. * Sets stiffness of the impostor
  114585. * @param impostor impostor to set stiffness on
  114586. * @param stiffness stiffness value from 0 to 1
  114587. */
  114588. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114589. /**
  114590. * Gets velocityIterations of the impostor
  114591. * @param impostor impostor to get velocity iterations from
  114592. * @returns velocityIterations value
  114593. */
  114594. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114595. /**
  114596. * Sets velocityIterations of the impostor
  114597. * @param impostor impostor to set velocity iterations on
  114598. * @param velocityIterations velocityIterations value
  114599. */
  114600. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114601. /**
  114602. * Gets positionIterations of the impostor
  114603. * @param impostor impostor to get position iterations from
  114604. * @returns positionIterations value
  114605. */
  114606. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114607. /**
  114608. * Sets positionIterations of the impostor
  114609. * @param impostor impostor to set position on
  114610. * @param positionIterations positionIterations value
  114611. */
  114612. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114613. /**
  114614. * Append an anchor to a cloth object
  114615. * @param impostor is the cloth impostor to add anchor to
  114616. * @param otherImpostor is the rigid impostor to anchor to
  114617. * @param width ratio across width from 0 to 1
  114618. * @param height ratio up height from 0 to 1
  114619. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114620. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114621. */
  114622. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114623. /**
  114624. * Append an hook to a rope object
  114625. * @param impostor is the rope impostor to add hook to
  114626. * @param otherImpostor is the rigid impostor to hook to
  114627. * @param length ratio along the rope from 0 to 1
  114628. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114629. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114630. */
  114631. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114632. /**
  114633. * Sleeps the physics body and stops it from being active
  114634. * @param impostor impostor to sleep
  114635. */
  114636. sleepBody(impostor: PhysicsImpostor): void;
  114637. /**
  114638. * Activates the physics body
  114639. * @param impostor impostor to activate
  114640. */
  114641. wakeUpBody(impostor: PhysicsImpostor): void;
  114642. /**
  114643. * Updates the distance parameters of the joint
  114644. * @param joint joint to update
  114645. * @param maxDistance maximum distance of the joint
  114646. * @param minDistance minimum distance of the joint
  114647. */
  114648. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114649. /**
  114650. * Sets a motor on the joint
  114651. * @param joint joint to set motor on
  114652. * @param speed speed of the motor
  114653. * @param maxForce maximum force of the motor
  114654. * @param motorIndex index of the motor
  114655. */
  114656. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114657. /**
  114658. * Sets the motors limit
  114659. * @param joint joint to set limit on
  114660. * @param upperLimit upper limit
  114661. * @param lowerLimit lower limit
  114662. */
  114663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114664. /**
  114665. * Syncs the position and rotation of a mesh with the impostor
  114666. * @param mesh mesh to sync
  114667. * @param impostor impostor to update the mesh with
  114668. */
  114669. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114670. /**
  114671. * Gets the radius of the impostor
  114672. * @param impostor impostor to get radius from
  114673. * @returns the radius
  114674. */
  114675. getRadius(impostor: PhysicsImpostor): number;
  114676. /**
  114677. * Gets the box size of the impostor
  114678. * @param impostor impostor to get box size from
  114679. * @param result the resulting box size
  114680. */
  114681. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114682. /**
  114683. * Disposes of the impostor
  114684. */
  114685. dispose(): void;
  114686. /**
  114687. * Does a raycast in the physics world
  114688. * @param from when should the ray start?
  114689. * @param to when should the ray end?
  114690. * @returns PhysicsRaycastResult
  114691. */
  114692. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114693. }
  114694. }
  114695. declare module BABYLON {
  114696. interface AbstractScene {
  114697. /**
  114698. * The list of reflection probes added to the scene
  114699. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114700. */
  114701. reflectionProbes: Array<ReflectionProbe>;
  114702. /**
  114703. * Removes the given reflection probe from this scene.
  114704. * @param toRemove The reflection probe to remove
  114705. * @returns The index of the removed reflection probe
  114706. */
  114707. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114708. /**
  114709. * Adds the given reflection probe to this scene.
  114710. * @param newReflectionProbe The reflection probe to add
  114711. */
  114712. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114713. }
  114714. /**
  114715. * Class used to generate realtime reflection / refraction cube textures
  114716. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114717. */
  114718. export class ReflectionProbe {
  114719. /** defines the name of the probe */
  114720. name: string;
  114721. private _scene;
  114722. private _renderTargetTexture;
  114723. private _projectionMatrix;
  114724. private _viewMatrix;
  114725. private _target;
  114726. private _add;
  114727. private _attachedMesh;
  114728. private _invertYAxis;
  114729. /** Gets or sets probe position (center of the cube map) */
  114730. position: Vector3;
  114731. /**
  114732. * Creates a new reflection probe
  114733. * @param name defines the name of the probe
  114734. * @param size defines the texture resolution (for each face)
  114735. * @param scene defines the hosting scene
  114736. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114737. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114738. */
  114739. constructor(
  114740. /** defines the name of the probe */
  114741. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114742. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114743. samples: number;
  114744. /** Gets or sets the refresh rate to use (on every frame by default) */
  114745. refreshRate: number;
  114746. /**
  114747. * Gets the hosting scene
  114748. * @returns a Scene
  114749. */
  114750. getScene(): Scene;
  114751. /** Gets the internal CubeTexture used to render to */
  114752. readonly cubeTexture: RenderTargetTexture;
  114753. /** Gets the list of meshes to render */
  114754. readonly renderList: Nullable<AbstractMesh[]>;
  114755. /**
  114756. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114757. * @param mesh defines the mesh to attach to
  114758. */
  114759. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114760. /**
  114761. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114762. * @param renderingGroupId The rendering group id corresponding to its index
  114763. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114764. */
  114765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114766. /**
  114767. * Clean all associated resources
  114768. */
  114769. dispose(): void;
  114770. /**
  114771. * Converts the reflection probe information to a readable string for debug purpose.
  114772. * @param fullDetails Supports for multiple levels of logging within scene loading
  114773. * @returns the human readable reflection probe info
  114774. */
  114775. toString(fullDetails?: boolean): string;
  114776. /**
  114777. * Get the class name of the relfection probe.
  114778. * @returns "ReflectionProbe"
  114779. */
  114780. getClassName(): string;
  114781. /**
  114782. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114783. * @returns The JSON representation of the texture
  114784. */
  114785. serialize(): any;
  114786. /**
  114787. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114788. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114789. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114790. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114791. * @returns The parsed reflection probe if successful
  114792. */
  114793. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114794. }
  114795. }
  114796. declare module BABYLON {
  114797. /** @hidden */
  114798. export var _BabylonLoaderRegistered: boolean;
  114799. }
  114800. declare module BABYLON {
  114801. /**
  114802. * The Physically based simple base material of BJS.
  114803. *
  114804. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114805. * It is used as the base class for both the specGloss and metalRough conventions.
  114806. */
  114807. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114808. /**
  114809. * Number of Simultaneous lights allowed on the material.
  114810. */
  114811. maxSimultaneousLights: number;
  114812. /**
  114813. * If sets to true, disables all the lights affecting the material.
  114814. */
  114815. disableLighting: boolean;
  114816. /**
  114817. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114818. */
  114819. environmentTexture: BaseTexture;
  114820. /**
  114821. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114822. */
  114823. invertNormalMapX: boolean;
  114824. /**
  114825. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114826. */
  114827. invertNormalMapY: boolean;
  114828. /**
  114829. * Normal map used in the model.
  114830. */
  114831. normalTexture: BaseTexture;
  114832. /**
  114833. * Emissivie color used to self-illuminate the model.
  114834. */
  114835. emissiveColor: Color3;
  114836. /**
  114837. * Emissivie texture used to self-illuminate the model.
  114838. */
  114839. emissiveTexture: BaseTexture;
  114840. /**
  114841. * Occlusion Channel Strenght.
  114842. */
  114843. occlusionStrength: number;
  114844. /**
  114845. * Occlusion Texture of the material (adding extra occlusion effects).
  114846. */
  114847. occlusionTexture: BaseTexture;
  114848. /**
  114849. * Defines the alpha limits in alpha test mode.
  114850. */
  114851. alphaCutOff: number;
  114852. /**
  114853. * Gets the current double sided mode.
  114854. */
  114855. /**
  114856. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114857. */
  114858. doubleSided: boolean;
  114859. /**
  114860. * Stores the pre-calculated light information of a mesh in a texture.
  114861. */
  114862. lightmapTexture: BaseTexture;
  114863. /**
  114864. * If true, the light map contains occlusion information instead of lighting info.
  114865. */
  114866. useLightmapAsShadowmap: boolean;
  114867. /**
  114868. * Instantiates a new PBRMaterial instance.
  114869. *
  114870. * @param name The material name
  114871. * @param scene The scene the material will be use in.
  114872. */
  114873. constructor(name: string, scene: Scene);
  114874. getClassName(): string;
  114875. }
  114876. }
  114877. declare module BABYLON {
  114878. /**
  114879. * The PBR material of BJS following the metal roughness convention.
  114880. *
  114881. * This fits to the PBR convention in the GLTF definition:
  114882. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114883. */
  114884. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114885. /**
  114886. * The base color has two different interpretations depending on the value of metalness.
  114887. * When the material is a metal, the base color is the specific measured reflectance value
  114888. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114889. * of the material.
  114890. */
  114891. baseColor: Color3;
  114892. /**
  114893. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114894. * well as opacity information in the alpha channel.
  114895. */
  114896. baseTexture: BaseTexture;
  114897. /**
  114898. * Specifies the metallic scalar value of the material.
  114899. * Can also be used to scale the metalness values of the metallic texture.
  114900. */
  114901. metallic: number;
  114902. /**
  114903. * Specifies the roughness scalar value of the material.
  114904. * Can also be used to scale the roughness values of the metallic texture.
  114905. */
  114906. roughness: number;
  114907. /**
  114908. * Texture containing both the metallic value in the B channel and the
  114909. * roughness value in the G channel to keep better precision.
  114910. */
  114911. metallicRoughnessTexture: BaseTexture;
  114912. /**
  114913. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114914. *
  114915. * @param name The material name
  114916. * @param scene The scene the material will be use in.
  114917. */
  114918. constructor(name: string, scene: Scene);
  114919. /**
  114920. * Return the currrent class name of the material.
  114921. */
  114922. getClassName(): string;
  114923. /**
  114924. * Makes a duplicate of the current material.
  114925. * @param name - name to use for the new material.
  114926. */
  114927. clone(name: string): PBRMetallicRoughnessMaterial;
  114928. /**
  114929. * Serialize the material to a parsable JSON object.
  114930. */
  114931. serialize(): any;
  114932. /**
  114933. * Parses a JSON object correponding to the serialize function.
  114934. */
  114935. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114936. }
  114937. }
  114938. declare module BABYLON {
  114939. /**
  114940. * The PBR material of BJS following the specular glossiness convention.
  114941. *
  114942. * This fits to the PBR convention in the GLTF definition:
  114943. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114944. */
  114945. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114946. /**
  114947. * Specifies the diffuse color of the material.
  114948. */
  114949. diffuseColor: Color3;
  114950. /**
  114951. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114952. * channel.
  114953. */
  114954. diffuseTexture: BaseTexture;
  114955. /**
  114956. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114957. */
  114958. specularColor: Color3;
  114959. /**
  114960. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114961. */
  114962. glossiness: number;
  114963. /**
  114964. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114965. */
  114966. specularGlossinessTexture: BaseTexture;
  114967. /**
  114968. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114969. *
  114970. * @param name The material name
  114971. * @param scene The scene the material will be use in.
  114972. */
  114973. constructor(name: string, scene: Scene);
  114974. /**
  114975. * Return the currrent class name of the material.
  114976. */
  114977. getClassName(): string;
  114978. /**
  114979. * Makes a duplicate of the current material.
  114980. * @param name - name to use for the new material.
  114981. */
  114982. clone(name: string): PBRSpecularGlossinessMaterial;
  114983. /**
  114984. * Serialize the material to a parsable JSON object.
  114985. */
  114986. serialize(): any;
  114987. /**
  114988. * Parses a JSON object correponding to the serialize function.
  114989. */
  114990. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114991. }
  114992. }
  114993. declare module BABYLON {
  114994. /**
  114995. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114996. * It can help converting any input color in a desired output one. This can then be used to create effects
  114997. * from sepia, black and white to sixties or futuristic rendering...
  114998. *
  114999. * The only supported format is currently 3dl.
  115000. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115001. */
  115002. export class ColorGradingTexture extends BaseTexture {
  115003. /**
  115004. * The current texture matrix. (will always be identity in color grading texture)
  115005. */
  115006. private _textureMatrix;
  115007. /**
  115008. * The texture URL.
  115009. */
  115010. url: string;
  115011. /**
  115012. * Empty line regex stored for GC.
  115013. */
  115014. private static _noneEmptyLineRegex;
  115015. private _engine;
  115016. /**
  115017. * Instantiates a ColorGradingTexture from the following parameters.
  115018. *
  115019. * @param url The location of the color gradind data (currently only supporting 3dl)
  115020. * @param scene The scene the texture will be used in
  115021. */
  115022. constructor(url: string, scene: Scene);
  115023. /**
  115024. * Returns the texture matrix used in most of the material.
  115025. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115026. */
  115027. getTextureMatrix(): Matrix;
  115028. /**
  115029. * Occurs when the file being loaded is a .3dl LUT file.
  115030. */
  115031. private load3dlTexture;
  115032. /**
  115033. * Starts the loading process of the texture.
  115034. */
  115035. private loadTexture;
  115036. /**
  115037. * Clones the color gradind texture.
  115038. */
  115039. clone(): ColorGradingTexture;
  115040. /**
  115041. * Called during delayed load for textures.
  115042. */
  115043. delayLoad(): void;
  115044. /**
  115045. * Parses a color grading texture serialized by Babylon.
  115046. * @param parsedTexture The texture information being parsedTexture
  115047. * @param scene The scene to load the texture in
  115048. * @param rootUrl The root url of the data assets to load
  115049. * @return A color gradind texture
  115050. */
  115051. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115052. /**
  115053. * Serializes the LUT texture to json format.
  115054. */
  115055. serialize(): any;
  115056. }
  115057. }
  115058. declare module BABYLON {
  115059. /**
  115060. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115061. */
  115062. export class EquiRectangularCubeTexture extends BaseTexture {
  115063. /** The six faces of the cube. */
  115064. private static _FacesMapping;
  115065. private _noMipmap;
  115066. private _onLoad;
  115067. private _onError;
  115068. /** The size of the cubemap. */
  115069. private _size;
  115070. /** The buffer of the image. */
  115071. private _buffer;
  115072. /** The width of the input image. */
  115073. private _width;
  115074. /** The height of the input image. */
  115075. private _height;
  115076. /** The URL to the image. */
  115077. url: string;
  115078. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115079. coordinatesMode: number;
  115080. /**
  115081. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115082. * @param url The location of the image
  115083. * @param scene The scene the texture will be used in
  115084. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115085. * @param noMipmap Forces to not generate the mipmap if true
  115086. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115087. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115088. * @param onLoad — defines a callback called when texture is loaded
  115089. * @param onError — defines a callback called if there is an error
  115090. */
  115091. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115092. /**
  115093. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115094. */
  115095. private loadImage;
  115096. /**
  115097. * Convert the image buffer into a cubemap and create a CubeTexture.
  115098. */
  115099. private loadTexture;
  115100. /**
  115101. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115102. * @param buffer The ArrayBuffer that should be converted.
  115103. * @returns The buffer as Float32Array.
  115104. */
  115105. private getFloat32ArrayFromArrayBuffer;
  115106. /**
  115107. * Get the current class name of the texture useful for serialization or dynamic coding.
  115108. * @returns "EquiRectangularCubeTexture"
  115109. */
  115110. getClassName(): string;
  115111. /**
  115112. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115113. * @returns A clone of the current EquiRectangularCubeTexture.
  115114. */
  115115. clone(): EquiRectangularCubeTexture;
  115116. }
  115117. }
  115118. declare module BABYLON {
  115119. /**
  115120. * Based on jsTGALoader - Javascript loader for TGA file
  115121. * By Vincent Thibault
  115122. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115123. */
  115124. export class TGATools {
  115125. private static _TYPE_INDEXED;
  115126. private static _TYPE_RGB;
  115127. private static _TYPE_GREY;
  115128. private static _TYPE_RLE_INDEXED;
  115129. private static _TYPE_RLE_RGB;
  115130. private static _TYPE_RLE_GREY;
  115131. private static _ORIGIN_MASK;
  115132. private static _ORIGIN_SHIFT;
  115133. private static _ORIGIN_BL;
  115134. private static _ORIGIN_BR;
  115135. private static _ORIGIN_UL;
  115136. private static _ORIGIN_UR;
  115137. /**
  115138. * Gets the header of a TGA file
  115139. * @param data defines the TGA data
  115140. * @returns the header
  115141. */
  115142. static GetTGAHeader(data: Uint8Array): any;
  115143. /**
  115144. * Uploads TGA content to a Babylon Texture
  115145. * @hidden
  115146. */
  115147. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115148. /** @hidden */
  115149. 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;
  115150. /** @hidden */
  115151. 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;
  115152. /** @hidden */
  115153. 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;
  115154. /** @hidden */
  115155. 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;
  115156. /** @hidden */
  115157. 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;
  115158. /** @hidden */
  115159. 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;
  115160. }
  115161. }
  115162. declare module BABYLON {
  115163. /**
  115164. * Implementation of the TGA Texture Loader.
  115165. * @hidden
  115166. */
  115167. export class _TGATextureLoader implements IInternalTextureLoader {
  115168. /**
  115169. * Defines wether the loader supports cascade loading the different faces.
  115170. */
  115171. readonly supportCascades: boolean;
  115172. /**
  115173. * This returns if the loader support the current file information.
  115174. * @param extension defines the file extension of the file being loaded
  115175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115176. * @param fallback defines the fallback internal texture if any
  115177. * @param isBase64 defines whether the texture is encoded as a base64
  115178. * @param isBuffer defines whether the texture data are stored as a buffer
  115179. * @returns true if the loader can load the specified file
  115180. */
  115181. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115182. /**
  115183. * Transform the url before loading if required.
  115184. * @param rootUrl the url of the texture
  115185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115186. * @returns the transformed texture
  115187. */
  115188. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115189. /**
  115190. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115191. * @param rootUrl the url of the texture
  115192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115193. * @returns the fallback texture
  115194. */
  115195. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115196. /**
  115197. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115198. * @param data contains the texture data
  115199. * @param texture defines the BabylonJS internal texture
  115200. * @param createPolynomials will be true if polynomials have been requested
  115201. * @param onLoad defines the callback to trigger once the texture is ready
  115202. * @param onError defines the callback to trigger in case of error
  115203. */
  115204. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115205. /**
  115206. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115207. * @param data contains the texture data
  115208. * @param texture defines the BabylonJS internal texture
  115209. * @param callback defines the method to call once ready to upload
  115210. */
  115211. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115212. }
  115213. }
  115214. declare module BABYLON {
  115215. /**
  115216. * Info about the .basis files
  115217. */
  115218. class BasisFileInfo {
  115219. /**
  115220. * If the file has alpha
  115221. */
  115222. hasAlpha: boolean;
  115223. /**
  115224. * Info about each image of the basis file
  115225. */
  115226. images: Array<{
  115227. levels: Array<{
  115228. width: number;
  115229. height: number;
  115230. transcodedPixels: ArrayBufferView;
  115231. }>;
  115232. }>;
  115233. }
  115234. /**
  115235. * Result of transcoding a basis file
  115236. */
  115237. class TranscodeResult {
  115238. /**
  115239. * Info about the .basis file
  115240. */
  115241. fileInfo: BasisFileInfo;
  115242. /**
  115243. * Format to use when loading the file
  115244. */
  115245. format: number;
  115246. }
  115247. /**
  115248. * Configuration options for the Basis transcoder
  115249. */
  115250. export class BasisTranscodeConfiguration {
  115251. /**
  115252. * Supported compression formats used to determine the supported output format of the transcoder
  115253. */
  115254. supportedCompressionFormats?: {
  115255. /**
  115256. * etc1 compression format
  115257. */
  115258. etc1?: boolean;
  115259. /**
  115260. * s3tc compression format
  115261. */
  115262. s3tc?: boolean;
  115263. /**
  115264. * pvrtc compression format
  115265. */
  115266. pvrtc?: boolean;
  115267. /**
  115268. * etc2 compression format
  115269. */
  115270. etc2?: boolean;
  115271. };
  115272. /**
  115273. * If mipmap levels should be loaded for transcoded images (Default: true)
  115274. */
  115275. loadMipmapLevels?: boolean;
  115276. /**
  115277. * Index of a single image to load (Default: all images)
  115278. */
  115279. loadSingleImage?: number;
  115280. }
  115281. /**
  115282. * Used to load .Basis files
  115283. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115284. */
  115285. export class BasisTools {
  115286. private static _IgnoreSupportedFormats;
  115287. /**
  115288. * URL to use when loading the basis transcoder
  115289. */
  115290. static JSModuleURL: string;
  115291. /**
  115292. * URL to use when loading the wasm module for the transcoder
  115293. */
  115294. static WasmModuleURL: string;
  115295. /**
  115296. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115297. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115298. * @returns internal format corresponding to the Basis format
  115299. */
  115300. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115301. private static _WorkerPromise;
  115302. private static _Worker;
  115303. private static _actionId;
  115304. private static _CreateWorkerAsync;
  115305. /**
  115306. * Transcodes a loaded image file to compressed pixel data
  115307. * @param imageData image data to transcode
  115308. * @param config configuration options for the transcoding
  115309. * @returns a promise resulting in the transcoded image
  115310. */
  115311. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115312. /**
  115313. * Loads a texture from the transcode result
  115314. * @param texture texture load to
  115315. * @param transcodeResult the result of transcoding the basis file to load from
  115316. */
  115317. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115318. }
  115319. }
  115320. declare module BABYLON {
  115321. /**
  115322. * Loader for .basis file format
  115323. */
  115324. export class _BasisTextureLoader implements IInternalTextureLoader {
  115325. /**
  115326. * Defines whether the loader supports cascade loading the different faces.
  115327. */
  115328. readonly supportCascades: boolean;
  115329. /**
  115330. * This returns if the loader support the current file information.
  115331. * @param extension defines the file extension of the file being loaded
  115332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115333. * @param fallback defines the fallback internal texture if any
  115334. * @param isBase64 defines whether the texture is encoded as a base64
  115335. * @param isBuffer defines whether the texture data are stored as a buffer
  115336. * @returns true if the loader can load the specified file
  115337. */
  115338. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115339. /**
  115340. * Transform the url before loading if required.
  115341. * @param rootUrl the url of the texture
  115342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115343. * @returns the transformed texture
  115344. */
  115345. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115346. /**
  115347. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115348. * @param rootUrl the url of the texture
  115349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115350. * @returns the fallback texture
  115351. */
  115352. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115353. /**
  115354. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115355. * @param data contains the texture data
  115356. * @param texture defines the BabylonJS internal texture
  115357. * @param createPolynomials will be true if polynomials have been requested
  115358. * @param onLoad defines the callback to trigger once the texture is ready
  115359. * @param onError defines the callback to trigger in case of error
  115360. */
  115361. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115362. /**
  115363. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115364. * @param data contains the texture data
  115365. * @param texture defines the BabylonJS internal texture
  115366. * @param callback defines the method to call once ready to upload
  115367. */
  115368. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115369. }
  115370. }
  115371. declare module BABYLON {
  115372. /**
  115373. * 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.
  115374. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115376. */
  115377. export class CustomProceduralTexture extends ProceduralTexture {
  115378. private _animate;
  115379. private _time;
  115380. private _config;
  115381. private _texturePath;
  115382. /**
  115383. * Instantiates a new Custom Procedural Texture.
  115384. * 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.
  115385. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115386. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115387. * @param name Define the name of the texture
  115388. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115389. * @param size Define the size of the texture to create
  115390. * @param scene Define the scene the texture belongs to
  115391. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115392. * @param generateMipMaps Define if the texture should creates mip maps or not
  115393. */
  115394. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115395. private _loadJson;
  115396. /**
  115397. * Is the texture ready to be used ? (rendered at least once)
  115398. * @returns true if ready, otherwise, false.
  115399. */
  115400. isReady(): boolean;
  115401. /**
  115402. * Render the texture to its associated render target.
  115403. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  115404. */
  115405. render(useCameraPostProcess?: boolean): void;
  115406. /**
  115407. * Update the list of dependant textures samplers in the shader.
  115408. */
  115409. updateTextures(): void;
  115410. /**
  115411. * Update the uniform values of the procedural texture in the shader.
  115412. */
  115413. updateShaderUniforms(): void;
  115414. /**
  115415. * Define if the texture animates or not.
  115416. */
  115417. animate: boolean;
  115418. }
  115419. }
  115420. declare module BABYLON {
  115421. /** @hidden */
  115422. export var noisePixelShader: {
  115423. name: string;
  115424. shader: string;
  115425. };
  115426. }
  115427. declare module BABYLON {
  115428. /**
  115429. * Class used to generate noise procedural textures
  115430. */
  115431. export class NoiseProceduralTexture extends ProceduralTexture {
  115432. private _time;
  115433. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  115434. brightness: number;
  115435. /** Defines the number of octaves to process */
  115436. octaves: number;
  115437. /** Defines the level of persistence (0.8 by default) */
  115438. persistence: number;
  115439. /** Gets or sets animation speed factor (default is 1) */
  115440. animationSpeedFactor: number;
  115441. /**
  115442. * Creates a new NoiseProceduralTexture
  115443. * @param name defines the name fo the texture
  115444. * @param size defines the size of the texture (default is 256)
  115445. * @param scene defines the hosting scene
  115446. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  115447. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  115448. */
  115449. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115450. private _updateShaderUniforms;
  115451. protected _getDefines(): string;
  115452. /** Generate the current state of the procedural texture */
  115453. render(useCameraPostProcess?: boolean): void;
  115454. /**
  115455. * Serializes this noise procedural texture
  115456. * @returns a serialized noise procedural texture object
  115457. */
  115458. serialize(): any;
  115459. /**
  115460. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  115461. * @param parsedTexture defines parsed texture data
  115462. * @param scene defines the current scene
  115463. * @param rootUrl defines the root URL containing noise procedural texture information
  115464. * @returns a parsed NoiseProceduralTexture
  115465. */
  115466. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  115467. }
  115468. }
  115469. declare module BABYLON {
  115470. /**
  115471. * Raw cube texture where the raw buffers are passed in
  115472. */
  115473. export class RawCubeTexture extends CubeTexture {
  115474. /**
  115475. * Creates a cube texture where the raw buffers are passed in.
  115476. * @param scene defines the scene the texture is attached to
  115477. * @param data defines the array of data to use to create each face
  115478. * @param size defines the size of the textures
  115479. * @param format defines the format of the data
  115480. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115481. * @param generateMipMaps defines if the engine should generate the mip levels
  115482. * @param invertY defines if data must be stored with Y axis inverted
  115483. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115484. * @param compression defines the compression used (null by default)
  115485. */
  115486. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115487. /**
  115488. * Updates the raw cube texture.
  115489. * @param data defines the data to store
  115490. * @param format defines the data format
  115491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115492. * @param invertY defines if data must be stored with Y axis inverted
  115493. * @param compression defines the compression used (null by default)
  115494. * @param level defines which level of the texture to update
  115495. */
  115496. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115497. /**
  115498. * Updates a raw cube texture with RGBD encoded data.
  115499. * @param data defines the array of data [mipmap][face] to use to create each face
  115500. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115503. * @returns a promsie that resolves when the operation is complete
  115504. */
  115505. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115506. /**
  115507. * Clones the raw cube texture.
  115508. * @return a new cube texture
  115509. */
  115510. clone(): CubeTexture;
  115511. /** @hidden */
  115512. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115513. }
  115514. }
  115515. declare module BABYLON {
  115516. /**
  115517. * Class used to store 3D textures containing user data
  115518. */
  115519. export class RawTexture3D extends Texture {
  115520. /** Gets or sets the texture format to use */
  115521. format: number;
  115522. private _engine;
  115523. /**
  115524. * Create a new RawTexture3D
  115525. * @param data defines the data of the texture
  115526. * @param width defines the width of the texture
  115527. * @param height defines the height of the texture
  115528. * @param depth defines the depth of the texture
  115529. * @param format defines the texture format to use
  115530. * @param scene defines the hosting scene
  115531. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115532. * @param invertY defines if texture must be stored with Y axis inverted
  115533. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115534. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115535. */
  115536. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115537. /** Gets or sets the texture format to use */
  115538. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115539. /**
  115540. * Update the texture with new data
  115541. * @param data defines the data to store in the texture
  115542. */
  115543. update(data: ArrayBufferView): void;
  115544. }
  115545. }
  115546. declare module BABYLON {
  115547. /**
  115548. * Creates a refraction texture used by refraction channel of the standard material.
  115549. * It is like a mirror but to see through a material.
  115550. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115551. */
  115552. export class RefractionTexture extends RenderTargetTexture {
  115553. /**
  115554. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115555. * 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.
  115556. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115557. */
  115558. refractionPlane: Plane;
  115559. /**
  115560. * Define how deep under the surface we should see.
  115561. */
  115562. depth: number;
  115563. /**
  115564. * Creates a refraction texture used by refraction channel of the standard material.
  115565. * It is like a mirror but to see through a material.
  115566. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115567. * @param name Define the texture name
  115568. * @param size Define the size of the underlying texture
  115569. * @param scene Define the scene the refraction belongs to
  115570. * @param generateMipMaps Define if we need to generate mips level for the refraction
  115571. */
  115572. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  115573. /**
  115574. * Clone the refraction texture.
  115575. * @returns the cloned texture
  115576. */
  115577. clone(): RefractionTexture;
  115578. /**
  115579. * Serialize the texture to a JSON representation you could use in Parse later on
  115580. * @returns the serialized JSON representation
  115581. */
  115582. serialize(): any;
  115583. }
  115584. }
  115585. declare module BABYLON {
  115586. /**
  115587. * Defines the options related to the creation of an HtmlElementTexture
  115588. */
  115589. export interface IHtmlElementTextureOptions {
  115590. /**
  115591. * Defines wether mip maps should be created or not.
  115592. */
  115593. generateMipMaps?: boolean;
  115594. /**
  115595. * Defines the sampling mode of the texture.
  115596. */
  115597. samplingMode?: number;
  115598. /**
  115599. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115600. */
  115601. engine: Nullable<Engine>;
  115602. /**
  115603. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115604. */
  115605. scene: Nullable<Scene>;
  115606. }
  115607. /**
  115608. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115609. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115610. * is automatically managed.
  115611. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115612. * in your application.
  115613. *
  115614. * As the update is not automatic, you need to call them manually.
  115615. */
  115616. export class HtmlElementTexture extends BaseTexture {
  115617. /**
  115618. * The texture URL.
  115619. */
  115620. element: HTMLVideoElement | HTMLCanvasElement;
  115621. private static readonly DefaultOptions;
  115622. private _textureMatrix;
  115623. private _engine;
  115624. private _isVideo;
  115625. private _generateMipMaps;
  115626. private _samplingMode;
  115627. /**
  115628. * Instantiates a HtmlElementTexture from the following parameters.
  115629. *
  115630. * @param name Defines the name of the texture
  115631. * @param element Defines the video or canvas the texture is filled with
  115632. * @param options Defines the other none mandatory texture creation options
  115633. */
  115634. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115635. private _createInternalTexture;
  115636. /**
  115637. * Returns the texture matrix used in most of the material.
  115638. */
  115639. getTextureMatrix(): Matrix;
  115640. /**
  115641. * Updates the content of the texture.
  115642. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115643. */
  115644. update(invertY?: Nullable<boolean>): void;
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * Enum used to define the target of a block
  115650. */
  115651. export enum NodeMaterialBlockTargets {
  115652. /** Vertex shader */
  115653. Vertex = 1,
  115654. /** Fragment shader */
  115655. Fragment = 2,
  115656. /** Neutral */
  115657. Neutral = 4,
  115658. /** Vertex and Fragment */
  115659. VertexAndFragment = 3
  115660. }
  115661. }
  115662. declare module BABYLON {
  115663. /**
  115664. * Defines the kind of connection point for node based material
  115665. */
  115666. export enum NodeMaterialBlockConnectionPointTypes {
  115667. /** Float */
  115668. Float = 1,
  115669. /** Int */
  115670. Int = 2,
  115671. /** Vector2 */
  115672. Vector2 = 4,
  115673. /** Vector3 */
  115674. Vector3 = 8,
  115675. /** Vector4 */
  115676. Vector4 = 16,
  115677. /** Color3 */
  115678. Color3 = 32,
  115679. /** Color4 */
  115680. Color4 = 64,
  115681. /** Matrix */
  115682. Matrix = 128,
  115683. /** Detect type based on connection */
  115684. AutoDetect = 1024,
  115685. /** Output type that will be defined by input type */
  115686. BasedOnInput = 2048
  115687. }
  115688. }
  115689. declare module BABYLON {
  115690. /**
  115691. * Root class for all node material optimizers
  115692. */
  115693. export class NodeMaterialOptimizer {
  115694. /**
  115695. * Function used to optimize a NodeMaterial graph
  115696. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115697. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115698. */
  115699. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115700. }
  115701. }
  115702. declare module BABYLON {
  115703. /**
  115704. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115705. */
  115706. export class TransformBlock extends NodeMaterialBlock {
  115707. /**
  115708. * Defines the value to use to complement W value to transform it to a Vector4
  115709. */
  115710. complementW: number;
  115711. /**
  115712. * Defines the value to use to complement z value to transform it to a Vector4
  115713. */
  115714. complementZ: number;
  115715. /**
  115716. * Creates a new TransformBlock
  115717. * @param name defines the block name
  115718. */
  115719. constructor(name: string);
  115720. /**
  115721. * Gets the current class name
  115722. * @returns the class name
  115723. */
  115724. getClassName(): string;
  115725. /**
  115726. * Gets the vector input
  115727. */
  115728. readonly vector: NodeMaterialConnectionPoint;
  115729. /**
  115730. * Gets the output component
  115731. */
  115732. readonly output: NodeMaterialConnectionPoint;
  115733. /**
  115734. * Gets the matrix transform input
  115735. */
  115736. readonly transform: NodeMaterialConnectionPoint;
  115737. protected _buildBlock(state: NodeMaterialBuildState): this;
  115738. serialize(): any;
  115739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115740. }
  115741. }
  115742. declare module BABYLON {
  115743. /**
  115744. * Block used to output the vertex position
  115745. */
  115746. export class VertexOutputBlock extends NodeMaterialBlock {
  115747. /**
  115748. * Creates a new VertexOutputBlock
  115749. * @param name defines the block name
  115750. */
  115751. constructor(name: string);
  115752. /**
  115753. * Gets the current class name
  115754. * @returns the class name
  115755. */
  115756. getClassName(): string;
  115757. /**
  115758. * Gets the vector input component
  115759. */
  115760. readonly vector: NodeMaterialConnectionPoint;
  115761. protected _buildBlock(state: NodeMaterialBuildState): this;
  115762. }
  115763. }
  115764. declare module BABYLON {
  115765. /**
  115766. * Block used to output the final color
  115767. */
  115768. export class FragmentOutputBlock extends NodeMaterialBlock {
  115769. /**
  115770. * Create a new FragmentOutputBlock
  115771. * @param name defines the block name
  115772. */
  115773. constructor(name: string);
  115774. /**
  115775. * Gets the current class name
  115776. * @returns the class name
  115777. */
  115778. getClassName(): string;
  115779. /**
  115780. * Gets the rgba input component
  115781. */
  115782. readonly rgba: NodeMaterialConnectionPoint;
  115783. /**
  115784. * Gets the rgb input component
  115785. */
  115786. readonly rgb: NodeMaterialConnectionPoint;
  115787. /**
  115788. * Gets the a input component
  115789. */
  115790. readonly a: NodeMaterialConnectionPoint;
  115791. protected _buildBlock(state: NodeMaterialBuildState): this;
  115792. }
  115793. }
  115794. declare module BABYLON {
  115795. /**
  115796. * Interface used to configure the node material editor
  115797. */
  115798. export interface INodeMaterialEditorOptions {
  115799. /** Define the URl to load node editor script */
  115800. editorURL?: string;
  115801. }
  115802. /** @hidden */
  115803. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115804. /** BONES */
  115805. NUM_BONE_INFLUENCERS: number;
  115806. BonesPerMesh: number;
  115807. BONETEXTURE: boolean;
  115808. /** MORPH TARGETS */
  115809. MORPHTARGETS: boolean;
  115810. MORPHTARGETS_NORMAL: boolean;
  115811. MORPHTARGETS_TANGENT: boolean;
  115812. MORPHTARGETS_UV: boolean;
  115813. NUM_MORPH_INFLUENCERS: number;
  115814. /** IMAGE PROCESSING */
  115815. IMAGEPROCESSING: boolean;
  115816. VIGNETTE: boolean;
  115817. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115818. VIGNETTEBLENDMODEOPAQUE: boolean;
  115819. TONEMAPPING: boolean;
  115820. TONEMAPPING_ACES: boolean;
  115821. CONTRAST: boolean;
  115822. EXPOSURE: boolean;
  115823. COLORCURVES: boolean;
  115824. COLORGRADING: boolean;
  115825. COLORGRADING3D: boolean;
  115826. SAMPLER3DGREENDEPTH: boolean;
  115827. SAMPLER3DBGRMAP: boolean;
  115828. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115829. constructor();
  115830. setValue(name: string, value: boolean): void;
  115831. }
  115832. /**
  115833. * Class used to configure NodeMaterial
  115834. */
  115835. export interface INodeMaterialOptions {
  115836. /**
  115837. * Defines if blocks should emit comments
  115838. */
  115839. emitComments: boolean;
  115840. }
  115841. /**
  115842. * Class used to create a node based material built by assembling shader blocks
  115843. */
  115844. export class NodeMaterial extends PushMaterial {
  115845. private static _BuildIdGenerator;
  115846. private _options;
  115847. private _vertexCompilationState;
  115848. private _fragmentCompilationState;
  115849. private _sharedData;
  115850. private _buildId;
  115851. private _buildWasSuccessful;
  115852. private _cachedWorldViewMatrix;
  115853. private _cachedWorldViewProjectionMatrix;
  115854. private _optimizers;
  115855. /** Define the URl to load node editor script */
  115856. static EditorURL: string;
  115857. private BJSNODEMATERIALEDITOR;
  115858. /** Get the inspector from bundle or global */
  115859. private _getGlobalNodeMaterialEditor;
  115860. /**
  115861. * 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)
  115862. */
  115863. ignoreAlpha: boolean;
  115864. /**
  115865. * Defines the maximum number of lights that can be used in the material
  115866. */
  115867. maxSimultaneousLights: number;
  115868. /**
  115869. * Observable raised when the material is built
  115870. */
  115871. onBuildObservable: Observable<NodeMaterial>;
  115872. /**
  115873. * Gets or sets the root nodes of the material vertex shader
  115874. */
  115875. _vertexOutputNodes: NodeMaterialBlock[];
  115876. /**
  115877. * Gets or sets the root nodes of the material fragment (pixel) shader
  115878. */
  115879. _fragmentOutputNodes: NodeMaterialBlock[];
  115880. /** Gets or sets options to control the node material overall behavior */
  115881. options: INodeMaterialOptions;
  115882. /**
  115883. * Default configuration related to image processing available in the standard Material.
  115884. */
  115885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115886. /**
  115887. * Gets the image processing configuration used either in this material.
  115888. */
  115889. /**
  115890. * Sets the Default image processing configuration used either in the this material.
  115891. *
  115892. * If sets to null, the scene one is in use.
  115893. */
  115894. imageProcessingConfiguration: ImageProcessingConfiguration;
  115895. /**
  115896. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115897. */
  115898. attachedBlocks: NodeMaterialBlock[];
  115899. /**
  115900. * Create a new node based material
  115901. * @param name defines the material name
  115902. * @param scene defines the hosting scene
  115903. * @param options defines creation option
  115904. */
  115905. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115906. /**
  115907. * Gets the current class name of the material e.g. "NodeMaterial"
  115908. * @returns the class name
  115909. */
  115910. getClassName(): string;
  115911. /**
  115912. * Keep track of the image processing observer to allow dispose and replace.
  115913. */
  115914. private _imageProcessingObserver;
  115915. /**
  115916. * Attaches a new image processing configuration to the Standard Material.
  115917. * @param configuration
  115918. */
  115919. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115920. /**
  115921. * Adds a new optimizer to the list of optimizers
  115922. * @param optimizer defines the optimizers to add
  115923. * @returns the current material
  115924. */
  115925. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115926. /**
  115927. * Remove an optimizer from the list of optimizers
  115928. * @param optimizer defines the optimizers to remove
  115929. * @returns the current material
  115930. */
  115931. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115932. /**
  115933. * Add a new block to the list of output nodes
  115934. * @param node defines the node to add
  115935. * @returns the current material
  115936. */
  115937. addOutputNode(node: NodeMaterialBlock): this;
  115938. /**
  115939. * Remove a block from the list of root nodes
  115940. * @param node defines the node to remove
  115941. * @returns the current material
  115942. */
  115943. removeOutputNode(node: NodeMaterialBlock): this;
  115944. private _addVertexOutputNode;
  115945. private _removeVertexOutputNode;
  115946. private _addFragmentOutputNode;
  115947. private _removeFragmentOutputNode;
  115948. /**
  115949. * Specifies if the material will require alpha blending
  115950. * @returns a boolean specifying if alpha blending is needed
  115951. */
  115952. needAlphaBlending(): boolean;
  115953. /**
  115954. * Specifies if this material should be rendered in alpha test mode
  115955. * @returns a boolean specifying if an alpha test is needed.
  115956. */
  115957. needAlphaTesting(): boolean;
  115958. private _initializeBlock;
  115959. private _resetDualBlocks;
  115960. /**
  115961. * Build the material and generates the inner effect
  115962. * @param verbose defines if the build should log activity
  115963. */
  115964. build(verbose?: boolean): void;
  115965. /**
  115966. * Runs an otpimization phase to try to improve the shader code
  115967. */
  115968. optimize(): void;
  115969. private _prepareDefinesForAttributes;
  115970. /**
  115971. * Get if the submesh is ready to be used and all its information available.
  115972. * Child classes can use it to update shaders
  115973. * @param mesh defines the mesh to check
  115974. * @param subMesh defines which submesh to check
  115975. * @param useInstances specifies that instances should be used
  115976. * @returns a boolean indicating that the submesh is ready or not
  115977. */
  115978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115979. /**
  115980. * Get a string representing the shaders built by the current node graph
  115981. */
  115982. readonly compiledShaders: string;
  115983. /**
  115984. * Binds the world matrix to the material
  115985. * @param world defines the world transformation matrix
  115986. */
  115987. bindOnlyWorldMatrix(world: Matrix): void;
  115988. /**
  115989. * Binds the submesh to this material by preparing the effect and shader to draw
  115990. * @param world defines the world transformation matrix
  115991. * @param mesh defines the mesh containing the submesh
  115992. * @param subMesh defines the submesh to bind the material to
  115993. */
  115994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115995. /**
  115996. * Gets the active textures from the material
  115997. * @returns an array of textures
  115998. */
  115999. getActiveTextures(): BaseTexture[];
  116000. /**
  116001. * Specifies if the material uses a texture
  116002. * @param texture defines the texture to check against the material
  116003. * @returns a boolean specifying if the material uses the texture
  116004. */
  116005. hasTexture(texture: BaseTexture): boolean;
  116006. /**
  116007. * Disposes the material
  116008. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116009. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116010. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116011. */
  116012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116013. /** Creates the node editor window. */
  116014. private _createNodeEditor;
  116015. /**
  116016. * Launch the node material editor
  116017. * @param config Define the configuration of the editor
  116018. * @return a promise fulfilled when the node editor is visible
  116019. */
  116020. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116021. /**
  116022. * Clear the current material
  116023. */
  116024. clear(): void;
  116025. /**
  116026. * Clear the current material and set it to a default state
  116027. */
  116028. setToDefault(): void;
  116029. private _gatherBlocks;
  116030. /**
  116031. * Serializes this material in a JSON representation
  116032. * @returns the serialized material object
  116033. */
  116034. serialize(): any;
  116035. /**
  116036. * Clear the current graph and load a new one from a serialization object
  116037. * @param source defines the JSON representation of the material
  116038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116039. */
  116040. loadFromSerialization(source: any, rootUrl?: string): void;
  116041. /**
  116042. * Creates a node material from parsed material data
  116043. * @param source defines the JSON representation of the material
  116044. * @param scene defines the hosting scene
  116045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116046. * @returns a new node material
  116047. */
  116048. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116049. }
  116050. }
  116051. declare module BABYLON {
  116052. /**
  116053. * Block used to read a texture from a sampler
  116054. */
  116055. export class TextureBlock extends NodeMaterialBlock {
  116056. private _defineName;
  116057. private _samplerName;
  116058. private _transformedUVName;
  116059. private _textureTransformName;
  116060. private _textureInfoName;
  116061. private _mainUVName;
  116062. private _mainUVDefineName;
  116063. /**
  116064. * Gets or sets the texture associated with the node
  116065. */
  116066. texture: Nullable<BaseTexture>;
  116067. /**
  116068. * Create a new TextureBlock
  116069. * @param name defines the block name
  116070. */
  116071. constructor(name: string);
  116072. /**
  116073. * Gets the current class name
  116074. * @returns the class name
  116075. */
  116076. getClassName(): string;
  116077. /**
  116078. * Gets the uv input component
  116079. */
  116080. readonly uv: NodeMaterialConnectionPoint;
  116081. /**
  116082. * Gets the output component
  116083. */
  116084. readonly output: NodeMaterialConnectionPoint;
  116085. autoConfigure(): void;
  116086. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116088. isReady(): boolean;
  116089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116090. private _injectVertexCode;
  116091. private _writeOutput;
  116092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116093. serialize(): any;
  116094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116095. }
  116096. }
  116097. declare module BABYLON {
  116098. /**
  116099. * Class used to store shared data between 2 NodeMaterialBuildState
  116100. */
  116101. export class NodeMaterialBuildStateSharedData {
  116102. /**
  116103. * Gets the list of emitted varyings
  116104. */
  116105. varyings: string[];
  116106. /**
  116107. * Gets the varying declaration string
  116108. */
  116109. varyingDeclaration: string;
  116110. /**
  116111. * Input blocks
  116112. */
  116113. inputBlocks: InputBlock[];
  116114. /**
  116115. * Input blocks
  116116. */
  116117. textureBlocks: TextureBlock[];
  116118. /**
  116119. * Bindable blocks (Blocks that need to set data to the effect)
  116120. */
  116121. bindableBlocks: NodeMaterialBlock[];
  116122. /**
  116123. * List of blocks that can provide a compilation fallback
  116124. */
  116125. blocksWithFallbacks: NodeMaterialBlock[];
  116126. /**
  116127. * List of blocks that can provide a define update
  116128. */
  116129. blocksWithDefines: NodeMaterialBlock[];
  116130. /**
  116131. * List of blocks that can provide a repeatable content
  116132. */
  116133. repeatableContentBlocks: NodeMaterialBlock[];
  116134. /**
  116135. * List of blocks that can provide a dynamic list of uniforms
  116136. */
  116137. dynamicUniformBlocks: NodeMaterialBlock[];
  116138. /**
  116139. * List of blocks that can block the isReady function for the material
  116140. */
  116141. blockingBlocks: NodeMaterialBlock[];
  116142. /**
  116143. * Build Id used to avoid multiple recompilations
  116144. */
  116145. buildId: number;
  116146. /** List of emitted variables */
  116147. variableNames: {
  116148. [key: string]: number;
  116149. };
  116150. /** List of emitted defines */
  116151. defineNames: {
  116152. [key: string]: number;
  116153. };
  116154. /** Should emit comments? */
  116155. emitComments: boolean;
  116156. /** Emit build activity */
  116157. verbose: boolean;
  116158. /**
  116159. * Gets the compilation hints emitted at compilation time
  116160. */
  116161. hints: {
  116162. needWorldViewMatrix: boolean;
  116163. needWorldViewProjectionMatrix: boolean;
  116164. needAlphaBlending: boolean;
  116165. needAlphaTesting: boolean;
  116166. };
  116167. /**
  116168. * List of compilation checks
  116169. */
  116170. checks: {
  116171. emitVertex: boolean;
  116172. emitFragment: boolean;
  116173. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116174. };
  116175. /** Creates a new shared data */
  116176. constructor();
  116177. /**
  116178. * Emits console errors and exceptions if there is a failing check
  116179. */
  116180. emitErrors(): void;
  116181. }
  116182. }
  116183. declare module BABYLON {
  116184. /**
  116185. * Class used to store node based material build state
  116186. */
  116187. export class NodeMaterialBuildState {
  116188. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116189. supportUniformBuffers: boolean;
  116190. /**
  116191. * Gets the list of emitted attributes
  116192. */
  116193. attributes: string[];
  116194. /**
  116195. * Gets the list of emitted uniforms
  116196. */
  116197. uniforms: string[];
  116198. /**
  116199. * Gets the list of emitted uniform buffers
  116200. */
  116201. uniformBuffers: string[];
  116202. /**
  116203. * Gets the list of emitted samplers
  116204. */
  116205. samplers: string[];
  116206. /**
  116207. * Gets the list of emitted functions
  116208. */
  116209. functions: {
  116210. [key: string]: string;
  116211. };
  116212. /**
  116213. * Gets the target of the compilation state
  116214. */
  116215. target: NodeMaterialBlockTargets;
  116216. /**
  116217. * Gets the list of emitted counters
  116218. */
  116219. counters: {
  116220. [key: string]: number;
  116221. };
  116222. /**
  116223. * Shared data between multiple NodeMaterialBuildState instances
  116224. */
  116225. sharedData: NodeMaterialBuildStateSharedData;
  116226. /** @hidden */
  116227. _vertexState: NodeMaterialBuildState;
  116228. /** @hidden */
  116229. _attributeDeclaration: string;
  116230. /** @hidden */
  116231. _uniformDeclaration: string;
  116232. /** @hidden */
  116233. _samplerDeclaration: string;
  116234. /** @hidden */
  116235. _varyingTransfer: string;
  116236. private _repeatableContentAnchorIndex;
  116237. /** @hidden */
  116238. _builtCompilationString: string;
  116239. /**
  116240. * Gets the emitted compilation strings
  116241. */
  116242. compilationString: string;
  116243. /**
  116244. * Finalize the compilation strings
  116245. * @param state defines the current compilation state
  116246. */
  116247. finalize(state: NodeMaterialBuildState): void;
  116248. /** @hidden */
  116249. readonly _repeatableContentAnchor: string;
  116250. /** @hidden */
  116251. _getFreeVariableName(prefix: string): string;
  116252. /** @hidden */
  116253. _getFreeDefineName(prefix: string): string;
  116254. /** @hidden */
  116255. _excludeVariableName(name: string): void;
  116256. /** @hidden */
  116257. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  116258. /** @hidden */
  116259. _emitFunction(name: string, code: string, comments: string): void;
  116260. /** @hidden */
  116261. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  116262. replaceStrings?: {
  116263. search: RegExp;
  116264. replace: string;
  116265. }[];
  116266. repeatKey?: string;
  116267. }): string;
  116268. /** @hidden */
  116269. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  116270. repeatKey?: string;
  116271. removeAttributes?: boolean;
  116272. removeUniforms?: boolean;
  116273. removeVaryings?: boolean;
  116274. removeIfDef?: boolean;
  116275. replaceStrings?: {
  116276. search: RegExp;
  116277. replace: string;
  116278. }[];
  116279. }, storeKey?: string): void;
  116280. /** @hidden */
  116281. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116282. /** @hidden */
  116283. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116284. }
  116285. }
  116286. declare module BABYLON {
  116287. /**
  116288. * Defines a block that can be used inside a node based material
  116289. */
  116290. export class NodeMaterialBlock {
  116291. private _buildId;
  116292. private _buildTarget;
  116293. private _target;
  116294. private _isFinalMerger;
  116295. private _isInput;
  116296. /** @hidden */
  116297. _inputs: NodeMaterialConnectionPoint[];
  116298. /** @hidden */
  116299. _outputs: NodeMaterialConnectionPoint[];
  116300. /**
  116301. * Gets or sets the name of the block
  116302. */
  116303. name: string;
  116304. /**
  116305. * Gets or sets the unique id of the node
  116306. */
  116307. uniqueId: number;
  116308. /**
  116309. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  116310. */
  116311. readonly isFinalMerger: boolean;
  116312. /**
  116313. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  116314. */
  116315. readonly isInput: boolean;
  116316. /**
  116317. * Gets or sets the build Id
  116318. */
  116319. buildId: number;
  116320. /**
  116321. * Gets or sets the target of the block
  116322. */
  116323. target: NodeMaterialBlockTargets;
  116324. /**
  116325. * Gets the list of input points
  116326. */
  116327. readonly inputs: NodeMaterialConnectionPoint[];
  116328. /** Gets the list of output points */
  116329. readonly outputs: NodeMaterialConnectionPoint[];
  116330. /**
  116331. * Find an input by its name
  116332. * @param name defines the name of the input to look for
  116333. * @returns the input or null if not found
  116334. */
  116335. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116336. /**
  116337. * Find an output by its name
  116338. * @param name defines the name of the outputto look for
  116339. * @returns the output or null if not found
  116340. */
  116341. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116342. /**
  116343. * Creates a new NodeMaterialBlock
  116344. * @param name defines the block name
  116345. * @param target defines the target of that block (Vertex by default)
  116346. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  116347. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  116348. */
  116349. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  116350. /**
  116351. * Initialize the block and prepare the context for build
  116352. * @param state defines the state that will be used for the build
  116353. */
  116354. initialize(state: NodeMaterialBuildState): void;
  116355. /**
  116356. * Bind data to effect. Will only be called for blocks with isBindable === true
  116357. * @param effect defines the effect to bind data to
  116358. * @param nodeMaterial defines the hosting NodeMaterial
  116359. * @param mesh defines the mesh that will be rendered
  116360. */
  116361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116362. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  116363. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  116364. protected _writeFloat(value: number): string;
  116365. /**
  116366. * Gets the current class name e.g. "NodeMaterialBlock"
  116367. * @returns the class name
  116368. */
  116369. getClassName(): string;
  116370. /**
  116371. * Register a new input. Must be called inside a block constructor
  116372. * @param name defines the connection point name
  116373. * @param type defines the connection point type
  116374. * @param isOptional defines a boolean indicating that this input can be omitted
  116375. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116376. * @returns the current block
  116377. */
  116378. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  116379. /**
  116380. * Register a new output. Must be called inside a block constructor
  116381. * @param name defines the connection point name
  116382. * @param type defines the connection point type
  116383. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116384. * @returns the current block
  116385. */
  116386. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  116387. /**
  116388. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  116389. * @param forOutput defines an optional connection point to check compatibility with
  116390. * @returns the first available input or null
  116391. */
  116392. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  116393. /**
  116394. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  116395. * @param forBlock defines an optional block to check compatibility with
  116396. * @returns the first available input or null
  116397. */
  116398. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  116399. /**
  116400. * Connect current block with another block
  116401. * @param other defines the block to connect with
  116402. * @param options define the various options to help pick the right connections
  116403. * @returns the current block
  116404. */
  116405. connectTo(other: NodeMaterialBlock, options?: {
  116406. input?: string;
  116407. output?: string;
  116408. outputSwizzle?: string;
  116409. }): this | undefined;
  116410. protected _buildBlock(state: NodeMaterialBuildState): void;
  116411. /**
  116412. * Add uniforms, samplers and uniform buffers at compilation time
  116413. * @param state defines the state to update
  116414. * @param nodeMaterial defines the node material requesting the update
  116415. * @param defines defines the material defines to update
  116416. */
  116417. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116418. /**
  116419. * Add potential fallbacks if shader compilation fails
  116420. * @param mesh defines the mesh to be rendered
  116421. * @param fallbacks defines the current prioritized list of fallbacks
  116422. */
  116423. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116424. /**
  116425. * Update defines for shader compilation
  116426. * @param mesh defines the mesh to be rendered
  116427. * @param nodeMaterial defines the node material requesting the update
  116428. * @param defines defines the material defines to update
  116429. * @param useInstances specifies that instances should be used
  116430. */
  116431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116432. /**
  116433. * Initialize defines for shader compilation
  116434. * @param mesh defines the mesh to be rendered
  116435. * @param nodeMaterial defines the node material requesting the update
  116436. * @param defines defines the material defines to be prepared
  116437. * @param useInstances specifies that instances should be used
  116438. */
  116439. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116440. /**
  116441. * Lets the block try to connect some inputs automatically
  116442. */
  116443. autoConfigure(): void;
  116444. /**
  116445. * Function called when a block is declared as repeatable content generator
  116446. * @param vertexShaderState defines the current compilation state for the vertex shader
  116447. * @param fragmentShaderState defines the current compilation state for the fragment shader
  116448. * @param mesh defines the mesh to be rendered
  116449. * @param defines defines the material defines to update
  116450. */
  116451. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116452. /**
  116453. * Checks if the block is ready
  116454. * @param mesh defines the mesh to be rendered
  116455. * @param nodeMaterial defines the node material requesting the update
  116456. * @param defines defines the material defines to update
  116457. * @param useInstances specifies that instances should be used
  116458. * @returns true if the block is ready
  116459. */
  116460. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  116461. private _processBuild;
  116462. /**
  116463. * Compile the current node and generate the shader code
  116464. * @param state defines the current compilation state (uniforms, samplers, current string)
  116465. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  116466. * @returns true if already built
  116467. */
  116468. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  116469. /**
  116470. * Serializes this block in a JSON representation
  116471. * @returns the serialized block object
  116472. */
  116473. serialize(): any;
  116474. /** @hidden */
  116475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116476. }
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  116481. */
  116482. export enum NodeMaterialBlockConnectionPointMode {
  116483. /** Value is an uniform */
  116484. Uniform = 0,
  116485. /** Value is a mesh attribute */
  116486. Attribute = 1,
  116487. /** Value is a varying between vertex and fragment shaders */
  116488. Varying = 2,
  116489. /** Mode is undefined */
  116490. Undefined = 3
  116491. }
  116492. }
  116493. declare module BABYLON {
  116494. /**
  116495. * Enum used to define well known values e.g. values automatically provided by the system
  116496. */
  116497. export enum NodeMaterialWellKnownValues {
  116498. /** World */
  116499. World = 1,
  116500. /** View */
  116501. View = 2,
  116502. /** Projection */
  116503. Projection = 3,
  116504. /** ViewProjection */
  116505. ViewProjection = 4,
  116506. /** WorldView */
  116507. WorldView = 5,
  116508. /** WorldViewProjection */
  116509. WorldViewProjection = 6,
  116510. /** CameraPosition */
  116511. CameraPosition = 7,
  116512. /** Fog Color */
  116513. FogColor = 8
  116514. }
  116515. }
  116516. declare module BABYLON {
  116517. /**
  116518. * Contains position and normal vectors for a vertex
  116519. */
  116520. export class PositionNormalVertex {
  116521. /** the position of the vertex (defaut: 0,0,0) */
  116522. position: Vector3;
  116523. /** the normal of the vertex (defaut: 0,1,0) */
  116524. normal: Vector3;
  116525. /**
  116526. * Creates a PositionNormalVertex
  116527. * @param position the position of the vertex (defaut: 0,0,0)
  116528. * @param normal the normal of the vertex (defaut: 0,1,0)
  116529. */
  116530. constructor(
  116531. /** the position of the vertex (defaut: 0,0,0) */
  116532. position?: Vector3,
  116533. /** the normal of the vertex (defaut: 0,1,0) */
  116534. normal?: Vector3);
  116535. /**
  116536. * Clones the PositionNormalVertex
  116537. * @returns the cloned PositionNormalVertex
  116538. */
  116539. clone(): PositionNormalVertex;
  116540. }
  116541. /**
  116542. * Contains position, normal and uv vectors for a vertex
  116543. */
  116544. export class PositionNormalTextureVertex {
  116545. /** the position of the vertex (defaut: 0,0,0) */
  116546. position: Vector3;
  116547. /** the normal of the vertex (defaut: 0,1,0) */
  116548. normal: Vector3;
  116549. /** the uv of the vertex (default: 0,0) */
  116550. uv: Vector2;
  116551. /**
  116552. * Creates a PositionNormalTextureVertex
  116553. * @param position the position of the vertex (defaut: 0,0,0)
  116554. * @param normal the normal of the vertex (defaut: 0,1,0)
  116555. * @param uv the uv of the vertex (default: 0,0)
  116556. */
  116557. constructor(
  116558. /** the position of the vertex (defaut: 0,0,0) */
  116559. position?: Vector3,
  116560. /** the normal of the vertex (defaut: 0,1,0) */
  116561. normal?: Vector3,
  116562. /** the uv of the vertex (default: 0,0) */
  116563. uv?: Vector2);
  116564. /**
  116565. * Clones the PositionNormalTextureVertex
  116566. * @returns the cloned PositionNormalTextureVertex
  116567. */
  116568. clone(): PositionNormalTextureVertex;
  116569. }
  116570. }
  116571. declare module BABYLON {
  116572. /**
  116573. * Block used to expose an input value
  116574. */
  116575. export class InputBlock extends NodeMaterialBlock {
  116576. private _mode;
  116577. private _associatedVariableName;
  116578. private _storedValue;
  116579. private _valueCallback;
  116580. private _type;
  116581. /** @hidden */
  116582. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116583. /**
  116584. * Gets or sets the connection point type (default is float)
  116585. */
  116586. readonly type: NodeMaterialBlockConnectionPointTypes;
  116587. /**
  116588. * Creates a new InputBlock
  116589. * @param name defines the block name
  116590. * @param target defines the target of that block (Vertex by default)
  116591. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116592. */
  116593. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116594. /**
  116595. * Gets the output component
  116596. */
  116597. readonly output: NodeMaterialConnectionPoint;
  116598. /**
  116599. * Set the source of this connection point to a vertex attribute
  116600. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116601. * @returns the current connection point
  116602. */
  116603. setAsAttribute(attributeName?: string): InputBlock;
  116604. /**
  116605. * Set the source of this connection point to a well known value
  116606. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116607. * @returns the current connection point
  116608. */
  116609. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116610. /**
  116611. * Gets or sets the value of that point.
  116612. * Please note that this value will be ignored if valueCallback is defined
  116613. */
  116614. value: any;
  116615. /**
  116616. * Gets or sets a callback used to get the value of that point.
  116617. * Please note that setting this value will force the connection point to ignore the value property
  116618. */
  116619. valueCallback: () => any;
  116620. /**
  116621. * Gets or sets the associated variable name in the shader
  116622. */
  116623. associatedVariableName: string;
  116624. /**
  116625. * Gets a boolean indicating that this connection point not defined yet
  116626. */
  116627. readonly isUndefined: boolean;
  116628. /**
  116629. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116630. * In this case the connection point name must be the name of the uniform to use.
  116631. * Can only be set on inputs
  116632. */
  116633. isUniform: boolean;
  116634. /**
  116635. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116636. * In this case the connection point name must be the name of the attribute to use
  116637. * Can only be set on inputs
  116638. */
  116639. isAttribute: boolean;
  116640. /**
  116641. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116642. * Can only be set on exit points
  116643. */
  116644. isVarying: boolean;
  116645. /**
  116646. * Gets a boolean indicating that the current connection point is a well known value
  116647. */
  116648. readonly isWellKnownValue: boolean;
  116649. /**
  116650. * Gets or sets the current well known value or null if not defined as well know value
  116651. */
  116652. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116653. /**
  116654. * Gets the current class name
  116655. * @returns the class name
  116656. */
  116657. getClassName(): string;
  116658. private _emitDefine;
  116659. /**
  116660. * Set the input block to its default value (based on its type)
  116661. */
  116662. setDefaultValue(): void;
  116663. private _emit;
  116664. /** @hidden */
  116665. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  116666. /** @hidden */
  116667. _transmit(effect: Effect, scene: Scene): void;
  116668. protected _buildBlock(state: NodeMaterialBuildState): void;
  116669. serialize(): any;
  116670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116671. }
  116672. }
  116673. declare module BABYLON {
  116674. /**
  116675. * Defines a connection point for a block
  116676. */
  116677. export class NodeMaterialConnectionPoint {
  116678. /** @hidden */
  116679. _ownerBlock: NodeMaterialBlock;
  116680. /** @hidden */
  116681. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116682. private _endpoints;
  116683. private _associatedVariableName;
  116684. /** @hidden */
  116685. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  116686. private _type;
  116687. /** @hidden */
  116688. _enforceAssociatedVariableName: boolean;
  116689. /**
  116690. * Gets or sets the additional types supported byt this connection point
  116691. */
  116692. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  116693. /**
  116694. * Gets or sets the associated variable name in the shader
  116695. */
  116696. associatedVariableName: string;
  116697. /**
  116698. * Gets or sets the connection point type (default is float)
  116699. */
  116700. type: NodeMaterialBlockConnectionPointTypes;
  116701. /**
  116702. * Gets or sets the connection point name
  116703. */
  116704. name: string;
  116705. /**
  116706. * Gets or sets a boolean indicating that this connection point can be omitted
  116707. */
  116708. isOptional: boolean;
  116709. /**
  116710. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116711. */
  116712. define: string;
  116713. /** Gets or sets the target of that connection point */
  116714. target: NodeMaterialBlockTargets;
  116715. /**
  116716. * Gets a boolean indicating that the current point is connected
  116717. */
  116718. readonly isConnected: boolean;
  116719. /**
  116720. * Gets a boolean indicating that the current point is connected to an input block
  116721. */
  116722. readonly isConnectedToInput: boolean;
  116723. /**
  116724. * Gets a the connected input block (if any)
  116725. */
  116726. readonly connectInputBlock: Nullable<InputBlock>;
  116727. /** Get the other side of the connection (if any) */
  116728. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116729. /** Get the block that owns this connection point */
  116730. readonly ownerBlock: NodeMaterialBlock;
  116731. /** Get the block connected on the other side of this connection (if any) */
  116732. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116733. /** Get the block connected on the endpoints of this connection (if any) */
  116734. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116735. /** Gets the list of connected endpoints */
  116736. readonly endpoints: NodeMaterialConnectionPoint[];
  116737. /**
  116738. * Creates a new connection point
  116739. * @param name defines the connection point name
  116740. * @param ownerBlock defines the block hosting this connection point
  116741. */
  116742. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116743. /**
  116744. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116745. * @returns the class name
  116746. */
  116747. getClassName(): string;
  116748. /**
  116749. * Gets an boolean indicating if the current point can be connected to another point
  116750. * @param connectionPoint defines the other connection point
  116751. * @returns true if the connection is possible
  116752. */
  116753. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116754. /**
  116755. * Connect this point to another connection point
  116756. * @param connectionPoint defines the other connection point
  116757. * @returns the current connection point
  116758. */
  116759. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116760. /**
  116761. * Disconnect this point from one of his endpoint
  116762. * @param endpoint defines the other connection point
  116763. * @returns the current connection point
  116764. */
  116765. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116766. /**
  116767. * Serializes this point in a JSON representation
  116768. * @returns the serialized point object
  116769. */
  116770. serialize(): any;
  116771. }
  116772. }
  116773. declare module BABYLON {
  116774. /**
  116775. * Block used to add support for vertex skinning (bones)
  116776. */
  116777. export class BonesBlock extends NodeMaterialBlock {
  116778. /**
  116779. * Creates a new BonesBlock
  116780. * @param name defines the block name
  116781. */
  116782. constructor(name: string);
  116783. /**
  116784. * Initialize the block and prepare the context for build
  116785. * @param state defines the state that will be used for the build
  116786. */
  116787. initialize(state: NodeMaterialBuildState): void;
  116788. /**
  116789. * Gets the current class name
  116790. * @returns the class name
  116791. */
  116792. getClassName(): string;
  116793. /**
  116794. * Gets the matrix indices input component
  116795. */
  116796. readonly matricesIndices: NodeMaterialConnectionPoint;
  116797. /**
  116798. * Gets the matrix weights input component
  116799. */
  116800. readonly matricesWeights: NodeMaterialConnectionPoint;
  116801. /**
  116802. * Gets the extra matrix indices input component
  116803. */
  116804. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116805. /**
  116806. * Gets the extra matrix weights input component
  116807. */
  116808. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116809. /**
  116810. * Gets the world input component
  116811. */
  116812. readonly world: NodeMaterialConnectionPoint;
  116813. /**
  116814. * Gets the output component
  116815. */
  116816. readonly output: NodeMaterialConnectionPoint;
  116817. autoConfigure(): void;
  116818. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116821. protected _buildBlock(state: NodeMaterialBuildState): this;
  116822. }
  116823. }
  116824. declare module BABYLON {
  116825. /**
  116826. * Block used to add support for instances
  116827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116828. */
  116829. export class InstancesBlock extends NodeMaterialBlock {
  116830. /**
  116831. * Creates a new InstancesBlock
  116832. * @param name defines the block name
  116833. */
  116834. constructor(name: string);
  116835. /**
  116836. * Gets the current class name
  116837. * @returns the class name
  116838. */
  116839. getClassName(): string;
  116840. /**
  116841. * Gets the first world row input component
  116842. */
  116843. readonly world0: NodeMaterialConnectionPoint;
  116844. /**
  116845. * Gets the second world row input component
  116846. */
  116847. readonly world1: NodeMaterialConnectionPoint;
  116848. /**
  116849. * Gets the third world row input component
  116850. */
  116851. readonly world2: NodeMaterialConnectionPoint;
  116852. /**
  116853. * Gets the forth world row input component
  116854. */
  116855. readonly world3: NodeMaterialConnectionPoint;
  116856. /**
  116857. * Gets the world input component
  116858. */
  116859. readonly world: NodeMaterialConnectionPoint;
  116860. /**
  116861. * Gets the output component
  116862. */
  116863. readonly output: NodeMaterialConnectionPoint;
  116864. autoConfigure(): void;
  116865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116866. protected _buildBlock(state: NodeMaterialBuildState): this;
  116867. }
  116868. }
  116869. declare module BABYLON {
  116870. /**
  116871. * Block used to add morph targets support to vertex shader
  116872. */
  116873. export class MorphTargetsBlock extends NodeMaterialBlock {
  116874. private _repeatableContentAnchor;
  116875. private _repeatebleContentGenerated;
  116876. /**
  116877. * Create a new MorphTargetsBlock
  116878. * @param name defines the block name
  116879. */
  116880. constructor(name: string);
  116881. /**
  116882. * Gets the current class name
  116883. * @returns the class name
  116884. */
  116885. getClassName(): string;
  116886. /**
  116887. * Gets the position input component
  116888. */
  116889. readonly position: NodeMaterialConnectionPoint;
  116890. /**
  116891. * Gets the normal input component
  116892. */
  116893. readonly normal: NodeMaterialConnectionPoint;
  116894. /**
  116895. * Gets the tangent input component
  116896. */
  116897. readonly tangent: NodeMaterialConnectionPoint;
  116898. /**
  116899. * Gets the tangent input component
  116900. */
  116901. readonly uv: NodeMaterialConnectionPoint;
  116902. /**
  116903. * Gets the position output component
  116904. */
  116905. readonly positionOutput: NodeMaterialConnectionPoint;
  116906. /**
  116907. * Gets the normal output component
  116908. */
  116909. readonly normalOutput: NodeMaterialConnectionPoint;
  116910. /**
  116911. * Gets the tangent output component
  116912. */
  116913. readonly tangentOutput: NodeMaterialConnectionPoint;
  116914. /**
  116915. * Gets the tangent output component
  116916. */
  116917. readonly uvOutput: NodeMaterialConnectionPoint;
  116918. initialize(state: NodeMaterialBuildState): void;
  116919. autoConfigure(): void;
  116920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116921. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116922. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116923. protected _buildBlock(state: NodeMaterialBuildState): this;
  116924. }
  116925. }
  116926. declare module BABYLON {
  116927. /**
  116928. * Block used to add an alpha test in the fragment shader
  116929. */
  116930. export class AlphaTestBlock extends NodeMaterialBlock {
  116931. /**
  116932. * Gets or sets the alpha value where alpha testing happens
  116933. */
  116934. alphaCutOff: number;
  116935. /**
  116936. * Create a new AlphaTestBlock
  116937. * @param name defines the block name
  116938. */
  116939. constructor(name: string);
  116940. /**
  116941. * Gets the current class name
  116942. * @returns the class name
  116943. */
  116944. getClassName(): string;
  116945. /**
  116946. * Gets the color input component
  116947. */
  116948. readonly color: NodeMaterialConnectionPoint;
  116949. /**
  116950. * Gets the alpha input component
  116951. */
  116952. readonly alpha: NodeMaterialConnectionPoint;
  116953. protected _buildBlock(state: NodeMaterialBuildState): this;
  116954. }
  116955. }
  116956. declare module BABYLON {
  116957. /**
  116958. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116959. */
  116960. export class ColorMergerBlock extends NodeMaterialBlock {
  116961. /**
  116962. * Create a new ColorMergerBlock
  116963. * @param name defines the block name
  116964. */
  116965. constructor(name: string);
  116966. /**
  116967. * Gets the current class name
  116968. * @returns the class name
  116969. */
  116970. getClassName(): string;
  116971. /**
  116972. * Gets the r component (input)
  116973. */
  116974. readonly r: NodeMaterialConnectionPoint;
  116975. /**
  116976. * Gets the g component (input)
  116977. */
  116978. readonly g: NodeMaterialConnectionPoint;
  116979. /**
  116980. * Gets the b component (input)
  116981. */
  116982. readonly b: NodeMaterialConnectionPoint;
  116983. /**
  116984. * Gets the a component (input)
  116985. */
  116986. readonly a: NodeMaterialConnectionPoint;
  116987. /**
  116988. * Gets the rgba component (output)
  116989. */
  116990. readonly rgba: NodeMaterialConnectionPoint;
  116991. /**
  116992. * Gets the rgb component (output)
  116993. */
  116994. readonly rgb: NodeMaterialConnectionPoint;
  116995. protected _buildBlock(state: NodeMaterialBuildState): this;
  116996. }
  116997. }
  116998. declare module BABYLON {
  116999. /**
  117000. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  117001. */
  117002. export class VectorMergerBlock extends NodeMaterialBlock {
  117003. /**
  117004. * Create a new VectorMergerBlock
  117005. * @param name defines the block name
  117006. */
  117007. constructor(name: string);
  117008. /**
  117009. * Gets the current class name
  117010. * @returns the class name
  117011. */
  117012. getClassName(): string;
  117013. /**
  117014. * Gets the x component (input)
  117015. */
  117016. readonly x: NodeMaterialConnectionPoint;
  117017. /**
  117018. * Gets the y component (input)
  117019. */
  117020. readonly y: NodeMaterialConnectionPoint;
  117021. /**
  117022. * Gets the z component (input)
  117023. */
  117024. readonly z: NodeMaterialConnectionPoint;
  117025. /**
  117026. * Gets the w component (input)
  117027. */
  117028. readonly w: NodeMaterialConnectionPoint;
  117029. /**
  117030. * Gets the xyzw component (output)
  117031. */
  117032. readonly xyzw: NodeMaterialConnectionPoint;
  117033. /**
  117034. * Gets the xyz component (output)
  117035. */
  117036. readonly xyz: NodeMaterialConnectionPoint;
  117037. /**
  117038. * Gets the xy component (output)
  117039. */
  117040. readonly xy: NodeMaterialConnectionPoint;
  117041. protected _buildBlock(state: NodeMaterialBuildState): this;
  117042. }
  117043. }
  117044. declare module BABYLON {
  117045. /**
  117046. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  117047. */
  117048. export class ColorSplitterBlock extends NodeMaterialBlock {
  117049. /**
  117050. * Create a new ColorSplitterBlock
  117051. * @param name defines the block name
  117052. */
  117053. constructor(name: string);
  117054. /**
  117055. * Gets the current class name
  117056. * @returns the class name
  117057. */
  117058. getClassName(): string;
  117059. /**
  117060. * Gets the rgba component (input)
  117061. */
  117062. readonly rgba: NodeMaterialConnectionPoint;
  117063. /**
  117064. * Gets the rgb component (input)
  117065. */
  117066. readonly rgbIn: NodeMaterialConnectionPoint;
  117067. /**
  117068. * Gets the rgb component (output)
  117069. */
  117070. readonly rgbOut: NodeMaterialConnectionPoint;
  117071. /**
  117072. * Gets the r component (output)
  117073. */
  117074. readonly r: NodeMaterialConnectionPoint;
  117075. /**
  117076. * Gets the g component (output)
  117077. */
  117078. readonly g: NodeMaterialConnectionPoint;
  117079. /**
  117080. * Gets the b component (output)
  117081. */
  117082. readonly b: NodeMaterialConnectionPoint;
  117083. /**
  117084. * Gets the a component (output)
  117085. */
  117086. readonly a: NodeMaterialConnectionPoint;
  117087. protected _buildBlock(state: NodeMaterialBuildState): this;
  117088. }
  117089. }
  117090. declare module BABYLON {
  117091. /**
  117092. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  117093. */
  117094. export class VectorSplitterBlock extends NodeMaterialBlock {
  117095. /**
  117096. * Create a new VectorSplitterBlock
  117097. * @param name defines the block name
  117098. */
  117099. constructor(name: string);
  117100. /**
  117101. * Gets the current class name
  117102. * @returns the class name
  117103. */
  117104. getClassName(): string;
  117105. /**
  117106. * Gets the xyzw component (input)
  117107. */
  117108. readonly xyzw: NodeMaterialConnectionPoint;
  117109. /**
  117110. * Gets the xyz component (input)
  117111. */
  117112. readonly xyzIn: NodeMaterialConnectionPoint;
  117113. /**
  117114. * Gets the xyz component (output)
  117115. */
  117116. readonly xyzOut: NodeMaterialConnectionPoint;
  117117. /**
  117118. * Gets the xy component (output)
  117119. */
  117120. readonly xy: NodeMaterialConnectionPoint;
  117121. /**
  117122. * Gets the x component (output)
  117123. */
  117124. readonly x: NodeMaterialConnectionPoint;
  117125. /**
  117126. * Gets the y component (output)
  117127. */
  117128. readonly y: NodeMaterialConnectionPoint;
  117129. /**
  117130. * Gets the z component (output)
  117131. */
  117132. readonly z: NodeMaterialConnectionPoint;
  117133. /**
  117134. * Gets the w component (output)
  117135. */
  117136. readonly w: NodeMaterialConnectionPoint;
  117137. protected _buildBlock(state: NodeMaterialBuildState): this;
  117138. }
  117139. }
  117140. declare module BABYLON {
  117141. /**
  117142. * Block used to add image processing support to fragment shader
  117143. */
  117144. export class ImageProcessingBlock extends NodeMaterialBlock {
  117145. /**
  117146. * Create a new ImageProcessingBlock
  117147. * @param name defines the block name
  117148. */
  117149. constructor(name: string);
  117150. /**
  117151. * Gets the current class name
  117152. * @returns the class name
  117153. */
  117154. getClassName(): string;
  117155. /**
  117156. * Gets the color input component
  117157. */
  117158. readonly color: NodeMaterialConnectionPoint;
  117159. /**
  117160. * Gets the output component
  117161. */
  117162. readonly output: NodeMaterialConnectionPoint;
  117163. /**
  117164. * Initialize the block and prepare the context for build
  117165. * @param state defines the state that will be used for the build
  117166. */
  117167. initialize(state: NodeMaterialBuildState): void;
  117168. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117171. protected _buildBlock(state: NodeMaterialBuildState): this;
  117172. }
  117173. }
  117174. declare module BABYLON {
  117175. /**
  117176. * Block used to add support for scene fog
  117177. */
  117178. export class FogBlock extends NodeMaterialBlock {
  117179. private _fogDistanceName;
  117180. private _fogParameters;
  117181. /**
  117182. * Create a new FogBlock
  117183. * @param name defines the block name
  117184. */
  117185. constructor(name: string);
  117186. /**
  117187. * Gets the current class name
  117188. * @returns the class name
  117189. */
  117190. getClassName(): string;
  117191. /**
  117192. * Gets the world position input component
  117193. */
  117194. readonly worldPosition: NodeMaterialConnectionPoint;
  117195. /**
  117196. * Gets the view input component
  117197. */
  117198. readonly view: NodeMaterialConnectionPoint;
  117199. /**
  117200. * Gets the color input component
  117201. */
  117202. readonly color: NodeMaterialConnectionPoint;
  117203. /**
  117204. * Gets the fog color input component
  117205. */
  117206. readonly fogColor: NodeMaterialConnectionPoint;
  117207. /**
  117208. * Gets the output component
  117209. */
  117210. readonly output: NodeMaterialConnectionPoint;
  117211. autoConfigure(): void;
  117212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117214. protected _buildBlock(state: NodeMaterialBuildState): this;
  117215. }
  117216. }
  117217. declare module BABYLON {
  117218. /**
  117219. * Block used to add light in the fragment shader
  117220. */
  117221. export class LightBlock extends NodeMaterialBlock {
  117222. private _lightId;
  117223. /**
  117224. * Gets or sets the light associated with this block
  117225. */
  117226. light: Nullable<Light>;
  117227. /**
  117228. * Create a new LightBlock
  117229. * @param name defines the block name
  117230. */
  117231. constructor(name: string);
  117232. /**
  117233. * Gets the current class name
  117234. * @returns the class name
  117235. */
  117236. getClassName(): string;
  117237. /**
  117238. * Gets the world position input component
  117239. */
  117240. readonly worldPosition: NodeMaterialConnectionPoint;
  117241. /**
  117242. * Gets the world normal input component
  117243. */
  117244. readonly worldNormal: NodeMaterialConnectionPoint;
  117245. /**
  117246. * Gets the camera (or eye) position component
  117247. */
  117248. readonly cameraPosition: NodeMaterialConnectionPoint;
  117249. /**
  117250. * Gets the diffuse output component
  117251. */
  117252. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117253. /**
  117254. * Gets the specular output component
  117255. */
  117256. readonly specularOutput: NodeMaterialConnectionPoint;
  117257. autoConfigure(): void;
  117258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117259. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117261. private _injectVertexCode;
  117262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117263. serialize(): any;
  117264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117265. }
  117266. }
  117267. declare module BABYLON {
  117268. /**
  117269. * Block used to multiply 2 values
  117270. */
  117271. export class MultiplyBlock extends NodeMaterialBlock {
  117272. /**
  117273. * Creates a new MultiplyBlock
  117274. * @param name defines the block name
  117275. */
  117276. constructor(name: string);
  117277. /**
  117278. * Gets the current class name
  117279. * @returns the class name
  117280. */
  117281. getClassName(): string;
  117282. /**
  117283. * Gets the left operand input component
  117284. */
  117285. readonly left: NodeMaterialConnectionPoint;
  117286. /**
  117287. * Gets the right operand input component
  117288. */
  117289. readonly right: NodeMaterialConnectionPoint;
  117290. /**
  117291. * Gets the output component
  117292. */
  117293. readonly output: NodeMaterialConnectionPoint;
  117294. protected _buildBlock(state: NodeMaterialBuildState): this;
  117295. }
  117296. }
  117297. declare module BABYLON {
  117298. /**
  117299. * Block used to add 2 vectors
  117300. */
  117301. export class AddBlock extends NodeMaterialBlock {
  117302. /**
  117303. * Creates a new AddBlock
  117304. * @param name defines the block name
  117305. */
  117306. constructor(name: string);
  117307. /**
  117308. * Gets the current class name
  117309. * @returns the class name
  117310. */
  117311. getClassName(): string;
  117312. /**
  117313. * Gets the left operand input component
  117314. */
  117315. readonly left: NodeMaterialConnectionPoint;
  117316. /**
  117317. * Gets the right operand input component
  117318. */
  117319. readonly right: NodeMaterialConnectionPoint;
  117320. /**
  117321. * Gets the output component
  117322. */
  117323. readonly output: NodeMaterialConnectionPoint;
  117324. protected _buildBlock(state: NodeMaterialBuildState): this;
  117325. }
  117326. }
  117327. declare module BABYLON {
  117328. /**
  117329. * Block used to clamp a float
  117330. */
  117331. export class ClampBlock extends NodeMaterialBlock {
  117332. /** Gets or sets the minimum range */
  117333. minimum: number;
  117334. /** Gets or sets the maximum range */
  117335. maximum: number;
  117336. /**
  117337. * Creates a new ClampBlock
  117338. * @param name defines the block name
  117339. */
  117340. constructor(name: string);
  117341. /**
  117342. * Gets the current class name
  117343. * @returns the class name
  117344. */
  117345. getClassName(): string;
  117346. /**
  117347. * Gets the value input component
  117348. */
  117349. readonly value: NodeMaterialConnectionPoint;
  117350. /**
  117351. * Gets the output component
  117352. */
  117353. readonly output: NodeMaterialConnectionPoint;
  117354. protected _buildBlock(state: NodeMaterialBuildState): this;
  117355. }
  117356. }
  117357. declare module BABYLON {
  117358. /**
  117359. * Block used to apply a cross product between 2 vectors
  117360. */
  117361. export class CrossBlock extends NodeMaterialBlock {
  117362. /**
  117363. * Creates a new CrossBlock
  117364. * @param name defines the block name
  117365. */
  117366. constructor(name: string);
  117367. /**
  117368. * Gets the current class name
  117369. * @returns the class name
  117370. */
  117371. getClassName(): string;
  117372. /**
  117373. * Gets the left operand input component
  117374. */
  117375. readonly left: NodeMaterialConnectionPoint;
  117376. /**
  117377. * Gets the right operand input component
  117378. */
  117379. readonly right: NodeMaterialConnectionPoint;
  117380. /**
  117381. * Gets the output component
  117382. */
  117383. readonly output: NodeMaterialConnectionPoint;
  117384. protected _buildBlock(state: NodeMaterialBuildState): this;
  117385. }
  117386. }
  117387. declare module BABYLON {
  117388. /**
  117389. * Block used to apply a dot product between 2 vectors
  117390. */
  117391. export class DotBlock extends NodeMaterialBlock {
  117392. /**
  117393. * Creates a new DotBlock
  117394. * @param name defines the block name
  117395. */
  117396. constructor(name: string);
  117397. /**
  117398. * Gets the current class name
  117399. * @returns the class name
  117400. */
  117401. getClassName(): string;
  117402. /**
  117403. * Gets the left operand input component
  117404. */
  117405. readonly left: NodeMaterialConnectionPoint;
  117406. /**
  117407. * Gets the right operand input component
  117408. */
  117409. readonly right: NodeMaterialConnectionPoint;
  117410. /**
  117411. * Gets the output component
  117412. */
  117413. readonly output: NodeMaterialConnectionPoint;
  117414. protected _buildBlock(state: NodeMaterialBuildState): this;
  117415. }
  117416. }
  117417. declare module BABYLON {
  117418. /**
  117419. * Block used to remap a float from a range to a new one
  117420. */
  117421. export class RemapBlock extends NodeMaterialBlock {
  117422. /**
  117423. * Gets or sets the source range
  117424. */
  117425. sourceRange: Vector2;
  117426. /**
  117427. * Gets or sets the target range
  117428. */
  117429. targetRange: Vector2;
  117430. /**
  117431. * Creates a new RemapBlock
  117432. * @param name defines the block name
  117433. */
  117434. constructor(name: string);
  117435. /**
  117436. * Gets the current class name
  117437. * @returns the class name
  117438. */
  117439. getClassName(): string;
  117440. /**
  117441. * Gets the input component
  117442. */
  117443. readonly input: NodeMaterialConnectionPoint;
  117444. /**
  117445. * Gets the output component
  117446. */
  117447. readonly output: NodeMaterialConnectionPoint;
  117448. protected _buildBlock(state: NodeMaterialBuildState): this;
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /**
  117453. * Block used to normalize a vector
  117454. */
  117455. export class NormalizeBlock extends NodeMaterialBlock {
  117456. /**
  117457. * Creates a new NormalizeBlock
  117458. * @param name defines the block name
  117459. */
  117460. constructor(name: string);
  117461. /**
  117462. * Gets the current class name
  117463. * @returns the class name
  117464. */
  117465. getClassName(): string;
  117466. /**
  117467. * Gets the input component
  117468. */
  117469. readonly input: NodeMaterialConnectionPoint;
  117470. /**
  117471. * Gets the output component
  117472. */
  117473. readonly output: NodeMaterialConnectionPoint;
  117474. protected _buildBlock(state: NodeMaterialBuildState): this;
  117475. }
  117476. }
  117477. declare module BABYLON {
  117478. /**
  117479. * Effect Render Options
  117480. */
  117481. export interface IEffectRendererOptions {
  117482. /**
  117483. * Defines the vertices positions.
  117484. */
  117485. positions?: number[];
  117486. /**
  117487. * Defines the indices.
  117488. */
  117489. indices?: number[];
  117490. }
  117491. /**
  117492. * Helper class to render one or more effects
  117493. */
  117494. export class EffectRenderer {
  117495. private engine;
  117496. private static _DefaultOptions;
  117497. private _vertexBuffers;
  117498. private _indexBuffer;
  117499. private _ringBufferIndex;
  117500. private _ringScreenBuffer;
  117501. private _fullscreenViewport;
  117502. private _getNextFrameBuffer;
  117503. /**
  117504. * Creates an effect renderer
  117505. * @param engine the engine to use for rendering
  117506. * @param options defines the options of the effect renderer
  117507. */
  117508. constructor(engine: Engine, options?: IEffectRendererOptions);
  117509. /**
  117510. * Sets the current viewport in normalized coordinates 0-1
  117511. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  117512. */
  117513. setViewport(viewport?: Viewport): void;
  117514. /**
  117515. * Sets the current effect wrapper to use during draw.
  117516. * The effect needs to be ready before calling this api.
  117517. * This also sets the default full screen position attribute.
  117518. * @param effectWrapper Defines the effect to draw with
  117519. */
  117520. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  117521. /**
  117522. * Draws a full screen quad.
  117523. */
  117524. draw(): void;
  117525. /**
  117526. * renders one or more effects to a specified texture
  117527. * @param effectWrappers list of effects to renderer
  117528. * @param outputTexture texture to draw to, if null it will render to the screen
  117529. */
  117530. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  117531. /**
  117532. * Disposes of the effect renderer
  117533. */
  117534. dispose(): void;
  117535. }
  117536. /**
  117537. * Options to create an EffectWrapper
  117538. */
  117539. interface EffectWrapperCreationOptions {
  117540. /**
  117541. * Engine to use to create the effect
  117542. */
  117543. engine: Engine;
  117544. /**
  117545. * Fragment shader for the effect
  117546. */
  117547. fragmentShader: string;
  117548. /**
  117549. * Vertex shader for the effect
  117550. */
  117551. vertexShader?: string;
  117552. /**
  117553. * Attributes to use in the shader
  117554. */
  117555. attributeNames?: Array<string>;
  117556. /**
  117557. * Uniforms to use in the shader
  117558. */
  117559. uniformNames?: Array<string>;
  117560. /**
  117561. * Texture sampler names to use in the shader
  117562. */
  117563. samplerNames?: Array<string>;
  117564. /**
  117565. * The friendly name of the effect displayed in Spector.
  117566. */
  117567. name?: string;
  117568. }
  117569. /**
  117570. * Wraps an effect to be used for rendering
  117571. */
  117572. export class EffectWrapper {
  117573. /**
  117574. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117575. */
  117576. onApplyObservable: Observable<{}>;
  117577. /**
  117578. * The underlying effect
  117579. */
  117580. effect: Effect;
  117581. /**
  117582. * Creates an effect to be renderer
  117583. * @param creationOptions options to create the effect
  117584. */
  117585. constructor(creationOptions: EffectWrapperCreationOptions);
  117586. /**
  117587. * Disposes of the effect wrapper
  117588. */
  117589. dispose(): void;
  117590. }
  117591. }
  117592. declare module BABYLON {
  117593. /**
  117594. * Helper class to push actions to a pool of workers.
  117595. */
  117596. export class WorkerPool implements IDisposable {
  117597. private _workerInfos;
  117598. private _pendingActions;
  117599. /**
  117600. * Constructor
  117601. * @param workers Array of workers to use for actions
  117602. */
  117603. constructor(workers: Array<Worker>);
  117604. /**
  117605. * Terminates all workers and clears any pending actions.
  117606. */
  117607. dispose(): void;
  117608. /**
  117609. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117610. * pended until a worker has completed its action.
  117611. * @param action The action to perform. Call onComplete when the action is complete.
  117612. */
  117613. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117614. private _execute;
  117615. }
  117616. }
  117617. declare module BABYLON {
  117618. /**
  117619. * Configuration for Draco compression
  117620. */
  117621. export interface IDracoCompressionConfiguration {
  117622. /**
  117623. * Configuration for the decoder.
  117624. */
  117625. decoder: {
  117626. /**
  117627. * The url to the WebAssembly module.
  117628. */
  117629. wasmUrl?: string;
  117630. /**
  117631. * The url to the WebAssembly binary.
  117632. */
  117633. wasmBinaryUrl?: string;
  117634. /**
  117635. * The url to the fallback JavaScript module.
  117636. */
  117637. fallbackUrl?: string;
  117638. };
  117639. }
  117640. /**
  117641. * Draco compression (https://google.github.io/draco/)
  117642. *
  117643. * This class wraps the Draco module.
  117644. *
  117645. * **Encoder**
  117646. *
  117647. * The encoder is not currently implemented.
  117648. *
  117649. * **Decoder**
  117650. *
  117651. * 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.
  117652. *
  117653. * To update the configuration, use the following code:
  117654. * ```javascript
  117655. * DracoCompression.Configuration = {
  117656. * decoder: {
  117657. * wasmUrl: "<url to the WebAssembly library>",
  117658. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117659. * fallbackUrl: "<url to the fallback JavaScript library>",
  117660. * }
  117661. * };
  117662. * ```
  117663. *
  117664. * 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.
  117665. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  117666. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  117667. *
  117668. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  117669. * ```javascript
  117670. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  117671. * ```
  117672. *
  117673. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  117674. */
  117675. export class DracoCompression implements IDisposable {
  117676. private _workerPoolPromise?;
  117677. private _decoderModulePromise?;
  117678. /**
  117679. * The configuration. Defaults to the following urls:
  117680. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  117681. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  117682. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117683. */
  117684. static Configuration: IDracoCompressionConfiguration;
  117685. /**
  117686. * Returns true if the decoder configuration is available.
  117687. */
  117688. static readonly DecoderAvailable: boolean;
  117689. /**
  117690. * Default number of workers to create when creating the draco compression object.
  117691. */
  117692. static DefaultNumWorkers: number;
  117693. private static GetDefaultNumWorkers;
  117694. private static _Default;
  117695. /**
  117696. * Default instance for the draco compression object.
  117697. */
  117698. static readonly Default: DracoCompression;
  117699. /**
  117700. * Constructor
  117701. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  117702. */
  117703. constructor(numWorkers?: number);
  117704. /**
  117705. * Stop all async operations and release resources.
  117706. */
  117707. dispose(): void;
  117708. /**
  117709. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  117710. * @returns a promise that resolves when ready
  117711. */
  117712. whenReadyAsync(): Promise<void>;
  117713. /**
  117714. * Decode Draco compressed mesh data to vertex data.
  117715. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  117716. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  117717. * @returns A promise that resolves with the decoded vertex data
  117718. */
  117719. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  117720. [kind: string]: number;
  117721. }): Promise<VertexData>;
  117722. }
  117723. }
  117724. declare module BABYLON {
  117725. /**
  117726. * Class for building Constructive Solid Geometry
  117727. */
  117728. export class CSG {
  117729. private polygons;
  117730. /**
  117731. * The world matrix
  117732. */
  117733. matrix: Matrix;
  117734. /**
  117735. * Stores the position
  117736. */
  117737. position: Vector3;
  117738. /**
  117739. * Stores the rotation
  117740. */
  117741. rotation: Vector3;
  117742. /**
  117743. * Stores the rotation quaternion
  117744. */
  117745. rotationQuaternion: Nullable<Quaternion>;
  117746. /**
  117747. * Stores the scaling vector
  117748. */
  117749. scaling: Vector3;
  117750. /**
  117751. * Convert the Mesh to CSG
  117752. * @param mesh The Mesh to convert to CSG
  117753. * @returns A new CSG from the Mesh
  117754. */
  117755. static FromMesh(mesh: Mesh): CSG;
  117756. /**
  117757. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  117758. * @param polygons Polygons used to construct a CSG solid
  117759. */
  117760. private static FromPolygons;
  117761. /**
  117762. * Clones, or makes a deep copy, of the CSG
  117763. * @returns A new CSG
  117764. */
  117765. clone(): CSG;
  117766. /**
  117767. * Unions this CSG with another CSG
  117768. * @param csg The CSG to union against this CSG
  117769. * @returns The unioned CSG
  117770. */
  117771. union(csg: CSG): CSG;
  117772. /**
  117773. * Unions this CSG with another CSG in place
  117774. * @param csg The CSG to union against this CSG
  117775. */
  117776. unionInPlace(csg: CSG): void;
  117777. /**
  117778. * Subtracts this CSG with another CSG
  117779. * @param csg The CSG to subtract against this CSG
  117780. * @returns A new CSG
  117781. */
  117782. subtract(csg: CSG): CSG;
  117783. /**
  117784. * Subtracts this CSG with another CSG in place
  117785. * @param csg The CSG to subtact against this CSG
  117786. */
  117787. subtractInPlace(csg: CSG): void;
  117788. /**
  117789. * Intersect this CSG with another CSG
  117790. * @param csg The CSG to intersect against this CSG
  117791. * @returns A new CSG
  117792. */
  117793. intersect(csg: CSG): CSG;
  117794. /**
  117795. * Intersects this CSG with another CSG in place
  117796. * @param csg The CSG to intersect against this CSG
  117797. */
  117798. intersectInPlace(csg: CSG): void;
  117799. /**
  117800. * Return a new CSG solid with solid and empty space switched. This solid is
  117801. * not modified.
  117802. * @returns A new CSG solid with solid and empty space switched
  117803. */
  117804. inverse(): CSG;
  117805. /**
  117806. * Inverses the CSG in place
  117807. */
  117808. inverseInPlace(): void;
  117809. /**
  117810. * This is used to keep meshes transformations so they can be restored
  117811. * when we build back a Babylon Mesh
  117812. * NB : All CSG operations are performed in world coordinates
  117813. * @param csg The CSG to copy the transform attributes from
  117814. * @returns This CSG
  117815. */
  117816. copyTransformAttributes(csg: CSG): CSG;
  117817. /**
  117818. * Build Raw mesh from CSG
  117819. * Coordinates here are in world space
  117820. * @param name The name of the mesh geometry
  117821. * @param scene The Scene
  117822. * @param keepSubMeshes Specifies if the submeshes should be kept
  117823. * @returns A new Mesh
  117824. */
  117825. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  117826. /**
  117827. * Build Mesh from CSG taking material and transforms into account
  117828. * @param name The name of the Mesh
  117829. * @param material The material of the Mesh
  117830. * @param scene The Scene
  117831. * @param keepSubMeshes Specifies if submeshes should be kept
  117832. * @returns The new Mesh
  117833. */
  117834. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117835. }
  117836. }
  117837. declare module BABYLON {
  117838. /**
  117839. * Class used to create a trail following a mesh
  117840. */
  117841. export class TrailMesh extends Mesh {
  117842. private _generator;
  117843. private _autoStart;
  117844. private _running;
  117845. private _diameter;
  117846. private _length;
  117847. private _sectionPolygonPointsCount;
  117848. private _sectionVectors;
  117849. private _sectionNormalVectors;
  117850. private _beforeRenderObserver;
  117851. /**
  117852. * @constructor
  117853. * @param name The value used by scene.getMeshByName() to do a lookup.
  117854. * @param generator The mesh to generate a trail.
  117855. * @param scene The scene to add this mesh to.
  117856. * @param diameter Diameter of trailing mesh. Default is 1.
  117857. * @param length Length of trailing mesh. Default is 60.
  117858. * @param autoStart Automatically start trailing mesh. Default true.
  117859. */
  117860. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117861. /**
  117862. * "TrailMesh"
  117863. * @returns "TrailMesh"
  117864. */
  117865. getClassName(): string;
  117866. private _createMesh;
  117867. /**
  117868. * Start trailing mesh.
  117869. */
  117870. start(): void;
  117871. /**
  117872. * Stop trailing mesh.
  117873. */
  117874. stop(): void;
  117875. /**
  117876. * Update trailing mesh geometry.
  117877. */
  117878. update(): void;
  117879. /**
  117880. * Returns a new TrailMesh object.
  117881. * @param name is a string, the name given to the new mesh
  117882. * @param newGenerator use new generator object for cloned trail mesh
  117883. * @returns a new mesh
  117884. */
  117885. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117886. /**
  117887. * Serializes this trail mesh
  117888. * @param serializationObject object to write serialization to
  117889. */
  117890. serialize(serializationObject: any): void;
  117891. /**
  117892. * Parses a serialized trail mesh
  117893. * @param parsedMesh the serialized mesh
  117894. * @param scene the scene to create the trail mesh in
  117895. * @returns the created trail mesh
  117896. */
  117897. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117898. }
  117899. }
  117900. declare module BABYLON {
  117901. /**
  117902. * Class containing static functions to help procedurally build meshes
  117903. */
  117904. export class TiledBoxBuilder {
  117905. /**
  117906. * Creates a box mesh
  117907. * 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)
  117908. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117912. * @param name defines the name of the mesh
  117913. * @param options defines the options used to create the mesh
  117914. * @param scene defines the hosting scene
  117915. * @returns the box mesh
  117916. */
  117917. static CreateTiledBox(name: string, options: {
  117918. pattern?: number;
  117919. width?: number;
  117920. height?: number;
  117921. depth?: number;
  117922. tileSize?: number;
  117923. tileWidth?: number;
  117924. tileHeight?: number;
  117925. alignHorizontal?: number;
  117926. alignVertical?: number;
  117927. faceUV?: Vector4[];
  117928. faceColors?: Color4[];
  117929. sideOrientation?: number;
  117930. updatable?: boolean;
  117931. }, scene?: Nullable<Scene>): Mesh;
  117932. }
  117933. }
  117934. declare module BABYLON {
  117935. /**
  117936. * Class containing static functions to help procedurally build meshes
  117937. */
  117938. export class TorusKnotBuilder {
  117939. /**
  117940. * Creates a torus knot mesh
  117941. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117942. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117943. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117944. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117948. * @param name defines the name of the mesh
  117949. * @param options defines the options used to create the mesh
  117950. * @param scene defines the hosting scene
  117951. * @returns the torus knot mesh
  117952. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117953. */
  117954. static CreateTorusKnot(name: string, options: {
  117955. radius?: number;
  117956. tube?: number;
  117957. radialSegments?: number;
  117958. tubularSegments?: number;
  117959. p?: number;
  117960. q?: number;
  117961. updatable?: boolean;
  117962. sideOrientation?: number;
  117963. frontUVs?: Vector4;
  117964. backUVs?: Vector4;
  117965. }, scene: any): Mesh;
  117966. }
  117967. }
  117968. declare module BABYLON {
  117969. /**
  117970. * Polygon
  117971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117972. */
  117973. export class Polygon {
  117974. /**
  117975. * Creates a rectangle
  117976. * @param xmin bottom X coord
  117977. * @param ymin bottom Y coord
  117978. * @param xmax top X coord
  117979. * @param ymax top Y coord
  117980. * @returns points that make the resulting rectation
  117981. */
  117982. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117983. /**
  117984. * Creates a circle
  117985. * @param radius radius of circle
  117986. * @param cx scale in x
  117987. * @param cy scale in y
  117988. * @param numberOfSides number of sides that make up the circle
  117989. * @returns points that make the resulting circle
  117990. */
  117991. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117992. /**
  117993. * Creates a polygon from input string
  117994. * @param input Input polygon data
  117995. * @returns the parsed points
  117996. */
  117997. static Parse(input: string): Vector2[];
  117998. /**
  117999. * Starts building a polygon from x and y coordinates
  118000. * @param x x coordinate
  118001. * @param y y coordinate
  118002. * @returns the started path2
  118003. */
  118004. static StartingAt(x: number, y: number): Path2;
  118005. }
  118006. /**
  118007. * Builds a polygon
  118008. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118009. */
  118010. export class PolygonMeshBuilder {
  118011. private _points;
  118012. private _outlinepoints;
  118013. private _holes;
  118014. private _name;
  118015. private _scene;
  118016. private _epoints;
  118017. private _eholes;
  118018. private _addToepoint;
  118019. /**
  118020. * Babylon reference to the earcut plugin.
  118021. */
  118022. bjsEarcut: any;
  118023. /**
  118024. * Creates a PolygonMeshBuilder
  118025. * @param name name of the builder
  118026. * @param contours Path of the polygon
  118027. * @param scene scene to add to when creating the mesh
  118028. * @param earcutInjection can be used to inject your own earcut reference
  118029. */
  118030. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118031. /**
  118032. * Adds a whole within the polygon
  118033. * @param hole Array of points defining the hole
  118034. * @returns this
  118035. */
  118036. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118037. /**
  118038. * Creates the polygon
  118039. * @param updatable If the mesh should be updatable
  118040. * @param depth The depth of the mesh created
  118041. * @returns the created mesh
  118042. */
  118043. build(updatable?: boolean, depth?: number): Mesh;
  118044. /**
  118045. * Creates the polygon
  118046. * @param depth The depth of the mesh created
  118047. * @returns the created VertexData
  118048. */
  118049. buildVertexData(depth?: number): VertexData;
  118050. /**
  118051. * Adds a side to the polygon
  118052. * @param positions points that make the polygon
  118053. * @param normals normals of the polygon
  118054. * @param uvs uvs of the polygon
  118055. * @param indices indices of the polygon
  118056. * @param bounds bounds of the polygon
  118057. * @param points points of the polygon
  118058. * @param depth depth of the polygon
  118059. * @param flip flip of the polygon
  118060. */
  118061. private addSide;
  118062. }
  118063. }
  118064. declare module BABYLON {
  118065. /**
  118066. * Class containing static functions to help procedurally build meshes
  118067. */
  118068. export class PolygonBuilder {
  118069. /**
  118070. * Creates a polygon mesh
  118071. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118072. * * 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
  118073. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118076. * * Remember you can only change the shape positions, not their number when updating a polygon
  118077. * @param name defines the name of the mesh
  118078. * @param options defines the options used to create the mesh
  118079. * @param scene defines the hosting scene
  118080. * @param earcutInjection can be used to inject your own earcut reference
  118081. * @returns the polygon mesh
  118082. */
  118083. static CreatePolygon(name: string, options: {
  118084. shape: Vector3[];
  118085. holes?: Vector3[][];
  118086. depth?: number;
  118087. faceUV?: Vector4[];
  118088. faceColors?: Color4[];
  118089. updatable?: boolean;
  118090. sideOrientation?: number;
  118091. frontUVs?: Vector4;
  118092. backUVs?: Vector4;
  118093. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118094. /**
  118095. * Creates an extruded polygon mesh, with depth in the Y direction.
  118096. * * 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)
  118097. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118098. * @param name defines the name of the mesh
  118099. * @param options defines the options used to create the mesh
  118100. * @param scene defines the hosting scene
  118101. * @param earcutInjection can be used to inject your own earcut reference
  118102. * @returns the polygon mesh
  118103. */
  118104. static ExtrudePolygon(name: string, options: {
  118105. shape: Vector3[];
  118106. holes?: Vector3[][];
  118107. depth?: number;
  118108. faceUV?: Vector4[];
  118109. faceColors?: Color4[];
  118110. updatable?: boolean;
  118111. sideOrientation?: number;
  118112. frontUVs?: Vector4;
  118113. backUVs?: Vector4;
  118114. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118115. }
  118116. }
  118117. declare module BABYLON {
  118118. /**
  118119. * Class containing static functions to help procedurally build meshes
  118120. */
  118121. export class LatheBuilder {
  118122. /**
  118123. * Creates lathe mesh.
  118124. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118125. * * 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
  118126. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118127. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118128. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118129. * * 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
  118130. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118131. * * 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
  118132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118136. * @param name defines the name of the mesh
  118137. * @param options defines the options used to create the mesh
  118138. * @param scene defines the hosting scene
  118139. * @returns the lathe mesh
  118140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118141. */
  118142. static CreateLathe(name: string, options: {
  118143. shape: Vector3[];
  118144. radius?: number;
  118145. tessellation?: number;
  118146. clip?: number;
  118147. arc?: number;
  118148. closed?: boolean;
  118149. updatable?: boolean;
  118150. sideOrientation?: number;
  118151. frontUVs?: Vector4;
  118152. backUVs?: Vector4;
  118153. cap?: number;
  118154. invertUV?: boolean;
  118155. }, scene?: Nullable<Scene>): Mesh;
  118156. }
  118157. }
  118158. declare module BABYLON {
  118159. /**
  118160. * Class containing static functions to help procedurally build meshes
  118161. */
  118162. export class TiledPlaneBuilder {
  118163. /**
  118164. * Creates a tiled plane mesh
  118165. * * The parameter `pattern` will, depending on value, do nothing or
  118166. * * * flip (reflect about central vertical) alternate tiles across and up
  118167. * * * flip every tile on alternate rows
  118168. * * * rotate (180 degs) alternate tiles across and up
  118169. * * * rotate every tile on alternate rows
  118170. * * * flip and rotate alternate tiles across and up
  118171. * * * flip and rotate every tile on alternate rows
  118172. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  118173. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  118174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118176. * * 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)
  118177. * * 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)
  118178. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118179. * @param name defines the name of the mesh
  118180. * @param options defines the options used to create the mesh
  118181. * @param scene defines the hosting scene
  118182. * @returns the box mesh
  118183. */
  118184. static CreateTiledPlane(name: string, options: {
  118185. pattern?: number;
  118186. tileSize?: number;
  118187. tileWidth?: number;
  118188. tileHeight?: number;
  118189. size?: number;
  118190. width?: number;
  118191. height?: number;
  118192. alignHorizontal?: number;
  118193. alignVertical?: number;
  118194. sideOrientation?: number;
  118195. frontUVs?: Vector4;
  118196. backUVs?: Vector4;
  118197. updatable?: boolean;
  118198. }, scene?: Nullable<Scene>): Mesh;
  118199. }
  118200. }
  118201. declare module BABYLON {
  118202. /**
  118203. * Class containing static functions to help procedurally build meshes
  118204. */
  118205. export class TubeBuilder {
  118206. /**
  118207. * Creates a tube mesh.
  118208. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118209. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118210. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118211. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118212. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118213. * * 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)
  118214. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118215. * * 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
  118216. * * 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
  118217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118221. * @param name defines the name of the mesh
  118222. * @param options defines the options used to create the mesh
  118223. * @param scene defines the hosting scene
  118224. * @returns the tube mesh
  118225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118226. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118227. */
  118228. static CreateTube(name: string, options: {
  118229. path: Vector3[];
  118230. radius?: number;
  118231. tessellation?: number;
  118232. radiusFunction?: {
  118233. (i: number, distance: number): number;
  118234. };
  118235. cap?: number;
  118236. arc?: number;
  118237. updatable?: boolean;
  118238. sideOrientation?: number;
  118239. frontUVs?: Vector4;
  118240. backUVs?: Vector4;
  118241. instance?: Mesh;
  118242. invertUV?: boolean;
  118243. }, scene?: Nullable<Scene>): Mesh;
  118244. }
  118245. }
  118246. declare module BABYLON {
  118247. /**
  118248. * Class containing static functions to help procedurally build meshes
  118249. */
  118250. export class IcoSphereBuilder {
  118251. /**
  118252. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118253. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118254. * * 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`)
  118255. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118256. * * 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
  118257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118260. * @param name defines the name of the mesh
  118261. * @param options defines the options used to create the mesh
  118262. * @param scene defines the hosting scene
  118263. * @returns the icosahedron mesh
  118264. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118265. */
  118266. static CreateIcoSphere(name: string, options: {
  118267. radius?: number;
  118268. radiusX?: number;
  118269. radiusY?: number;
  118270. radiusZ?: number;
  118271. flat?: boolean;
  118272. subdivisions?: number;
  118273. sideOrientation?: number;
  118274. frontUVs?: Vector4;
  118275. backUVs?: Vector4;
  118276. updatable?: boolean;
  118277. }, scene?: Nullable<Scene>): Mesh;
  118278. }
  118279. }
  118280. declare module BABYLON {
  118281. /**
  118282. * Class containing static functions to help procedurally build meshes
  118283. */
  118284. export class DecalBuilder {
  118285. /**
  118286. * Creates a decal mesh.
  118287. * 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
  118288. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118289. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118290. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118291. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118292. * @param name defines the name of the mesh
  118293. * @param sourceMesh defines the mesh where the decal must be applied
  118294. * @param options defines the options used to create the mesh
  118295. * @param scene defines the hosting scene
  118296. * @returns the decal mesh
  118297. * @see https://doc.babylonjs.com/how_to/decals
  118298. */
  118299. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118300. position?: Vector3;
  118301. normal?: Vector3;
  118302. size?: Vector3;
  118303. angle?: number;
  118304. }): Mesh;
  118305. }
  118306. }
  118307. declare module BABYLON {
  118308. /**
  118309. * Class containing static functions to help procedurally build meshes
  118310. */
  118311. export class MeshBuilder {
  118312. /**
  118313. * Creates a box mesh
  118314. * * The parameter `size` sets the size (float) of each box side (default 1)
  118315. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118316. * * 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)
  118317. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118321. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118322. * @param name defines the name of the mesh
  118323. * @param options defines the options used to create the mesh
  118324. * @param scene defines the hosting scene
  118325. * @returns the box mesh
  118326. */
  118327. static CreateBox(name: string, options: {
  118328. size?: number;
  118329. width?: number;
  118330. height?: number;
  118331. depth?: number;
  118332. faceUV?: Vector4[];
  118333. faceColors?: Color4[];
  118334. sideOrientation?: number;
  118335. frontUVs?: Vector4;
  118336. backUVs?: Vector4;
  118337. updatable?: boolean;
  118338. }, scene?: Nullable<Scene>): Mesh;
  118339. /**
  118340. * Creates a tiled box mesh
  118341. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118343. * @param name defines the name of the mesh
  118344. * @param options defines the options used to create the mesh
  118345. * @param scene defines the hosting scene
  118346. * @returns the tiled box mesh
  118347. */
  118348. static CreateTiledBox(name: string, options: {
  118349. pattern?: number;
  118350. size?: number;
  118351. width?: number;
  118352. height?: number;
  118353. depth: number;
  118354. tileSize?: number;
  118355. tileWidth?: number;
  118356. tileHeight?: number;
  118357. faceUV?: Vector4[];
  118358. faceColors?: Color4[];
  118359. alignHorizontal?: number;
  118360. alignVertical?: number;
  118361. sideOrientation?: number;
  118362. updatable?: boolean;
  118363. }, scene?: Nullable<Scene>): Mesh;
  118364. /**
  118365. * Creates a sphere mesh
  118366. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118367. * * 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`)
  118368. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118369. * * 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
  118370. * * 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)
  118371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118374. * @param name defines the name of the mesh
  118375. * @param options defines the options used to create the mesh
  118376. * @param scene defines the hosting scene
  118377. * @returns the sphere mesh
  118378. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118379. */
  118380. static CreateSphere(name: string, options: {
  118381. segments?: number;
  118382. diameter?: number;
  118383. diameterX?: number;
  118384. diameterY?: number;
  118385. diameterZ?: number;
  118386. arc?: number;
  118387. slice?: number;
  118388. sideOrientation?: number;
  118389. frontUVs?: Vector4;
  118390. backUVs?: Vector4;
  118391. updatable?: boolean;
  118392. }, scene?: Nullable<Scene>): Mesh;
  118393. /**
  118394. * Creates a plane polygonal mesh. By default, this is a disc
  118395. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  118396. * * 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
  118397. * * 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
  118398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118401. * @param name defines the name of the mesh
  118402. * @param options defines the options used to create the mesh
  118403. * @param scene defines the hosting scene
  118404. * @returns the plane polygonal mesh
  118405. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  118406. */
  118407. static CreateDisc(name: string, options: {
  118408. radius?: number;
  118409. tessellation?: number;
  118410. arc?: number;
  118411. updatable?: boolean;
  118412. sideOrientation?: number;
  118413. frontUVs?: Vector4;
  118414. backUVs?: Vector4;
  118415. }, scene?: Nullable<Scene>): Mesh;
  118416. /**
  118417. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118418. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118419. * * 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`)
  118420. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118421. * * 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
  118422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118425. * @param name defines the name of the mesh
  118426. * @param options defines the options used to create the mesh
  118427. * @param scene defines the hosting scene
  118428. * @returns the icosahedron mesh
  118429. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118430. */
  118431. static CreateIcoSphere(name: string, options: {
  118432. radius?: number;
  118433. radiusX?: number;
  118434. radiusY?: number;
  118435. radiusZ?: number;
  118436. flat?: boolean;
  118437. subdivisions?: number;
  118438. sideOrientation?: number;
  118439. frontUVs?: Vector4;
  118440. backUVs?: Vector4;
  118441. updatable?: boolean;
  118442. }, scene?: Nullable<Scene>): Mesh;
  118443. /**
  118444. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118445. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118446. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118447. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118448. * * 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
  118449. * * 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
  118450. * * 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
  118451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118454. * * 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
  118455. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118456. * * 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
  118457. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118459. * @param name defines the name of the mesh
  118460. * @param options defines the options used to create the mesh
  118461. * @param scene defines the hosting scene
  118462. * @returns the ribbon mesh
  118463. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118465. */
  118466. static CreateRibbon(name: string, options: {
  118467. pathArray: Vector3[][];
  118468. closeArray?: boolean;
  118469. closePath?: boolean;
  118470. offset?: number;
  118471. updatable?: boolean;
  118472. sideOrientation?: number;
  118473. frontUVs?: Vector4;
  118474. backUVs?: Vector4;
  118475. instance?: Mesh;
  118476. invertUV?: boolean;
  118477. uvs?: Vector2[];
  118478. colors?: Color4[];
  118479. }, scene?: Nullable<Scene>): Mesh;
  118480. /**
  118481. * Creates a cylinder or a cone mesh
  118482. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118483. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118484. * * 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.
  118485. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118486. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118487. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118488. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118489. * * 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).
  118490. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118491. * * 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).
  118492. * * 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
  118493. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118494. * * 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
  118495. * * 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.
  118496. * * If `enclose` is false, a ring surface is one element.
  118497. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118498. * * 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
  118499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118502. * @param name defines the name of the mesh
  118503. * @param options defines the options used to create the mesh
  118504. * @param scene defines the hosting scene
  118505. * @returns the cylinder mesh
  118506. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118507. */
  118508. static CreateCylinder(name: string, options: {
  118509. height?: number;
  118510. diameterTop?: number;
  118511. diameterBottom?: number;
  118512. diameter?: number;
  118513. tessellation?: number;
  118514. subdivisions?: number;
  118515. arc?: number;
  118516. faceColors?: Color4[];
  118517. faceUV?: Vector4[];
  118518. updatable?: boolean;
  118519. hasRings?: boolean;
  118520. enclose?: boolean;
  118521. cap?: number;
  118522. sideOrientation?: number;
  118523. frontUVs?: Vector4;
  118524. backUVs?: Vector4;
  118525. }, scene?: Nullable<Scene>): Mesh;
  118526. /**
  118527. * Creates a torus mesh
  118528. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118529. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118530. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118534. * @param name defines the name of the mesh
  118535. * @param options defines the options used to create the mesh
  118536. * @param scene defines the hosting scene
  118537. * @returns the torus mesh
  118538. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118539. */
  118540. static CreateTorus(name: string, options: {
  118541. diameter?: number;
  118542. thickness?: number;
  118543. tessellation?: number;
  118544. updatable?: boolean;
  118545. sideOrientation?: number;
  118546. frontUVs?: Vector4;
  118547. backUVs?: Vector4;
  118548. }, scene?: Nullable<Scene>): Mesh;
  118549. /**
  118550. * Creates a torus knot mesh
  118551. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118552. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118553. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118554. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118558. * @param name defines the name of the mesh
  118559. * @param options defines the options used to create the mesh
  118560. * @param scene defines the hosting scene
  118561. * @returns the torus knot mesh
  118562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118563. */
  118564. static CreateTorusKnot(name: string, options: {
  118565. radius?: number;
  118566. tube?: number;
  118567. radialSegments?: number;
  118568. tubularSegments?: number;
  118569. p?: number;
  118570. q?: number;
  118571. updatable?: boolean;
  118572. sideOrientation?: number;
  118573. frontUVs?: Vector4;
  118574. backUVs?: Vector4;
  118575. }, scene?: Nullable<Scene>): Mesh;
  118576. /**
  118577. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118578. * * 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
  118579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118580. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118581. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118582. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118583. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118584. * * 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
  118585. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118588. * @param name defines the name of the new line system
  118589. * @param options defines the options used to create the line system
  118590. * @param scene defines the hosting scene
  118591. * @returns a new line system mesh
  118592. */
  118593. static CreateLineSystem(name: string, options: {
  118594. lines: Vector3[][];
  118595. updatable?: boolean;
  118596. instance?: Nullable<LinesMesh>;
  118597. colors?: Nullable<Color4[][]>;
  118598. useVertexAlpha?: boolean;
  118599. }, scene: Nullable<Scene>): LinesMesh;
  118600. /**
  118601. * Creates a line mesh
  118602. * 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
  118603. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118604. * * The parameter `points` is an array successive Vector3
  118605. * * 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
  118606. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118607. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118608. * * When updating an instance, remember that only point positions can change, not the number of points
  118609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118611. * @param name defines the name of the new line system
  118612. * @param options defines the options used to create the line system
  118613. * @param scene defines the hosting scene
  118614. * @returns a new line mesh
  118615. */
  118616. static CreateLines(name: string, options: {
  118617. points: Vector3[];
  118618. updatable?: boolean;
  118619. instance?: Nullable<LinesMesh>;
  118620. colors?: Color4[];
  118621. useVertexAlpha?: boolean;
  118622. }, scene?: Nullable<Scene>): LinesMesh;
  118623. /**
  118624. * Creates a dashed line mesh
  118625. * * 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
  118626. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118627. * * The parameter `points` is an array successive Vector3
  118628. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118629. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118630. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118631. * * 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
  118632. * * When updating an instance, remember that only point positions can change, not the number of points
  118633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118634. * @param name defines the name of the mesh
  118635. * @param options defines the options used to create the mesh
  118636. * @param scene defines the hosting scene
  118637. * @returns the dashed line mesh
  118638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118639. */
  118640. static CreateDashedLines(name: string, options: {
  118641. points: Vector3[];
  118642. dashSize?: number;
  118643. gapSize?: number;
  118644. dashNb?: number;
  118645. updatable?: boolean;
  118646. instance?: LinesMesh;
  118647. }, scene?: Nullable<Scene>): LinesMesh;
  118648. /**
  118649. * 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.
  118650. * * 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.
  118651. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118652. * * 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.
  118653. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118654. * * 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
  118655. * * 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
  118656. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118661. * @param name defines the name of the mesh
  118662. * @param options defines the options used to create the mesh
  118663. * @param scene defines the hosting scene
  118664. * @returns the extruded shape mesh
  118665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118667. */
  118668. static ExtrudeShape(name: string, options: {
  118669. shape: Vector3[];
  118670. path: Vector3[];
  118671. scale?: number;
  118672. rotation?: number;
  118673. cap?: number;
  118674. updatable?: boolean;
  118675. sideOrientation?: number;
  118676. frontUVs?: Vector4;
  118677. backUVs?: Vector4;
  118678. instance?: Mesh;
  118679. invertUV?: boolean;
  118680. }, scene?: Nullable<Scene>): Mesh;
  118681. /**
  118682. * Creates an custom extruded shape mesh.
  118683. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118684. * * 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.
  118685. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118686. * * 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
  118687. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118688. * * 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
  118689. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118690. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118691. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118692. * * 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
  118693. * * 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
  118694. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118699. * @param name defines the name of the mesh
  118700. * @param options defines the options used to create the mesh
  118701. * @param scene defines the hosting scene
  118702. * @returns the custom extruded shape mesh
  118703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118706. */
  118707. static ExtrudeShapeCustom(name: string, options: {
  118708. shape: Vector3[];
  118709. path: Vector3[];
  118710. scaleFunction?: any;
  118711. rotationFunction?: any;
  118712. ribbonCloseArray?: boolean;
  118713. ribbonClosePath?: boolean;
  118714. cap?: number;
  118715. updatable?: boolean;
  118716. sideOrientation?: number;
  118717. frontUVs?: Vector4;
  118718. backUVs?: Vector4;
  118719. instance?: Mesh;
  118720. invertUV?: boolean;
  118721. }, scene?: Nullable<Scene>): Mesh;
  118722. /**
  118723. * Creates lathe mesh.
  118724. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118725. * * 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
  118726. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118727. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118728. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118729. * * 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
  118730. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118731. * * 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
  118732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118736. * @param name defines the name of the mesh
  118737. * @param options defines the options used to create the mesh
  118738. * @param scene defines the hosting scene
  118739. * @returns the lathe mesh
  118740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118741. */
  118742. static CreateLathe(name: string, options: {
  118743. shape: Vector3[];
  118744. radius?: number;
  118745. tessellation?: number;
  118746. clip?: number;
  118747. arc?: number;
  118748. closed?: boolean;
  118749. updatable?: boolean;
  118750. sideOrientation?: number;
  118751. frontUVs?: Vector4;
  118752. backUVs?: Vector4;
  118753. cap?: number;
  118754. invertUV?: boolean;
  118755. }, scene?: Nullable<Scene>): Mesh;
  118756. /**
  118757. * Creates a tiled plane mesh
  118758. * * You can set a limited pattern arrangement with the tiles
  118759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118762. * @param name defines the name of the mesh
  118763. * @param options defines the options used to create the mesh
  118764. * @param scene defines the hosting scene
  118765. * @returns the plane mesh
  118766. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118767. */
  118768. static CreateTiledPlane(name: string, options: {
  118769. pattern?: number;
  118770. tileSize?: number;
  118771. tileWidth?: number;
  118772. tileHeight?: number;
  118773. size?: number;
  118774. width?: number;
  118775. height?: number;
  118776. alignHorizontal?: number;
  118777. alignVertical?: number;
  118778. sideOrientation?: number;
  118779. frontUVs?: Vector4;
  118780. backUVs?: Vector4;
  118781. updatable?: boolean;
  118782. }, scene?: Nullable<Scene>): Mesh;
  118783. /**
  118784. * Creates a plane mesh
  118785. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  118786. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  118787. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  118788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118791. * @param name defines the name of the mesh
  118792. * @param options defines the options used to create the mesh
  118793. * @param scene defines the hosting scene
  118794. * @returns the plane mesh
  118795. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118796. */
  118797. static CreatePlane(name: string, options: {
  118798. size?: number;
  118799. width?: number;
  118800. height?: number;
  118801. sideOrientation?: number;
  118802. frontUVs?: Vector4;
  118803. backUVs?: Vector4;
  118804. updatable?: boolean;
  118805. sourcePlane?: Plane;
  118806. }, scene?: Nullable<Scene>): Mesh;
  118807. /**
  118808. * Creates a ground mesh
  118809. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118810. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118812. * @param name defines the name of the mesh
  118813. * @param options defines the options used to create the mesh
  118814. * @param scene defines the hosting scene
  118815. * @returns the ground mesh
  118816. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118817. */
  118818. static CreateGround(name: string, options: {
  118819. width?: number;
  118820. height?: number;
  118821. subdivisions?: number;
  118822. subdivisionsX?: number;
  118823. subdivisionsY?: number;
  118824. updatable?: boolean;
  118825. }, scene?: Nullable<Scene>): Mesh;
  118826. /**
  118827. * Creates a tiled ground mesh
  118828. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118829. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118830. * * 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
  118831. * * 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
  118832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118833. * @param name defines the name of the mesh
  118834. * @param options defines the options used to create the mesh
  118835. * @param scene defines the hosting scene
  118836. * @returns the tiled ground mesh
  118837. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118838. */
  118839. static CreateTiledGround(name: string, options: {
  118840. xmin: number;
  118841. zmin: number;
  118842. xmax: number;
  118843. zmax: number;
  118844. subdivisions?: {
  118845. w: number;
  118846. h: number;
  118847. };
  118848. precision?: {
  118849. w: number;
  118850. h: number;
  118851. };
  118852. updatable?: boolean;
  118853. }, scene?: Nullable<Scene>): Mesh;
  118854. /**
  118855. * Creates a ground mesh from a height map
  118856. * * The parameter `url` sets the URL of the height map image resource.
  118857. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118858. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118859. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118860. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118861. * * 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.
  118862. * * 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).
  118863. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118865. * @param name defines the name of the mesh
  118866. * @param url defines the url to the height map
  118867. * @param options defines the options used to create the mesh
  118868. * @param scene defines the hosting scene
  118869. * @returns the ground mesh
  118870. * @see https://doc.babylonjs.com/babylon101/height_map
  118871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118872. */
  118873. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118874. width?: number;
  118875. height?: number;
  118876. subdivisions?: number;
  118877. minHeight?: number;
  118878. maxHeight?: number;
  118879. colorFilter?: Color3;
  118880. alphaFilter?: number;
  118881. updatable?: boolean;
  118882. onReady?: (mesh: GroundMesh) => void;
  118883. }, scene?: Nullable<Scene>): GroundMesh;
  118884. /**
  118885. * Creates a polygon mesh
  118886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118887. * * 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
  118888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118891. * * Remember you can only change the shape positions, not their number when updating a polygon
  118892. * @param name defines the name of the mesh
  118893. * @param options defines the options used to create the mesh
  118894. * @param scene defines the hosting scene
  118895. * @param earcutInjection can be used to inject your own earcut reference
  118896. * @returns the polygon mesh
  118897. */
  118898. static CreatePolygon(name: string, options: {
  118899. shape: Vector3[];
  118900. holes?: Vector3[][];
  118901. depth?: number;
  118902. faceUV?: Vector4[];
  118903. faceColors?: Color4[];
  118904. updatable?: boolean;
  118905. sideOrientation?: number;
  118906. frontUVs?: Vector4;
  118907. backUVs?: Vector4;
  118908. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118909. /**
  118910. * Creates an extruded polygon mesh, with depth in the Y direction.
  118911. * * 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)
  118912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118913. * @param name defines the name of the mesh
  118914. * @param options defines the options used to create the mesh
  118915. * @param scene defines the hosting scene
  118916. * @param earcutInjection can be used to inject your own earcut reference
  118917. * @returns the polygon mesh
  118918. */
  118919. static ExtrudePolygon(name: string, options: {
  118920. shape: Vector3[];
  118921. holes?: Vector3[][];
  118922. depth?: number;
  118923. faceUV?: Vector4[];
  118924. faceColors?: Color4[];
  118925. updatable?: boolean;
  118926. sideOrientation?: number;
  118927. frontUVs?: Vector4;
  118928. backUVs?: Vector4;
  118929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118930. /**
  118931. * Creates a tube mesh.
  118932. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118933. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118934. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118935. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118936. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118937. * * 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)
  118938. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118939. * * 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
  118940. * * 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
  118941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118945. * @param name defines the name of the mesh
  118946. * @param options defines the options used to create the mesh
  118947. * @param scene defines the hosting scene
  118948. * @returns the tube mesh
  118949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118950. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118951. */
  118952. static CreateTube(name: string, options: {
  118953. path: Vector3[];
  118954. radius?: number;
  118955. tessellation?: number;
  118956. radiusFunction?: {
  118957. (i: number, distance: number): number;
  118958. };
  118959. cap?: number;
  118960. arc?: number;
  118961. updatable?: boolean;
  118962. sideOrientation?: number;
  118963. frontUVs?: Vector4;
  118964. backUVs?: Vector4;
  118965. instance?: Mesh;
  118966. invertUV?: boolean;
  118967. }, scene?: Nullable<Scene>): Mesh;
  118968. /**
  118969. * Creates a polyhedron mesh
  118970. * * 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
  118971. * * The parameter `size` (positive float, default 1) sets the polygon size
  118972. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118973. * * 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`
  118974. * * 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
  118975. * * 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)`)
  118976. * * 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
  118977. * * 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
  118978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118981. * @param name defines the name of the mesh
  118982. * @param options defines the options used to create the mesh
  118983. * @param scene defines the hosting scene
  118984. * @returns the polyhedron mesh
  118985. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118986. */
  118987. static CreatePolyhedron(name: string, options: {
  118988. type?: number;
  118989. size?: number;
  118990. sizeX?: number;
  118991. sizeY?: number;
  118992. sizeZ?: number;
  118993. custom?: any;
  118994. faceUV?: Vector4[];
  118995. faceColors?: Color4[];
  118996. flat?: boolean;
  118997. updatable?: boolean;
  118998. sideOrientation?: number;
  118999. frontUVs?: Vector4;
  119000. backUVs?: Vector4;
  119001. }, scene?: Nullable<Scene>): Mesh;
  119002. /**
  119003. * Creates a decal mesh.
  119004. * 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
  119005. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119006. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119007. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119008. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119009. * @param name defines the name of the mesh
  119010. * @param sourceMesh defines the mesh where the decal must be applied
  119011. * @param options defines the options used to create the mesh
  119012. * @param scene defines the hosting scene
  119013. * @returns the decal mesh
  119014. * @see https://doc.babylonjs.com/how_to/decals
  119015. */
  119016. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119017. position?: Vector3;
  119018. normal?: Vector3;
  119019. size?: Vector3;
  119020. angle?: number;
  119021. }): Mesh;
  119022. }
  119023. }
  119024. declare module BABYLON {
  119025. /**
  119026. * A simplifier interface for future simplification implementations
  119027. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119028. */
  119029. export interface ISimplifier {
  119030. /**
  119031. * Simplification of a given mesh according to the given settings.
  119032. * Since this requires computation, it is assumed that the function runs async.
  119033. * @param settings The settings of the simplification, including quality and distance
  119034. * @param successCallback A callback that will be called after the mesh was simplified.
  119035. * @param errorCallback in case of an error, this callback will be called. optional.
  119036. */
  119037. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119038. }
  119039. /**
  119040. * Expected simplification settings.
  119041. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119043. */
  119044. export interface ISimplificationSettings {
  119045. /**
  119046. * Gets or sets the expected quality
  119047. */
  119048. quality: number;
  119049. /**
  119050. * Gets or sets the distance when this optimized version should be used
  119051. */
  119052. distance: number;
  119053. /**
  119054. * Gets an already optimized mesh
  119055. */
  119056. optimizeMesh?: boolean;
  119057. }
  119058. /**
  119059. * Class used to specify simplification options
  119060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119061. */
  119062. export class SimplificationSettings implements ISimplificationSettings {
  119063. /** expected quality */
  119064. quality: number;
  119065. /** distance when this optimized version should be used */
  119066. distance: number;
  119067. /** already optimized mesh */
  119068. optimizeMesh?: boolean | undefined;
  119069. /**
  119070. * Creates a SimplificationSettings
  119071. * @param quality expected quality
  119072. * @param distance distance when this optimized version should be used
  119073. * @param optimizeMesh already optimized mesh
  119074. */
  119075. constructor(
  119076. /** expected quality */
  119077. quality: number,
  119078. /** distance when this optimized version should be used */
  119079. distance: number,
  119080. /** already optimized mesh */
  119081. optimizeMesh?: boolean | undefined);
  119082. }
  119083. /**
  119084. * Interface used to define a simplification task
  119085. */
  119086. export interface ISimplificationTask {
  119087. /**
  119088. * Array of settings
  119089. */
  119090. settings: Array<ISimplificationSettings>;
  119091. /**
  119092. * Simplification type
  119093. */
  119094. simplificationType: SimplificationType;
  119095. /**
  119096. * Mesh to simplify
  119097. */
  119098. mesh: Mesh;
  119099. /**
  119100. * Callback called on success
  119101. */
  119102. successCallback?: () => void;
  119103. /**
  119104. * Defines if parallel processing can be used
  119105. */
  119106. parallelProcessing: boolean;
  119107. }
  119108. /**
  119109. * Queue used to order the simplification tasks
  119110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119111. */
  119112. export class SimplificationQueue {
  119113. private _simplificationArray;
  119114. /**
  119115. * Gets a boolean indicating that the process is still running
  119116. */
  119117. running: boolean;
  119118. /**
  119119. * Creates a new queue
  119120. */
  119121. constructor();
  119122. /**
  119123. * Adds a new simplification task
  119124. * @param task defines a task to add
  119125. */
  119126. addTask(task: ISimplificationTask): void;
  119127. /**
  119128. * Execute next task
  119129. */
  119130. executeNext(): void;
  119131. /**
  119132. * Execute a simplification task
  119133. * @param task defines the task to run
  119134. */
  119135. runSimplification(task: ISimplificationTask): void;
  119136. private getSimplifier;
  119137. }
  119138. /**
  119139. * The implemented types of simplification
  119140. * At the moment only Quadratic Error Decimation is implemented
  119141. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119142. */
  119143. export enum SimplificationType {
  119144. /** Quadratic error decimation */
  119145. QUADRATIC = 0
  119146. }
  119147. }
  119148. declare module BABYLON {
  119149. interface Scene {
  119150. /** @hidden (Backing field) */
  119151. _simplificationQueue: SimplificationQueue;
  119152. /**
  119153. * Gets or sets the simplification queue attached to the scene
  119154. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119155. */
  119156. simplificationQueue: SimplificationQueue;
  119157. }
  119158. interface Mesh {
  119159. /**
  119160. * Simplify the mesh according to the given array of settings.
  119161. * Function will return immediately and will simplify async
  119162. * @param settings a collection of simplification settings
  119163. * @param parallelProcessing should all levels calculate parallel or one after the other
  119164. * @param simplificationType the type of simplification to run
  119165. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  119166. * @returns the current mesh
  119167. */
  119168. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  119169. }
  119170. /**
  119171. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  119172. * created in a scene
  119173. */
  119174. export class SimplicationQueueSceneComponent implements ISceneComponent {
  119175. /**
  119176. * The component name helpfull to identify the component in the list of scene components.
  119177. */
  119178. readonly name: string;
  119179. /**
  119180. * The scene the component belongs to.
  119181. */
  119182. scene: Scene;
  119183. /**
  119184. * Creates a new instance of the component for the given scene
  119185. * @param scene Defines the scene to register the component in
  119186. */
  119187. constructor(scene: Scene);
  119188. /**
  119189. * Registers the component in a given scene
  119190. */
  119191. register(): void;
  119192. /**
  119193. * Rebuilds the elements related to this component in case of
  119194. * context lost for instance.
  119195. */
  119196. rebuild(): void;
  119197. /**
  119198. * Disposes the component and the associated ressources
  119199. */
  119200. dispose(): void;
  119201. private _beforeCameraUpdate;
  119202. }
  119203. }
  119204. declare module BABYLON {
  119205. /**
  119206. * Navigation plugin interface to add navigation constrained by a navigation mesh
  119207. */
  119208. export interface INavigationEnginePlugin {
  119209. /**
  119210. * plugin name
  119211. */
  119212. name: string;
  119213. /**
  119214. * Creates a navigation mesh
  119215. * @param meshes array of all the geometry used to compute the navigatio mesh
  119216. * @param parameters bunch of parameters used to filter geometry
  119217. */
  119218. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119219. /**
  119220. * Create a navigation mesh debug mesh
  119221. * @param scene is where the mesh will be added
  119222. * @returns debug display mesh
  119223. */
  119224. createDebugNavMesh(scene: Scene): Mesh;
  119225. /**
  119226. * Get a navigation mesh constrained position, closest to the parameter position
  119227. * @param position world position
  119228. * @returns the closest point to position constrained by the navigation mesh
  119229. */
  119230. getClosestPoint(position: Vector3): Vector3;
  119231. /**
  119232. * Get a navigation mesh constrained position, within a particular radius
  119233. * @param position world position
  119234. * @param maxRadius the maximum distance to the constrained world position
  119235. * @returns the closest point to position constrained by the navigation mesh
  119236. */
  119237. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119238. /**
  119239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119240. * @param start world position
  119241. * @param end world position
  119242. * @returns array containing world position composing the path
  119243. */
  119244. computePath(start: Vector3, end: Vector3): Vector3[];
  119245. /**
  119246. * If this plugin is supported
  119247. * @returns true if plugin is supported
  119248. */
  119249. isSupported(): boolean;
  119250. /**
  119251. * Create a new Crowd so you can add agents
  119252. * @param maxAgents the maximum agent count in the crowd
  119253. * @param maxAgentRadius the maximum radius an agent can have
  119254. * @param scene to attach the crowd to
  119255. * @returns the crowd you can add agents to
  119256. */
  119257. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119258. /**
  119259. * Release all resources
  119260. */
  119261. dispose(): void;
  119262. }
  119263. /**
  119264. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  119265. */
  119266. export interface ICrowd {
  119267. /**
  119268. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119269. * You can attach anything to that node. The node position is updated in the scene update tick.
  119270. * @param pos world position that will be constrained by the navigation mesh
  119271. * @param parameters agent parameters
  119272. * @param transform hooked to the agent that will be update by the scene
  119273. * @returns agent index
  119274. */
  119275. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119276. /**
  119277. * Returns the agent position in world space
  119278. * @param index agent index returned by addAgent
  119279. * @returns world space position
  119280. */
  119281. getAgentPosition(index: number): Vector3;
  119282. /**
  119283. * Gets the agent velocity in world space
  119284. * @param index agent index returned by addAgent
  119285. * @returns world space velocity
  119286. */
  119287. getAgentVelocity(index: number): Vector3;
  119288. /**
  119289. * remove a particular agent previously created
  119290. * @param index agent index returned by addAgent
  119291. */
  119292. removeAgent(index: number): void;
  119293. /**
  119294. * get the list of all agents attached to this crowd
  119295. * @returns list of agent indices
  119296. */
  119297. getAgents(): number[];
  119298. /**
  119299. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119300. * @param deltaTime in seconds
  119301. */
  119302. update(deltaTime: number): void;
  119303. /**
  119304. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119305. * @param index agent index returned by addAgent
  119306. * @param destination targeted world position
  119307. */
  119308. agentGoto(index: number, destination: Vector3): void;
  119309. /**
  119310. * Release all resources
  119311. */
  119312. dispose(): void;
  119313. }
  119314. /**
  119315. * Configures an agent
  119316. */
  119317. export interface IAgentParameters {
  119318. /**
  119319. * Agent radius. [Limit: >= 0]
  119320. */
  119321. radius: number;
  119322. /**
  119323. * Agent height. [Limit: > 0]
  119324. */
  119325. height: number;
  119326. /**
  119327. * Maximum allowed acceleration. [Limit: >= 0]
  119328. */
  119329. maxAcceleration: number;
  119330. /**
  119331. * Maximum allowed speed. [Limit: >= 0]
  119332. */
  119333. maxSpeed: number;
  119334. /**
  119335. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  119336. */
  119337. collisionQueryRange: number;
  119338. /**
  119339. * The path visibility optimization range. [Limit: > 0]
  119340. */
  119341. pathOptimizationRange: number;
  119342. /**
  119343. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  119344. */
  119345. separationWeight: number;
  119346. }
  119347. /**
  119348. * Configures the navigation mesh creation
  119349. */
  119350. export interface INavMeshParameters {
  119351. /**
  119352. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  119353. */
  119354. cs: number;
  119355. /**
  119356. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  119357. */
  119358. ch: number;
  119359. /**
  119360. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  119361. */
  119362. walkableSlopeAngle: number;
  119363. /**
  119364. * Minimum floor to 'ceiling' height that will still allow the floor area to
  119365. * be considered walkable. [Limit: >= 3] [Units: vx]
  119366. */
  119367. walkableHeight: number;
  119368. /**
  119369. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  119370. */
  119371. walkableClimb: number;
  119372. /**
  119373. * The distance to erode/shrink the walkable area of the heightfield away from
  119374. * obstructions. [Limit: >=0] [Units: vx]
  119375. */
  119376. walkableRadius: number;
  119377. /**
  119378. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  119379. */
  119380. maxEdgeLen: number;
  119381. /**
  119382. * The maximum distance a simplfied contour's border edges should deviate
  119383. * the original raw contour. [Limit: >=0] [Units: vx]
  119384. */
  119385. maxSimplificationError: number;
  119386. /**
  119387. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  119388. */
  119389. minRegionArea: number;
  119390. /**
  119391. * Any regions with a span count smaller than this value will, if possible,
  119392. * be merged with larger regions. [Limit: >=0] [Units: vx]
  119393. */
  119394. mergeRegionArea: number;
  119395. /**
  119396. * The maximum number of vertices allowed for polygons generated during the
  119397. * contour to polygon conversion process. [Limit: >= 3]
  119398. */
  119399. maxVertsPerPoly: number;
  119400. /**
  119401. * Sets the sampling distance to use when generating the detail mesh.
  119402. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  119403. */
  119404. detailSampleDist: number;
  119405. /**
  119406. * The maximum distance the detail mesh surface should deviate from heightfield
  119407. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  119408. */
  119409. detailSampleMaxError: number;
  119410. }
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * RecastJS navigation plugin
  119415. */
  119416. export class RecastJSPlugin implements INavigationEnginePlugin {
  119417. /**
  119418. * Reference to the Recast library
  119419. */
  119420. bjsRECAST: any;
  119421. /**
  119422. * plugin name
  119423. */
  119424. name: string;
  119425. /**
  119426. * the first navmesh created. We might extend this to support multiple navmeshes
  119427. */
  119428. navMesh: any;
  119429. /**
  119430. * Initializes the recastJS plugin
  119431. * @param recastInjection can be used to inject your own recast reference
  119432. */
  119433. constructor(recastInjection?: any);
  119434. /**
  119435. * Creates a navigation mesh
  119436. * @param meshes array of all the geometry used to compute the navigatio mesh
  119437. * @param parameters bunch of parameters used to filter geometry
  119438. */
  119439. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119440. /**
  119441. * Create a navigation mesh debug mesh
  119442. * @param scene is where the mesh will be added
  119443. * @returns debug display mesh
  119444. */
  119445. createDebugNavMesh(scene: Scene): Mesh;
  119446. /**
  119447. * Get a navigation mesh constrained position, closest to the parameter position
  119448. * @param position world position
  119449. * @returns the closest point to position constrained by the navigation mesh
  119450. */
  119451. getClosestPoint(position: Vector3): Vector3;
  119452. /**
  119453. * Get a navigation mesh constrained position, within a particular radius
  119454. * @param position world position
  119455. * @param maxRadius the maximum distance to the constrained world position
  119456. * @returns the closest point to position constrained by the navigation mesh
  119457. */
  119458. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119459. /**
  119460. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119461. * @param start world position
  119462. * @param end world position
  119463. * @returns array containing world position composing the path
  119464. */
  119465. computePath(start: Vector3, end: Vector3): Vector3[];
  119466. /**
  119467. * Create a new Crowd so you can add agents
  119468. * @param maxAgents the maximum agent count in the crowd
  119469. * @param maxAgentRadius the maximum radius an agent can have
  119470. * @param scene to attach the crowd to
  119471. * @returns the crowd you can add agents to
  119472. */
  119473. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119474. /**
  119475. * Disposes
  119476. */
  119477. dispose(): void;
  119478. /**
  119479. * If this plugin is supported
  119480. * @returns true if plugin is supported
  119481. */
  119482. isSupported(): boolean;
  119483. }
  119484. /**
  119485. * Recast detour crowd implementation
  119486. */
  119487. export class RecastJSCrowd implements ICrowd {
  119488. /**
  119489. * Recast/detour plugin
  119490. */
  119491. bjsRECASTPlugin: RecastJSPlugin;
  119492. /**
  119493. * Link to the detour crowd
  119494. */
  119495. recastCrowd: any;
  119496. /**
  119497. * One transform per agent
  119498. */
  119499. transforms: TransformNode[];
  119500. /**
  119501. * All agents created
  119502. */
  119503. agents: number[];
  119504. /**
  119505. * Link to the scene is kept to unregister the crowd from the scene
  119506. */
  119507. private _scene;
  119508. /**
  119509. * Observer for crowd updates
  119510. */
  119511. private _onBeforeAnimationsObserver;
  119512. /**
  119513. * Constructor
  119514. * @param plugin recastJS plugin
  119515. * @param maxAgents the maximum agent count in the crowd
  119516. * @param maxAgentRadius the maximum radius an agent can have
  119517. * @param scene to attach the crowd to
  119518. * @returns the crowd you can add agents to
  119519. */
  119520. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  119521. /**
  119522. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119523. * You can attach anything to that node. The node position is updated in the scene update tick.
  119524. * @param pos world position that will be constrained by the navigation mesh
  119525. * @param parameters agent parameters
  119526. * @param transform hooked to the agent that will be update by the scene
  119527. * @returns agent index
  119528. */
  119529. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119530. /**
  119531. * Returns the agent position in world space
  119532. * @param index agent index returned by addAgent
  119533. * @returns world space position
  119534. */
  119535. getAgentPosition(index: number): Vector3;
  119536. /**
  119537. * Returns the agent velocity in world space
  119538. * @param index agent index returned by addAgent
  119539. * @returns world space velocity
  119540. */
  119541. getAgentVelocity(index: number): Vector3;
  119542. /**
  119543. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119544. * @param index agent index returned by addAgent
  119545. * @param destination targeted world position
  119546. */
  119547. agentGoto(index: number, destination: Vector3): void;
  119548. /**
  119549. * remove a particular agent previously created
  119550. * @param index agent index returned by addAgent
  119551. */
  119552. removeAgent(index: number): void;
  119553. /**
  119554. * get the list of all agents attached to this crowd
  119555. * @returns list of agent indices
  119556. */
  119557. getAgents(): number[];
  119558. /**
  119559. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119560. * @param deltaTime in seconds
  119561. */
  119562. update(deltaTime: number): void;
  119563. /**
  119564. * Release all resources
  119565. */
  119566. dispose(): void;
  119567. }
  119568. }
  119569. declare module BABYLON {
  119570. /**
  119571. * Class used to enable access to IndexedDB
  119572. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119573. */
  119574. export class Database implements IOfflineProvider {
  119575. private _callbackManifestChecked;
  119576. private _currentSceneUrl;
  119577. private _db;
  119578. private _enableSceneOffline;
  119579. private _enableTexturesOffline;
  119580. private _manifestVersionFound;
  119581. private _mustUpdateRessources;
  119582. private _hasReachedQuota;
  119583. private _isSupported;
  119584. private _idbFactory;
  119585. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119586. private static IsUASupportingBlobStorage;
  119587. /**
  119588. * Gets a boolean indicating if Database storate is enabled (off by default)
  119589. */
  119590. static IDBStorageEnabled: boolean;
  119591. /**
  119592. * Gets a boolean indicating if scene must be saved in the database
  119593. */
  119594. readonly enableSceneOffline: boolean;
  119595. /**
  119596. * Gets a boolean indicating if textures must be saved in the database
  119597. */
  119598. readonly enableTexturesOffline: boolean;
  119599. /**
  119600. * Creates a new Database
  119601. * @param urlToScene defines the url to load the scene
  119602. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119603. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119604. */
  119605. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119606. private static _ParseURL;
  119607. private static _ReturnFullUrlLocation;
  119608. private _checkManifestFile;
  119609. /**
  119610. * Open the database and make it available
  119611. * @param successCallback defines the callback to call on success
  119612. * @param errorCallback defines the callback to call on error
  119613. */
  119614. open(successCallback: () => void, errorCallback: () => void): void;
  119615. /**
  119616. * Loads an image from the database
  119617. * @param url defines the url to load from
  119618. * @param image defines the target DOM image
  119619. */
  119620. loadImage(url: string, image: HTMLImageElement): void;
  119621. private _loadImageFromDBAsync;
  119622. private _saveImageIntoDBAsync;
  119623. private _checkVersionFromDB;
  119624. private _loadVersionFromDBAsync;
  119625. private _saveVersionIntoDBAsync;
  119626. /**
  119627. * Loads a file from database
  119628. * @param url defines the URL to load from
  119629. * @param sceneLoaded defines a callback to call on success
  119630. * @param progressCallBack defines a callback to call when progress changed
  119631. * @param errorCallback defines a callback to call on error
  119632. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119633. */
  119634. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119635. private _loadFileAsync;
  119636. private _saveFileAsync;
  119637. /**
  119638. * Validates if xhr data is correct
  119639. * @param xhr defines the request to validate
  119640. * @param dataType defines the expected data type
  119641. * @returns true if data is correct
  119642. */
  119643. private static _ValidateXHRData;
  119644. }
  119645. }
  119646. declare module BABYLON {
  119647. /** @hidden */
  119648. export var gpuUpdateParticlesPixelShader: {
  119649. name: string;
  119650. shader: string;
  119651. };
  119652. }
  119653. declare module BABYLON {
  119654. /** @hidden */
  119655. export var gpuUpdateParticlesVertexShader: {
  119656. name: string;
  119657. shader: string;
  119658. };
  119659. }
  119660. declare module BABYLON {
  119661. /** @hidden */
  119662. export var clipPlaneFragmentDeclaration2: {
  119663. name: string;
  119664. shader: string;
  119665. };
  119666. }
  119667. declare module BABYLON {
  119668. /** @hidden */
  119669. export var gpuRenderParticlesPixelShader: {
  119670. name: string;
  119671. shader: string;
  119672. };
  119673. }
  119674. declare module BABYLON {
  119675. /** @hidden */
  119676. export var clipPlaneVertexDeclaration2: {
  119677. name: string;
  119678. shader: string;
  119679. };
  119680. }
  119681. declare module BABYLON {
  119682. /** @hidden */
  119683. export var gpuRenderParticlesVertexShader: {
  119684. name: string;
  119685. shader: string;
  119686. };
  119687. }
  119688. declare module BABYLON {
  119689. /**
  119690. * This represents a GPU particle system in Babylon
  119691. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  119692. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  119693. */
  119694. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  119695. /**
  119696. * The layer mask we are rendering the particles through.
  119697. */
  119698. layerMask: number;
  119699. private _capacity;
  119700. private _activeCount;
  119701. private _currentActiveCount;
  119702. private _accumulatedCount;
  119703. private _renderEffect;
  119704. private _updateEffect;
  119705. private _buffer0;
  119706. private _buffer1;
  119707. private _spriteBuffer;
  119708. private _updateVAO;
  119709. private _renderVAO;
  119710. private _targetIndex;
  119711. private _sourceBuffer;
  119712. private _targetBuffer;
  119713. private _engine;
  119714. private _currentRenderId;
  119715. private _started;
  119716. private _stopped;
  119717. private _timeDelta;
  119718. private _randomTexture;
  119719. private _randomTexture2;
  119720. private _attributesStrideSize;
  119721. private _updateEffectOptions;
  119722. private _randomTextureSize;
  119723. private _actualFrame;
  119724. private readonly _rawTextureWidth;
  119725. /**
  119726. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  119727. */
  119728. static readonly IsSupported: boolean;
  119729. /**
  119730. * An event triggered when the system is disposed.
  119731. */
  119732. onDisposeObservable: Observable<GPUParticleSystem>;
  119733. /**
  119734. * Gets the maximum number of particles active at the same time.
  119735. * @returns The max number of active particles.
  119736. */
  119737. getCapacity(): number;
  119738. /**
  119739. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  119740. * to override the particles.
  119741. */
  119742. forceDepthWrite: boolean;
  119743. /**
  119744. * Gets or set the number of active particles
  119745. */
  119746. activeParticleCount: number;
  119747. private _preWarmDone;
  119748. /**
  119749. * Is this system ready to be used/rendered
  119750. * @return true if the system is ready
  119751. */
  119752. isReady(): boolean;
  119753. /**
  119754. * Gets if the system has been started. (Note: this will still be true after stop is called)
  119755. * @returns True if it has been started, otherwise false.
  119756. */
  119757. isStarted(): boolean;
  119758. /**
  119759. * Starts the particle system and begins to emit
  119760. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  119761. */
  119762. start(delay?: number): void;
  119763. /**
  119764. * Stops the particle system.
  119765. */
  119766. stop(): void;
  119767. /**
  119768. * Remove all active particles
  119769. */
  119770. reset(): void;
  119771. /**
  119772. * Returns the string "GPUParticleSystem"
  119773. * @returns a string containing the class name
  119774. */
  119775. getClassName(): string;
  119776. private _colorGradientsTexture;
  119777. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  119778. /**
  119779. * Adds a new color gradient
  119780. * @param gradient defines the gradient to use (between 0 and 1)
  119781. * @param color1 defines the color to affect to the specified gradient
  119782. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  119783. * @returns the current particle system
  119784. */
  119785. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  119786. /**
  119787. * Remove a specific color gradient
  119788. * @param gradient defines the gradient to remove
  119789. * @returns the current particle system
  119790. */
  119791. removeColorGradient(gradient: number): GPUParticleSystem;
  119792. private _angularSpeedGradientsTexture;
  119793. private _sizeGradientsTexture;
  119794. private _velocityGradientsTexture;
  119795. private _limitVelocityGradientsTexture;
  119796. private _dragGradientsTexture;
  119797. private _addFactorGradient;
  119798. /**
  119799. * Adds a new size gradient
  119800. * @param gradient defines the gradient to use (between 0 and 1)
  119801. * @param factor defines the size factor to affect to the specified gradient
  119802. * @returns the current particle system
  119803. */
  119804. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  119805. /**
  119806. * Remove a specific size gradient
  119807. * @param gradient defines the gradient to remove
  119808. * @returns the current particle system
  119809. */
  119810. removeSizeGradient(gradient: number): GPUParticleSystem;
  119811. /**
  119812. * Adds a new angular speed gradient
  119813. * @param gradient defines the gradient to use (between 0 and 1)
  119814. * @param factor defines the angular speed to affect to the specified gradient
  119815. * @returns the current particle system
  119816. */
  119817. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  119818. /**
  119819. * Remove a specific angular speed gradient
  119820. * @param gradient defines the gradient to remove
  119821. * @returns the current particle system
  119822. */
  119823. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  119824. /**
  119825. * Adds a new velocity gradient
  119826. * @param gradient defines the gradient to use (between 0 and 1)
  119827. * @param factor defines the velocity to affect to the specified gradient
  119828. * @returns the current particle system
  119829. */
  119830. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119831. /**
  119832. * Remove a specific velocity gradient
  119833. * @param gradient defines the gradient to remove
  119834. * @returns the current particle system
  119835. */
  119836. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119837. /**
  119838. * Adds a new limit velocity gradient
  119839. * @param gradient defines the gradient to use (between 0 and 1)
  119840. * @param factor defines the limit velocity value to affect to the specified gradient
  119841. * @returns the current particle system
  119842. */
  119843. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119844. /**
  119845. * Remove a specific limit velocity gradient
  119846. * @param gradient defines the gradient to remove
  119847. * @returns the current particle system
  119848. */
  119849. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119850. /**
  119851. * Adds a new drag gradient
  119852. * @param gradient defines the gradient to use (between 0 and 1)
  119853. * @param factor defines the drag value to affect to the specified gradient
  119854. * @returns the current particle system
  119855. */
  119856. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119857. /**
  119858. * Remove a specific drag gradient
  119859. * @param gradient defines the gradient to remove
  119860. * @returns the current particle system
  119861. */
  119862. removeDragGradient(gradient: number): GPUParticleSystem;
  119863. /**
  119864. * Not supported by GPUParticleSystem
  119865. * @param gradient defines the gradient to use (between 0 and 1)
  119866. * @param factor defines the emit rate value to affect to the specified gradient
  119867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119868. * @returns the current particle system
  119869. */
  119870. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119871. /**
  119872. * Not supported by GPUParticleSystem
  119873. * @param gradient defines the gradient to remove
  119874. * @returns the current particle system
  119875. */
  119876. removeEmitRateGradient(gradient: number): IParticleSystem;
  119877. /**
  119878. * Not supported by GPUParticleSystem
  119879. * @param gradient defines the gradient to use (between 0 and 1)
  119880. * @param factor defines the start size value to affect to the specified gradient
  119881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119882. * @returns the current particle system
  119883. */
  119884. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119885. /**
  119886. * Not supported by GPUParticleSystem
  119887. * @param gradient defines the gradient to remove
  119888. * @returns the current particle system
  119889. */
  119890. removeStartSizeGradient(gradient: number): IParticleSystem;
  119891. /**
  119892. * Not supported by GPUParticleSystem
  119893. * @param gradient defines the gradient to use (between 0 and 1)
  119894. * @param min defines the color remap minimal range
  119895. * @param max defines the color remap maximal range
  119896. * @returns the current particle system
  119897. */
  119898. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119899. /**
  119900. * Not supported by GPUParticleSystem
  119901. * @param gradient defines the gradient to remove
  119902. * @returns the current particle system
  119903. */
  119904. removeColorRemapGradient(): IParticleSystem;
  119905. /**
  119906. * Not supported by GPUParticleSystem
  119907. * @param gradient defines the gradient to use (between 0 and 1)
  119908. * @param min defines the alpha remap minimal range
  119909. * @param max defines the alpha remap maximal range
  119910. * @returns the current particle system
  119911. */
  119912. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119913. /**
  119914. * Not supported by GPUParticleSystem
  119915. * @param gradient defines the gradient to remove
  119916. * @returns the current particle system
  119917. */
  119918. removeAlphaRemapGradient(): IParticleSystem;
  119919. /**
  119920. * Not supported by GPUParticleSystem
  119921. * @param gradient defines the gradient to use (between 0 and 1)
  119922. * @param color defines the color to affect to the specified gradient
  119923. * @returns the current particle system
  119924. */
  119925. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119926. /**
  119927. * Not supported by GPUParticleSystem
  119928. * @param gradient defines the gradient to remove
  119929. * @returns the current particle system
  119930. */
  119931. removeRampGradient(): IParticleSystem;
  119932. /**
  119933. * Not supported by GPUParticleSystem
  119934. * @returns the list of ramp gradients
  119935. */
  119936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119937. /**
  119938. * Not supported by GPUParticleSystem
  119939. * Gets or sets a boolean indicating that ramp gradients must be used
  119940. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119941. */
  119942. useRampGradients: boolean;
  119943. /**
  119944. * Not supported by GPUParticleSystem
  119945. * @param gradient defines the gradient to use (between 0 and 1)
  119946. * @param factor defines the life time factor to affect to the specified gradient
  119947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119948. * @returns the current particle system
  119949. */
  119950. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119951. /**
  119952. * Not supported by GPUParticleSystem
  119953. * @param gradient defines the gradient to remove
  119954. * @returns the current particle system
  119955. */
  119956. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119957. /**
  119958. * Instantiates a GPU particle system.
  119959. * 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.
  119960. * @param name The name of the particle system
  119961. * @param options The options used to create the system
  119962. * @param scene The scene the particle system belongs to
  119963. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119964. */
  119965. constructor(name: string, options: Partial<{
  119966. capacity: number;
  119967. randomTextureSize: number;
  119968. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119969. protected _reset(): void;
  119970. private _createUpdateVAO;
  119971. private _createRenderVAO;
  119972. private _initialize;
  119973. /** @hidden */
  119974. _recreateUpdateEffect(): void;
  119975. /** @hidden */
  119976. _recreateRenderEffect(): void;
  119977. /**
  119978. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119979. * @param preWarm defines if we are in the pre-warmimg phase
  119980. */
  119981. animate(preWarm?: boolean): void;
  119982. private _createFactorGradientTexture;
  119983. private _createSizeGradientTexture;
  119984. private _createAngularSpeedGradientTexture;
  119985. private _createVelocityGradientTexture;
  119986. private _createLimitVelocityGradientTexture;
  119987. private _createDragGradientTexture;
  119988. private _createColorGradientTexture;
  119989. /**
  119990. * Renders the particle system in its current state
  119991. * @param preWarm defines if the system should only update the particles but not render them
  119992. * @returns the current number of particles
  119993. */
  119994. render(preWarm?: boolean): number;
  119995. /**
  119996. * Rebuilds the particle system
  119997. */
  119998. rebuild(): void;
  119999. private _releaseBuffers;
  120000. private _releaseVAOs;
  120001. /**
  120002. * Disposes the particle system and free the associated resources
  120003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120004. */
  120005. dispose(disposeTexture?: boolean): void;
  120006. /**
  120007. * Clones the particle system.
  120008. * @param name The name of the cloned object
  120009. * @param newEmitter The new emitter to use
  120010. * @returns the cloned particle system
  120011. */
  120012. clone(name: string, newEmitter: any): GPUParticleSystem;
  120013. /**
  120014. * Serializes the particle system to a JSON object.
  120015. * @returns the JSON object
  120016. */
  120017. serialize(): any;
  120018. /**
  120019. * Parses a JSON object to create a GPU particle system.
  120020. * @param parsedParticleSystem The JSON object to parse
  120021. * @param scene The scene to create the particle system in
  120022. * @param rootUrl The root url to use to load external dependencies like texture
  120023. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120024. * @returns the parsed GPU particle system
  120025. */
  120026. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120027. }
  120028. }
  120029. declare module BABYLON {
  120030. /**
  120031. * Represents a set of particle systems working together to create a specific effect
  120032. */
  120033. export class ParticleSystemSet implements IDisposable {
  120034. private _emitterCreationOptions;
  120035. private _emitterNode;
  120036. /**
  120037. * Gets the particle system list
  120038. */
  120039. systems: IParticleSystem[];
  120040. /**
  120041. * Gets the emitter node used with this set
  120042. */
  120043. readonly emitterNode: Nullable<TransformNode>;
  120044. /**
  120045. * Creates a new emitter mesh as a sphere
  120046. * @param options defines the options used to create the sphere
  120047. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120048. * @param scene defines the hosting scene
  120049. */
  120050. setEmitterAsSphere(options: {
  120051. diameter: number;
  120052. segments: number;
  120053. color: Color3;
  120054. }, renderingGroupId: number, scene: Scene): void;
  120055. /**
  120056. * Starts all particle systems of the set
  120057. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120058. */
  120059. start(emitter?: AbstractMesh): void;
  120060. /**
  120061. * Release all associated resources
  120062. */
  120063. dispose(): void;
  120064. /**
  120065. * Serialize the set into a JSON compatible object
  120066. * @returns a JSON compatible representation of the set
  120067. */
  120068. serialize(): any;
  120069. /**
  120070. * Parse a new ParticleSystemSet from a serialized source
  120071. * @param data defines a JSON compatible representation of the set
  120072. * @param scene defines the hosting scene
  120073. * @param gpu defines if we want GPU particles or CPU particles
  120074. * @returns a new ParticleSystemSet
  120075. */
  120076. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120077. }
  120078. }
  120079. declare module BABYLON {
  120080. /**
  120081. * This class is made for on one-liner static method to help creating particle system set.
  120082. */
  120083. export class ParticleHelper {
  120084. /**
  120085. * Gets or sets base Assets URL
  120086. */
  120087. static BaseAssetsUrl: string;
  120088. /**
  120089. * Create a default particle system that you can tweak
  120090. * @param emitter defines the emitter to use
  120091. * @param capacity defines the system capacity (default is 500 particles)
  120092. * @param scene defines the hosting scene
  120093. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120094. * @returns the new Particle system
  120095. */
  120096. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120097. /**
  120098. * This is the main static method (one-liner) of this helper to create different particle systems
  120099. * @param type This string represents the type to the particle system to create
  120100. * @param scene The scene where the particle system should live
  120101. * @param gpu If the system will use gpu
  120102. * @returns the ParticleSystemSet created
  120103. */
  120104. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120105. /**
  120106. * Static function used to export a particle system to a ParticleSystemSet variable.
  120107. * Please note that the emitter shape is not exported
  120108. * @param systems defines the particle systems to export
  120109. * @returns the created particle system set
  120110. */
  120111. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120112. }
  120113. }
  120114. declare module BABYLON {
  120115. interface Engine {
  120116. /**
  120117. * Create an effect to use with particle systems.
  120118. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120119. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120120. * @param uniformsNames defines a list of attribute names
  120121. * @param samplers defines an array of string used to represent textures
  120122. * @param defines defines the string containing the defines to use to compile the shaders
  120123. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120124. * @param onCompiled defines a function to call when the effect creation is successful
  120125. * @param onError defines a function to call when the effect creation has failed
  120126. * @returns the new Effect
  120127. */
  120128. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120129. }
  120130. interface Mesh {
  120131. /**
  120132. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120133. * @returns an array of IParticleSystem
  120134. */
  120135. getEmittedParticleSystems(): IParticleSystem[];
  120136. /**
  120137. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120138. * @returns an array of IParticleSystem
  120139. */
  120140. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120141. }
  120142. /**
  120143. * @hidden
  120144. */
  120145. export var _IDoNeedToBeInTheBuild: number;
  120146. }
  120147. declare module BABYLON {
  120148. interface Scene {
  120149. /** @hidden (Backing field) */
  120150. _physicsEngine: Nullable<IPhysicsEngine>;
  120151. /**
  120152. * Gets the current physics engine
  120153. * @returns a IPhysicsEngine or null if none attached
  120154. */
  120155. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  120156. /**
  120157. * Enables physics to the current scene
  120158. * @param gravity defines the scene's gravity for the physics engine
  120159. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  120160. * @return a boolean indicating if the physics engine was initialized
  120161. */
  120162. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  120163. /**
  120164. * Disables and disposes the physics engine associated with the scene
  120165. */
  120166. disablePhysicsEngine(): void;
  120167. /**
  120168. * Gets a boolean indicating if there is an active physics engine
  120169. * @returns a boolean indicating if there is an active physics engine
  120170. */
  120171. isPhysicsEnabled(): boolean;
  120172. /**
  120173. * Deletes a physics compound impostor
  120174. * @param compound defines the compound to delete
  120175. */
  120176. deleteCompoundImpostor(compound: any): void;
  120177. /**
  120178. * An event triggered when physic simulation is about to be run
  120179. */
  120180. onBeforePhysicsObservable: Observable<Scene>;
  120181. /**
  120182. * An event triggered when physic simulation has been done
  120183. */
  120184. onAfterPhysicsObservable: Observable<Scene>;
  120185. }
  120186. interface AbstractMesh {
  120187. /** @hidden */
  120188. _physicsImpostor: Nullable<PhysicsImpostor>;
  120189. /**
  120190. * Gets or sets impostor used for physic simulation
  120191. * @see http://doc.babylonjs.com/features/physics_engine
  120192. */
  120193. physicsImpostor: Nullable<PhysicsImpostor>;
  120194. /**
  120195. * Gets the current physics impostor
  120196. * @see http://doc.babylonjs.com/features/physics_engine
  120197. * @returns a physics impostor or null
  120198. */
  120199. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  120200. /** Apply a physic impulse to the mesh
  120201. * @param force defines the force to apply
  120202. * @param contactPoint defines where to apply the force
  120203. * @returns the current mesh
  120204. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120205. */
  120206. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  120207. /**
  120208. * Creates a physic joint between two meshes
  120209. * @param otherMesh defines the other mesh to use
  120210. * @param pivot1 defines the pivot to use on this mesh
  120211. * @param pivot2 defines the pivot to use on the other mesh
  120212. * @param options defines additional options (can be plugin dependent)
  120213. * @returns the current mesh
  120214. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  120215. */
  120216. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  120217. /** @hidden */
  120218. _disposePhysicsObserver: Nullable<Observer<Node>>;
  120219. }
  120220. /**
  120221. * Defines the physics engine scene component responsible to manage a physics engine
  120222. */
  120223. export class PhysicsEngineSceneComponent implements ISceneComponent {
  120224. /**
  120225. * The component name helpful to identify the component in the list of scene components.
  120226. */
  120227. readonly name: string;
  120228. /**
  120229. * The scene the component belongs to.
  120230. */
  120231. scene: Scene;
  120232. /**
  120233. * Creates a new instance of the component for the given scene
  120234. * @param scene Defines the scene to register the component in
  120235. */
  120236. constructor(scene: Scene);
  120237. /**
  120238. * Registers the component in a given scene
  120239. */
  120240. register(): void;
  120241. /**
  120242. * Rebuilds the elements related to this component in case of
  120243. * context lost for instance.
  120244. */
  120245. rebuild(): void;
  120246. /**
  120247. * Disposes the component and the associated ressources
  120248. */
  120249. dispose(): void;
  120250. }
  120251. }
  120252. declare module BABYLON {
  120253. /**
  120254. * A helper for physics simulations
  120255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120256. */
  120257. export class PhysicsHelper {
  120258. private _scene;
  120259. private _physicsEngine;
  120260. /**
  120261. * Initializes the Physics helper
  120262. * @param scene Babylon.js scene
  120263. */
  120264. constructor(scene: Scene);
  120265. /**
  120266. * Applies a radial explosion impulse
  120267. * @param origin the origin of the explosion
  120268. * @param radiusOrEventOptions the radius or the options of radial explosion
  120269. * @param strength the explosion strength
  120270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120271. * @returns A physics radial explosion event, or null
  120272. */
  120273. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120274. /**
  120275. * Applies a radial explosion force
  120276. * @param origin the origin of the explosion
  120277. * @param radiusOrEventOptions the radius or the options of radial explosion
  120278. * @param strength the explosion strength
  120279. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120280. * @returns A physics radial explosion event, or null
  120281. */
  120282. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120283. /**
  120284. * Creates a gravitational field
  120285. * @param origin the origin of the explosion
  120286. * @param radiusOrEventOptions the radius or the options of radial explosion
  120287. * @param strength the explosion strength
  120288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120289. * @returns A physics gravitational field event, or null
  120290. */
  120291. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  120292. /**
  120293. * Creates a physics updraft event
  120294. * @param origin the origin of the updraft
  120295. * @param radiusOrEventOptions the radius or the options of the updraft
  120296. * @param strength the strength of the updraft
  120297. * @param height the height of the updraft
  120298. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  120299. * @returns A physics updraft event, or null
  120300. */
  120301. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  120302. /**
  120303. * Creates a physics vortex event
  120304. * @param origin the of the vortex
  120305. * @param radiusOrEventOptions the radius or the options of the vortex
  120306. * @param strength the strength of the vortex
  120307. * @param height the height of the vortex
  120308. * @returns a Physics vortex event, or null
  120309. * A physics vortex event or null
  120310. */
  120311. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  120312. }
  120313. /**
  120314. * Represents a physics radial explosion event
  120315. */
  120316. class PhysicsRadialExplosionEvent {
  120317. private _scene;
  120318. private _options;
  120319. private _sphere;
  120320. private _dataFetched;
  120321. /**
  120322. * Initializes a radial explosioin event
  120323. * @param _scene BabylonJS scene
  120324. * @param _options The options for the vortex event
  120325. */
  120326. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  120327. /**
  120328. * Returns the data related to the radial explosion event (sphere).
  120329. * @returns The radial explosion event data
  120330. */
  120331. getData(): PhysicsRadialExplosionEventData;
  120332. /**
  120333. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  120334. * @param impostor A physics imposter
  120335. * @param origin the origin of the explosion
  120336. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  120337. */
  120338. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  120339. /**
  120340. * Triggers affecterd impostors callbacks
  120341. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  120342. */
  120343. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  120344. /**
  120345. * Disposes the sphere.
  120346. * @param force Specifies if the sphere should be disposed by force
  120347. */
  120348. dispose(force?: boolean): void;
  120349. /*** Helpers ***/
  120350. private _prepareSphere;
  120351. private _intersectsWithSphere;
  120352. }
  120353. /**
  120354. * Represents a gravitational field event
  120355. */
  120356. class PhysicsGravitationalFieldEvent {
  120357. private _physicsHelper;
  120358. private _scene;
  120359. private _origin;
  120360. private _options;
  120361. private _tickCallback;
  120362. private _sphere;
  120363. private _dataFetched;
  120364. /**
  120365. * Initializes the physics gravitational field event
  120366. * @param _physicsHelper A physics helper
  120367. * @param _scene BabylonJS scene
  120368. * @param _origin The origin position of the gravitational field event
  120369. * @param _options The options for the vortex event
  120370. */
  120371. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  120372. /**
  120373. * Returns the data related to the gravitational field event (sphere).
  120374. * @returns A gravitational field event
  120375. */
  120376. getData(): PhysicsGravitationalFieldEventData;
  120377. /**
  120378. * Enables the gravitational field.
  120379. */
  120380. enable(): void;
  120381. /**
  120382. * Disables the gravitational field.
  120383. */
  120384. disable(): void;
  120385. /**
  120386. * Disposes the sphere.
  120387. * @param force The force to dispose from the gravitational field event
  120388. */
  120389. dispose(force?: boolean): void;
  120390. private _tick;
  120391. }
  120392. /**
  120393. * Represents a physics updraft event
  120394. */
  120395. class PhysicsUpdraftEvent {
  120396. private _scene;
  120397. private _origin;
  120398. private _options;
  120399. private _physicsEngine;
  120400. private _originTop;
  120401. private _originDirection;
  120402. private _tickCallback;
  120403. private _cylinder;
  120404. private _cylinderPosition;
  120405. private _dataFetched;
  120406. /**
  120407. * Initializes the physics updraft event
  120408. * @param _scene BabylonJS scene
  120409. * @param _origin The origin position of the updraft
  120410. * @param _options The options for the updraft event
  120411. */
  120412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  120413. /**
  120414. * Returns the data related to the updraft event (cylinder).
  120415. * @returns A physics updraft event
  120416. */
  120417. getData(): PhysicsUpdraftEventData;
  120418. /**
  120419. * Enables the updraft.
  120420. */
  120421. enable(): void;
  120422. /**
  120423. * Disables the updraft.
  120424. */
  120425. disable(): void;
  120426. /**
  120427. * Disposes the cylinder.
  120428. * @param force Specifies if the updraft should be disposed by force
  120429. */
  120430. dispose(force?: boolean): void;
  120431. private getImpostorHitData;
  120432. private _tick;
  120433. /*** Helpers ***/
  120434. private _prepareCylinder;
  120435. private _intersectsWithCylinder;
  120436. }
  120437. /**
  120438. * Represents a physics vortex event
  120439. */
  120440. class PhysicsVortexEvent {
  120441. private _scene;
  120442. private _origin;
  120443. private _options;
  120444. private _physicsEngine;
  120445. private _originTop;
  120446. private _tickCallback;
  120447. private _cylinder;
  120448. private _cylinderPosition;
  120449. private _dataFetched;
  120450. /**
  120451. * Initializes the physics vortex event
  120452. * @param _scene The BabylonJS scene
  120453. * @param _origin The origin position of the vortex
  120454. * @param _options The options for the vortex event
  120455. */
  120456. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  120457. /**
  120458. * Returns the data related to the vortex event (cylinder).
  120459. * @returns The physics vortex event data
  120460. */
  120461. getData(): PhysicsVortexEventData;
  120462. /**
  120463. * Enables the vortex.
  120464. */
  120465. enable(): void;
  120466. /**
  120467. * Disables the cortex.
  120468. */
  120469. disable(): void;
  120470. /**
  120471. * Disposes the sphere.
  120472. * @param force
  120473. */
  120474. dispose(force?: boolean): void;
  120475. private getImpostorHitData;
  120476. private _tick;
  120477. /*** Helpers ***/
  120478. private _prepareCylinder;
  120479. private _intersectsWithCylinder;
  120480. }
  120481. /**
  120482. * Options fot the radial explosion event
  120483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120484. */
  120485. export class PhysicsRadialExplosionEventOptions {
  120486. /**
  120487. * The radius of the sphere for the radial explosion.
  120488. */
  120489. radius: number;
  120490. /**
  120491. * The strenth of the explosion.
  120492. */
  120493. strength: number;
  120494. /**
  120495. * The strenght of the force in correspondence to the distance of the affected object
  120496. */
  120497. falloff: PhysicsRadialImpulseFalloff;
  120498. /**
  120499. * Sphere options for the radial explosion.
  120500. */
  120501. sphere: {
  120502. segments: number;
  120503. diameter: number;
  120504. };
  120505. /**
  120506. * Sphere options for the radial explosion.
  120507. */
  120508. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  120509. }
  120510. /**
  120511. * Options fot the updraft event
  120512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120513. */
  120514. export class PhysicsUpdraftEventOptions {
  120515. /**
  120516. * The radius of the cylinder for the vortex
  120517. */
  120518. radius: number;
  120519. /**
  120520. * The strenth of the updraft.
  120521. */
  120522. strength: number;
  120523. /**
  120524. * The height of the cylinder for the updraft.
  120525. */
  120526. height: number;
  120527. /**
  120528. * The mode for the the updraft.
  120529. */
  120530. updraftMode: PhysicsUpdraftMode;
  120531. }
  120532. /**
  120533. * Options fot the vortex event
  120534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120535. */
  120536. export class PhysicsVortexEventOptions {
  120537. /**
  120538. * The radius of the cylinder for the vortex
  120539. */
  120540. radius: number;
  120541. /**
  120542. * The strenth of the vortex.
  120543. */
  120544. strength: number;
  120545. /**
  120546. * The height of the cylinder for the vortex.
  120547. */
  120548. height: number;
  120549. /**
  120550. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  120551. */
  120552. centripetalForceThreshold: number;
  120553. /**
  120554. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  120555. */
  120556. centripetalForceMultiplier: number;
  120557. /**
  120558. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  120559. */
  120560. centrifugalForceMultiplier: number;
  120561. /**
  120562. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  120563. */
  120564. updraftForceMultiplier: number;
  120565. }
  120566. /**
  120567. * The strenght of the force in correspondence to the distance of the affected object
  120568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120569. */
  120570. export enum PhysicsRadialImpulseFalloff {
  120571. /** Defines that impulse is constant in strength across it's whole radius */
  120572. Constant = 0,
  120573. /** Defines that impulse gets weaker if it's further from the origin */
  120574. Linear = 1
  120575. }
  120576. /**
  120577. * The strength of the force in correspondence to the distance of the affected object
  120578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120579. */
  120580. export enum PhysicsUpdraftMode {
  120581. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120582. Center = 0,
  120583. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120584. Perpendicular = 1
  120585. }
  120586. /**
  120587. * Interface for a physics hit data
  120588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120589. */
  120590. export interface PhysicsHitData {
  120591. /**
  120592. * The force applied at the contact point
  120593. */
  120594. force: Vector3;
  120595. /**
  120596. * The contact point
  120597. */
  120598. contactPoint: Vector3;
  120599. /**
  120600. * The distance from the origin to the contact point
  120601. */
  120602. distanceFromOrigin: number;
  120603. }
  120604. /**
  120605. * Interface for radial explosion event data
  120606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120607. */
  120608. export interface PhysicsRadialExplosionEventData {
  120609. /**
  120610. * A sphere used for the radial explosion event
  120611. */
  120612. sphere: Mesh;
  120613. }
  120614. /**
  120615. * Interface for gravitational field event data
  120616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120617. */
  120618. export interface PhysicsGravitationalFieldEventData {
  120619. /**
  120620. * A sphere mesh used for the gravitational field event
  120621. */
  120622. sphere: Mesh;
  120623. }
  120624. /**
  120625. * Interface for updraft event data
  120626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120627. */
  120628. export interface PhysicsUpdraftEventData {
  120629. /**
  120630. * A cylinder used for the updraft event
  120631. */
  120632. cylinder: Mesh;
  120633. }
  120634. /**
  120635. * Interface for vortex event data
  120636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120637. */
  120638. export interface PhysicsVortexEventData {
  120639. /**
  120640. * A cylinder used for the vortex event
  120641. */
  120642. cylinder: Mesh;
  120643. }
  120644. /**
  120645. * Interface for an affected physics impostor
  120646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120647. */
  120648. export interface PhysicsAffectedImpostorWithData {
  120649. /**
  120650. * The impostor affected by the effect
  120651. */
  120652. impostor: PhysicsImpostor;
  120653. /**
  120654. * The data about the hit/horce from the explosion
  120655. */
  120656. hitData: PhysicsHitData;
  120657. }
  120658. }
  120659. declare module BABYLON {
  120660. /** @hidden */
  120661. export var blackAndWhitePixelShader: {
  120662. name: string;
  120663. shader: string;
  120664. };
  120665. }
  120666. declare module BABYLON {
  120667. /**
  120668. * Post process used to render in black and white
  120669. */
  120670. export class BlackAndWhitePostProcess extends PostProcess {
  120671. /**
  120672. * Linear about to convert he result to black and white (default: 1)
  120673. */
  120674. degree: number;
  120675. /**
  120676. * Creates a black and white post process
  120677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120678. * @param name The name of the effect.
  120679. * @param options The required width/height ratio to downsize to before computing the render pass.
  120680. * @param camera The camera to apply the render pass to.
  120681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120682. * @param engine The engine which the post process will be applied. (default: current engine)
  120683. * @param reusable If the post process can be reused on the same frame. (default: false)
  120684. */
  120685. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120686. }
  120687. }
  120688. declare module BABYLON {
  120689. /**
  120690. * This represents a set of one or more post processes in Babylon.
  120691. * A post process can be used to apply a shader to a texture after it is rendered.
  120692. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120693. */
  120694. export class PostProcessRenderEffect {
  120695. private _postProcesses;
  120696. private _getPostProcesses;
  120697. private _singleInstance;
  120698. private _cameras;
  120699. private _indicesForCamera;
  120700. /**
  120701. * Name of the effect
  120702. * @hidden
  120703. */
  120704. _name: string;
  120705. /**
  120706. * Instantiates a post process render effect.
  120707. * A post process can be used to apply a shader to a texture after it is rendered.
  120708. * @param engine The engine the effect is tied to
  120709. * @param name The name of the effect
  120710. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120711. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120712. */
  120713. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  120714. /**
  120715. * Checks if all the post processes in the effect are supported.
  120716. */
  120717. readonly isSupported: boolean;
  120718. /**
  120719. * Updates the current state of the effect
  120720. * @hidden
  120721. */
  120722. _update(): void;
  120723. /**
  120724. * Attaches the effect on cameras
  120725. * @param cameras The camera to attach to.
  120726. * @hidden
  120727. */
  120728. _attachCameras(cameras: Camera): void;
  120729. /**
  120730. * Attaches the effect on cameras
  120731. * @param cameras The camera to attach to.
  120732. * @hidden
  120733. */
  120734. _attachCameras(cameras: Camera[]): void;
  120735. /**
  120736. * Detaches the effect on cameras
  120737. * @param cameras The camera to detatch from.
  120738. * @hidden
  120739. */
  120740. _detachCameras(cameras: Camera): void;
  120741. /**
  120742. * Detatches the effect on cameras
  120743. * @param cameras The camera to detatch from.
  120744. * @hidden
  120745. */
  120746. _detachCameras(cameras: Camera[]): void;
  120747. /**
  120748. * Enables the effect on given cameras
  120749. * @param cameras The camera to enable.
  120750. * @hidden
  120751. */
  120752. _enable(cameras: Camera): void;
  120753. /**
  120754. * Enables the effect on given cameras
  120755. * @param cameras The camera to enable.
  120756. * @hidden
  120757. */
  120758. _enable(cameras: Nullable<Camera[]>): void;
  120759. /**
  120760. * Disables the effect on the given cameras
  120761. * @param cameras The camera to disable.
  120762. * @hidden
  120763. */
  120764. _disable(cameras: Camera): void;
  120765. /**
  120766. * Disables the effect on the given cameras
  120767. * @param cameras The camera to disable.
  120768. * @hidden
  120769. */
  120770. _disable(cameras: Nullable<Camera[]>): void;
  120771. /**
  120772. * Gets a list of the post processes contained in the effect.
  120773. * @param camera The camera to get the post processes on.
  120774. * @returns The list of the post processes in the effect.
  120775. */
  120776. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  120777. }
  120778. }
  120779. declare module BABYLON {
  120780. /** @hidden */
  120781. export var extractHighlightsPixelShader: {
  120782. name: string;
  120783. shader: string;
  120784. };
  120785. }
  120786. declare module BABYLON {
  120787. /**
  120788. * 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.
  120789. */
  120790. export class ExtractHighlightsPostProcess extends PostProcess {
  120791. /**
  120792. * The luminance threshold, pixels below this value will be set to black.
  120793. */
  120794. threshold: number;
  120795. /** @hidden */
  120796. _exposure: number;
  120797. /**
  120798. * Post process which has the input texture to be used when performing highlight extraction
  120799. * @hidden
  120800. */
  120801. _inputPostProcess: Nullable<PostProcess>;
  120802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120803. }
  120804. }
  120805. declare module BABYLON {
  120806. /** @hidden */
  120807. export var bloomMergePixelShader: {
  120808. name: string;
  120809. shader: string;
  120810. };
  120811. }
  120812. declare module BABYLON {
  120813. /**
  120814. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120815. */
  120816. export class BloomMergePostProcess extends PostProcess {
  120817. /** Weight of the bloom to be added to the original input. */
  120818. weight: number;
  120819. /**
  120820. * Creates a new instance of @see BloomMergePostProcess
  120821. * @param name The name of the effect.
  120822. * @param originalFromInput Post process which's input will be used for the merge.
  120823. * @param blurred Blurred highlights post process which's output will be used.
  120824. * @param weight Weight of the bloom to be added to the original input.
  120825. * @param options The required width/height ratio to downsize to before computing the render pass.
  120826. * @param camera The camera to apply the render pass to.
  120827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120828. * @param engine The engine which the post process will be applied. (default: current engine)
  120829. * @param reusable If the post process can be reused on the same frame. (default: false)
  120830. * @param textureType Type of textures used when performing the post process. (default: 0)
  120831. * @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)
  120832. */
  120833. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120834. /** Weight of the bloom to be added to the original input. */
  120835. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120841. */
  120842. export class BloomEffect extends PostProcessRenderEffect {
  120843. private bloomScale;
  120844. /**
  120845. * @hidden Internal
  120846. */
  120847. _effects: Array<PostProcess>;
  120848. /**
  120849. * @hidden Internal
  120850. */
  120851. _downscale: ExtractHighlightsPostProcess;
  120852. private _blurX;
  120853. private _blurY;
  120854. private _merge;
  120855. /**
  120856. * The luminance threshold to find bright areas of the image to bloom.
  120857. */
  120858. threshold: number;
  120859. /**
  120860. * The strength of the bloom.
  120861. */
  120862. weight: number;
  120863. /**
  120864. * Specifies the size of the bloom blur kernel, relative to the final output size
  120865. */
  120866. kernel: number;
  120867. /**
  120868. * Creates a new instance of @see BloomEffect
  120869. * @param scene The scene the effect belongs to.
  120870. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120871. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120872. * @param bloomWeight The the strength of bloom.
  120873. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120874. * @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)
  120875. */
  120876. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120877. /**
  120878. * Disposes each of the internal effects for a given camera.
  120879. * @param camera The camera to dispose the effect on.
  120880. */
  120881. disposeEffects(camera: Camera): void;
  120882. /**
  120883. * @hidden Internal
  120884. */
  120885. _updateEffects(): void;
  120886. /**
  120887. * Internal
  120888. * @returns if all the contained post processes are ready.
  120889. * @hidden
  120890. */
  120891. _isReady(): boolean;
  120892. }
  120893. }
  120894. declare module BABYLON {
  120895. /** @hidden */
  120896. export var chromaticAberrationPixelShader: {
  120897. name: string;
  120898. shader: string;
  120899. };
  120900. }
  120901. declare module BABYLON {
  120902. /**
  120903. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120904. */
  120905. export class ChromaticAberrationPostProcess extends PostProcess {
  120906. /**
  120907. * The amount of seperation of rgb channels (default: 30)
  120908. */
  120909. aberrationAmount: number;
  120910. /**
  120911. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120912. */
  120913. radialIntensity: number;
  120914. /**
  120915. * 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))
  120916. */
  120917. direction: Vector2;
  120918. /**
  120919. * 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))
  120920. */
  120921. centerPosition: Vector2;
  120922. /**
  120923. * Creates a new instance ChromaticAberrationPostProcess
  120924. * @param name The name of the effect.
  120925. * @param screenWidth The width of the screen to apply the effect on.
  120926. * @param screenHeight The height of the screen to apply the effect on.
  120927. * @param options The required width/height ratio to downsize to before computing the render pass.
  120928. * @param camera The camera to apply the render pass to.
  120929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120930. * @param engine The engine which the post process will be applied. (default: current engine)
  120931. * @param reusable If the post process can be reused on the same frame. (default: false)
  120932. * @param textureType Type of textures used when performing the post process. (default: 0)
  120933. * @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)
  120934. */
  120935. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120936. }
  120937. }
  120938. declare module BABYLON {
  120939. /** @hidden */
  120940. export var circleOfConfusionPixelShader: {
  120941. name: string;
  120942. shader: string;
  120943. };
  120944. }
  120945. declare module BABYLON {
  120946. /**
  120947. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120948. */
  120949. export class CircleOfConfusionPostProcess extends PostProcess {
  120950. /**
  120951. * 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.
  120952. */
  120953. lensSize: number;
  120954. /**
  120955. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120956. */
  120957. fStop: number;
  120958. /**
  120959. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120960. */
  120961. focusDistance: number;
  120962. /**
  120963. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120964. */
  120965. focalLength: number;
  120966. private _depthTexture;
  120967. /**
  120968. * Creates a new instance CircleOfConfusionPostProcess
  120969. * @param name The name of the effect.
  120970. * @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.
  120971. * @param options The required width/height ratio to downsize to before computing the render pass.
  120972. * @param camera The camera to apply the render pass to.
  120973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120974. * @param engine The engine which the post process will be applied. (default: current engine)
  120975. * @param reusable If the post process can be reused on the same frame. (default: false)
  120976. * @param textureType Type of textures used when performing the post process. (default: 0)
  120977. * @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)
  120978. */
  120979. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120980. /**
  120981. * 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.
  120982. */
  120983. depthTexture: RenderTargetTexture;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /** @hidden */
  120988. export var colorCorrectionPixelShader: {
  120989. name: string;
  120990. shader: string;
  120991. };
  120992. }
  120993. declare module BABYLON {
  120994. /**
  120995. *
  120996. * This post-process allows the modification of rendered colors by using
  120997. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120998. *
  120999. * The object needs to be provided an url to a texture containing the color
  121000. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121001. * Use an image editing software to tweak the LUT to match your needs.
  121002. *
  121003. * For an example of a color LUT, see here:
  121004. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121005. * For explanations on color grading, see here:
  121006. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121007. *
  121008. */
  121009. export class ColorCorrectionPostProcess extends PostProcess {
  121010. private _colorTableTexture;
  121011. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121012. }
  121013. }
  121014. declare module BABYLON {
  121015. /** @hidden */
  121016. export var convolutionPixelShader: {
  121017. name: string;
  121018. shader: string;
  121019. };
  121020. }
  121021. declare module BABYLON {
  121022. /**
  121023. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121024. * input texture to perform effects such as edge detection or sharpening
  121025. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121026. */
  121027. export class ConvolutionPostProcess extends PostProcess {
  121028. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121029. kernel: number[];
  121030. /**
  121031. * Creates a new instance ConvolutionPostProcess
  121032. * @param name The name of the effect.
  121033. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121034. * @param options The required width/height ratio to downsize to before computing the render pass.
  121035. * @param camera The camera to apply the render pass to.
  121036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121037. * @param engine The engine which the post process will be applied. (default: current engine)
  121038. * @param reusable If the post process can be reused on the same frame. (default: false)
  121039. * @param textureType Type of textures used when performing the post process. (default: 0)
  121040. */
  121041. constructor(name: string,
  121042. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121043. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121044. /**
  121045. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121046. */
  121047. static EdgeDetect0Kernel: number[];
  121048. /**
  121049. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121050. */
  121051. static EdgeDetect1Kernel: number[];
  121052. /**
  121053. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121054. */
  121055. static EdgeDetect2Kernel: number[];
  121056. /**
  121057. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121058. */
  121059. static SharpenKernel: number[];
  121060. /**
  121061. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121062. */
  121063. static EmbossKernel: number[];
  121064. /**
  121065. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121066. */
  121067. static GaussianKernel: number[];
  121068. }
  121069. }
  121070. declare module BABYLON {
  121071. /**
  121072. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121073. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121074. * based on samples that have a large difference in distance than the center pixel.
  121075. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121076. */
  121077. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121078. direction: Vector2;
  121079. /**
  121080. * Creates a new instance CircleOfConfusionPostProcess
  121081. * @param name The name of the effect.
  121082. * @param scene The scene the effect belongs to.
  121083. * @param direction The direction the blur should be applied.
  121084. * @param kernel The size of the kernel used to blur.
  121085. * @param options The required width/height ratio to downsize to before computing the render pass.
  121086. * @param camera The camera to apply the render pass to.
  121087. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121088. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121090. * @param engine The engine which the post process will be applied. (default: current engine)
  121091. * @param reusable If the post process can be reused on the same frame. (default: false)
  121092. * @param textureType Type of textures used when performing the post process. (default: 0)
  121093. * @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)
  121094. */
  121095. 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);
  121096. }
  121097. }
  121098. declare module BABYLON {
  121099. /** @hidden */
  121100. export var depthOfFieldMergePixelShader: {
  121101. name: string;
  121102. shader: string;
  121103. };
  121104. }
  121105. declare module BABYLON {
  121106. /**
  121107. * Options to be set when merging outputs from the default pipeline.
  121108. */
  121109. export class DepthOfFieldMergePostProcessOptions {
  121110. /**
  121111. * The original image to merge on top of
  121112. */
  121113. originalFromInput: PostProcess;
  121114. /**
  121115. * Parameters to perform the merge of the depth of field effect
  121116. */
  121117. depthOfField?: {
  121118. circleOfConfusion: PostProcess;
  121119. blurSteps: Array<PostProcess>;
  121120. };
  121121. /**
  121122. * Parameters to perform the merge of bloom effect
  121123. */
  121124. bloom?: {
  121125. blurred: PostProcess;
  121126. weight: number;
  121127. };
  121128. }
  121129. /**
  121130. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121131. */
  121132. export class DepthOfFieldMergePostProcess extends PostProcess {
  121133. private blurSteps;
  121134. /**
  121135. * Creates a new instance of DepthOfFieldMergePostProcess
  121136. * @param name The name of the effect.
  121137. * @param originalFromInput Post process which's input will be used for the merge.
  121138. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121139. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121140. * @param options The required width/height ratio to downsize to before computing the render pass.
  121141. * @param camera The camera to apply the render pass to.
  121142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121143. * @param engine The engine which the post process will be applied. (default: current engine)
  121144. * @param reusable If the post process can be reused on the same frame. (default: false)
  121145. * @param textureType Type of textures used when performing the post process. (default: 0)
  121146. * @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)
  121147. */
  121148. 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);
  121149. /**
  121150. * Updates the effect with the current post process compile time values and recompiles the shader.
  121151. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121152. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121153. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121154. * @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
  121155. * @param onCompiled Called when the shader has been compiled.
  121156. * @param onError Called if there is an error when compiling a shader.
  121157. */
  121158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  121159. }
  121160. }
  121161. declare module BABYLON {
  121162. /**
  121163. * Specifies the level of max blur that should be applied when using the depth of field effect
  121164. */
  121165. export enum DepthOfFieldEffectBlurLevel {
  121166. /**
  121167. * Subtle blur
  121168. */
  121169. Low = 0,
  121170. /**
  121171. * Medium blur
  121172. */
  121173. Medium = 1,
  121174. /**
  121175. * Large blur
  121176. */
  121177. High = 2
  121178. }
  121179. /**
  121180. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121181. */
  121182. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  121183. private _circleOfConfusion;
  121184. /**
  121185. * @hidden Internal, blurs from high to low
  121186. */
  121187. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  121188. private _depthOfFieldBlurY;
  121189. private _dofMerge;
  121190. /**
  121191. * @hidden Internal post processes in depth of field effect
  121192. */
  121193. _effects: Array<PostProcess>;
  121194. /**
  121195. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121196. */
  121197. focalLength: number;
  121198. /**
  121199. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121200. */
  121201. fStop: number;
  121202. /**
  121203. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121204. */
  121205. focusDistance: number;
  121206. /**
  121207. * 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.
  121208. */
  121209. lensSize: number;
  121210. /**
  121211. * Creates a new instance DepthOfFieldEffect
  121212. * @param scene The scene the effect belongs to.
  121213. * @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.
  121214. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121215. * @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)
  121216. */
  121217. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  121218. /**
  121219. * Get the current class name of the current effet
  121220. * @returns "DepthOfFieldEffect"
  121221. */
  121222. getClassName(): string;
  121223. /**
  121224. * 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.
  121225. */
  121226. depthTexture: RenderTargetTexture;
  121227. /**
  121228. * Disposes each of the internal effects for a given camera.
  121229. * @param camera The camera to dispose the effect on.
  121230. */
  121231. disposeEffects(camera: Camera): void;
  121232. /**
  121233. * @hidden Internal
  121234. */
  121235. _updateEffects(): void;
  121236. /**
  121237. * Internal
  121238. * @returns if all the contained post processes are ready.
  121239. * @hidden
  121240. */
  121241. _isReady(): boolean;
  121242. }
  121243. }
  121244. declare module BABYLON {
  121245. /** @hidden */
  121246. export var displayPassPixelShader: {
  121247. name: string;
  121248. shader: string;
  121249. };
  121250. }
  121251. declare module BABYLON {
  121252. /**
  121253. * DisplayPassPostProcess which produces an output the same as it's input
  121254. */
  121255. export class DisplayPassPostProcess extends PostProcess {
  121256. /**
  121257. * Creates the DisplayPassPostProcess
  121258. * @param name The name of the effect.
  121259. * @param options The required width/height ratio to downsize to before computing the render pass.
  121260. * @param camera The camera to apply the render pass to.
  121261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121262. * @param engine The engine which the post process will be applied. (default: current engine)
  121263. * @param reusable If the post process can be reused on the same frame. (default: false)
  121264. */
  121265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121266. }
  121267. }
  121268. declare module BABYLON {
  121269. /** @hidden */
  121270. export var filterPixelShader: {
  121271. name: string;
  121272. shader: string;
  121273. };
  121274. }
  121275. declare module BABYLON {
  121276. /**
  121277. * Applies a kernel filter to the image
  121278. */
  121279. export class FilterPostProcess extends PostProcess {
  121280. /** The matrix to be applied to the image */
  121281. kernelMatrix: Matrix;
  121282. /**
  121283. *
  121284. * @param name The name of the effect.
  121285. * @param kernelMatrix The matrix to be applied to the image
  121286. * @param options The required width/height ratio to downsize to before computing the render pass.
  121287. * @param camera The camera to apply the render pass to.
  121288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121289. * @param engine The engine which the post process will be applied. (default: current engine)
  121290. * @param reusable If the post process can be reused on the same frame. (default: false)
  121291. */
  121292. constructor(name: string,
  121293. /** The matrix to be applied to the image */
  121294. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121295. }
  121296. }
  121297. declare module BABYLON {
  121298. /** @hidden */
  121299. export var fxaaPixelShader: {
  121300. name: string;
  121301. shader: string;
  121302. };
  121303. }
  121304. declare module BABYLON {
  121305. /** @hidden */
  121306. export var fxaaVertexShader: {
  121307. name: string;
  121308. shader: string;
  121309. };
  121310. }
  121311. declare module BABYLON {
  121312. /**
  121313. * Fxaa post process
  121314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121315. */
  121316. export class FxaaPostProcess extends PostProcess {
  121317. /** @hidden */
  121318. texelWidth: number;
  121319. /** @hidden */
  121320. texelHeight: number;
  121321. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121322. private _getDefines;
  121323. }
  121324. }
  121325. declare module BABYLON {
  121326. /** @hidden */
  121327. export var grainPixelShader: {
  121328. name: string;
  121329. shader: string;
  121330. };
  121331. }
  121332. declare module BABYLON {
  121333. /**
  121334. * The GrainPostProcess adds noise to the image at mid luminance levels
  121335. */
  121336. export class GrainPostProcess extends PostProcess {
  121337. /**
  121338. * The intensity of the grain added (default: 30)
  121339. */
  121340. intensity: number;
  121341. /**
  121342. * If the grain should be randomized on every frame
  121343. */
  121344. animated: boolean;
  121345. /**
  121346. * Creates a new instance of @see GrainPostProcess
  121347. * @param name The name of the effect.
  121348. * @param options The required width/height ratio to downsize to before computing the render pass.
  121349. * @param camera The camera to apply the render pass to.
  121350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121351. * @param engine The engine which the post process will be applied. (default: current engine)
  121352. * @param reusable If the post process can be reused on the same frame. (default: false)
  121353. * @param textureType Type of textures used when performing the post process. (default: 0)
  121354. * @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)
  121355. */
  121356. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121357. }
  121358. }
  121359. declare module BABYLON {
  121360. /** @hidden */
  121361. export var highlightsPixelShader: {
  121362. name: string;
  121363. shader: string;
  121364. };
  121365. }
  121366. declare module BABYLON {
  121367. /**
  121368. * Extracts highlights from the image
  121369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121370. */
  121371. export class HighlightsPostProcess extends PostProcess {
  121372. /**
  121373. * Extracts highlights from the image
  121374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121375. * @param name The name of the effect.
  121376. * @param options The required width/height ratio to downsize to before computing the render pass.
  121377. * @param camera The camera to apply the render pass to.
  121378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121379. * @param engine The engine which the post process will be applied. (default: current engine)
  121380. * @param reusable If the post process can be reused on the same frame. (default: false)
  121381. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121382. */
  121383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121384. }
  121385. }
  121386. declare module BABYLON {
  121387. /** @hidden */
  121388. export var mrtFragmentDeclaration: {
  121389. name: string;
  121390. shader: string;
  121391. };
  121392. }
  121393. declare module BABYLON {
  121394. /** @hidden */
  121395. export var geometryPixelShader: {
  121396. name: string;
  121397. shader: string;
  121398. };
  121399. }
  121400. declare module BABYLON {
  121401. /** @hidden */
  121402. export var geometryVertexShader: {
  121403. name: string;
  121404. shader: string;
  121405. };
  121406. }
  121407. declare module BABYLON {
  121408. /** @hidden */
  121409. interface ISavedTransformationMatrix {
  121410. world: Matrix;
  121411. viewProjection: Matrix;
  121412. }
  121413. /**
  121414. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121415. */
  121416. export class GeometryBufferRenderer {
  121417. /**
  121418. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121419. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121420. */
  121421. static readonly POSITION_TEXTURE_TYPE: number;
  121422. /**
  121423. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121424. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121425. */
  121426. static readonly VELOCITY_TEXTURE_TYPE: number;
  121427. /**
  121428. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121429. * in order to compute objects velocities when enableVelocity is set to "true"
  121430. * @hidden
  121431. */
  121432. _previousTransformationMatrices: {
  121433. [index: number]: ISavedTransformationMatrix;
  121434. };
  121435. /**
  121436. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  121437. * in order to compute objects velocities when enableVelocity is set to "true"
  121438. * @hidden
  121439. */
  121440. _previousBonesTransformationMatrices: {
  121441. [index: number]: Float32Array;
  121442. };
  121443. /**
  121444. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  121445. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  121446. */
  121447. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  121448. private _scene;
  121449. private _multiRenderTarget;
  121450. private _ratio;
  121451. private _enablePosition;
  121452. private _enableVelocity;
  121453. private _positionIndex;
  121454. private _velocityIndex;
  121455. protected _effect: Effect;
  121456. protected _cachedDefines: string;
  121457. /**
  121458. * Set the render list (meshes to be rendered) used in the G buffer.
  121459. */
  121460. renderList: Mesh[];
  121461. /**
  121462. * Gets wether or not G buffer are supported by the running hardware.
  121463. * This requires draw buffer supports
  121464. */
  121465. readonly isSupported: boolean;
  121466. /**
  121467. * Returns the index of the given texture type in the G-Buffer textures array
  121468. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121469. * @returns the index of the given texture type in the G-Buffer textures array
  121470. */
  121471. getTextureIndex(textureType: number): number;
  121472. /**
  121473. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121474. */
  121475. /**
  121476. * Sets whether or not objects positions are enabled for the G buffer.
  121477. */
  121478. enablePosition: boolean;
  121479. /**
  121480. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121481. */
  121482. /**
  121483. * Sets wether or not objects velocities are enabled for the G buffer.
  121484. */
  121485. enableVelocity: boolean;
  121486. /**
  121487. * Gets the scene associated with the buffer.
  121488. */
  121489. readonly scene: Scene;
  121490. /**
  121491. * Gets the ratio used by the buffer during its creation.
  121492. * How big is the buffer related to the main canvas.
  121493. */
  121494. readonly ratio: number;
  121495. /** @hidden */
  121496. static _SceneComponentInitialization: (scene: Scene) => void;
  121497. /**
  121498. * Creates a new G Buffer for the scene
  121499. * @param scene The scene the buffer belongs to
  121500. * @param ratio How big is the buffer related to the main canvas.
  121501. */
  121502. constructor(scene: Scene, ratio?: number);
  121503. /**
  121504. * Checks wether everything is ready to render a submesh to the G buffer.
  121505. * @param subMesh the submesh to check readiness for
  121506. * @param useInstances is the mesh drawn using instance or not
  121507. * @returns true if ready otherwise false
  121508. */
  121509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121510. /**
  121511. * Gets the current underlying G Buffer.
  121512. * @returns the buffer
  121513. */
  121514. getGBuffer(): MultiRenderTarget;
  121515. /**
  121516. * Gets the number of samples used to render the buffer (anti aliasing).
  121517. */
  121518. /**
  121519. * Sets the number of samples used to render the buffer (anti aliasing).
  121520. */
  121521. samples: number;
  121522. /**
  121523. * Disposes the renderer and frees up associated resources.
  121524. */
  121525. dispose(): void;
  121526. protected _createRenderTargets(): void;
  121527. private _copyBonesTransformationMatrices;
  121528. }
  121529. }
  121530. declare module BABYLON {
  121531. interface Scene {
  121532. /** @hidden (Backing field) */
  121533. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121534. /**
  121535. * Gets or Sets the current geometry buffer associated to the scene.
  121536. */
  121537. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121538. /**
  121539. * Enables a GeometryBufferRender and associates it with the scene
  121540. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  121541. * @returns the GeometryBufferRenderer
  121542. */
  121543. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  121544. /**
  121545. * Disables the GeometryBufferRender associated with the scene
  121546. */
  121547. disableGeometryBufferRenderer(): void;
  121548. }
  121549. /**
  121550. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121551. * in several rendering techniques.
  121552. */
  121553. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  121554. /**
  121555. * The component name helpful to identify the component in the list of scene components.
  121556. */
  121557. readonly name: string;
  121558. /**
  121559. * The scene the component belongs to.
  121560. */
  121561. scene: Scene;
  121562. /**
  121563. * Creates a new instance of the component for the given scene
  121564. * @param scene Defines the scene to register the component in
  121565. */
  121566. constructor(scene: Scene);
  121567. /**
  121568. * Registers the component in a given scene
  121569. */
  121570. register(): void;
  121571. /**
  121572. * Rebuilds the elements related to this component in case of
  121573. * context lost for instance.
  121574. */
  121575. rebuild(): void;
  121576. /**
  121577. * Disposes the component and the associated ressources
  121578. */
  121579. dispose(): void;
  121580. private _gatherRenderTargets;
  121581. }
  121582. }
  121583. declare module BABYLON {
  121584. /** @hidden */
  121585. export var motionBlurPixelShader: {
  121586. name: string;
  121587. shader: string;
  121588. };
  121589. }
  121590. declare module BABYLON {
  121591. /**
  121592. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121593. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121594. * As an example, all you have to do is to create the post-process:
  121595. * var mb = new BABYLON.MotionBlurPostProcess(
  121596. * 'mb', // The name of the effect.
  121597. * scene, // The scene containing the objects to blur according to their velocity.
  121598. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121599. * camera // The camera to apply the render pass to.
  121600. * );
  121601. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121602. */
  121603. export class MotionBlurPostProcess extends PostProcess {
  121604. /**
  121605. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121606. */
  121607. motionStrength: number;
  121608. /**
  121609. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121610. */
  121611. /**
  121612. * Sets the number of iterations to be used for motion blur quality
  121613. */
  121614. motionBlurSamples: number;
  121615. private _motionBlurSamples;
  121616. private _geometryBufferRenderer;
  121617. /**
  121618. * Creates a new instance MotionBlurPostProcess
  121619. * @param name The name of the effect.
  121620. * @param scene The scene containing the objects to blur according to their velocity.
  121621. * @param options The required width/height ratio to downsize to before computing the render pass.
  121622. * @param camera The camera to apply the render pass to.
  121623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121624. * @param engine The engine which the post process will be applied. (default: current engine)
  121625. * @param reusable If the post process can be reused on the same frame. (default: false)
  121626. * @param textureType Type of textures used when performing the post process. (default: 0)
  121627. * @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)
  121628. */
  121629. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121630. /**
  121631. * Excludes the given skinned mesh from computing bones velocities.
  121632. * 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.
  121633. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121634. */
  121635. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121636. /**
  121637. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121638. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121639. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121640. */
  121641. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121642. /**
  121643. * Disposes the post process.
  121644. * @param camera The camera to dispose the post process on.
  121645. */
  121646. dispose(camera?: Camera): void;
  121647. }
  121648. }
  121649. declare module BABYLON {
  121650. /** @hidden */
  121651. export var refractionPixelShader: {
  121652. name: string;
  121653. shader: string;
  121654. };
  121655. }
  121656. declare module BABYLON {
  121657. /**
  121658. * Post process which applies a refractin texture
  121659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121660. */
  121661. export class RefractionPostProcess extends PostProcess {
  121662. /** the base color of the refraction (used to taint the rendering) */
  121663. color: Color3;
  121664. /** simulated refraction depth */
  121665. depth: number;
  121666. /** the coefficient of the base color (0 to remove base color tainting) */
  121667. colorLevel: number;
  121668. private _refTexture;
  121669. private _ownRefractionTexture;
  121670. /**
  121671. * Gets or sets the refraction texture
  121672. * Please note that you are responsible for disposing the texture if you set it manually
  121673. */
  121674. refractionTexture: Texture;
  121675. /**
  121676. * Initializes the RefractionPostProcess
  121677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121678. * @param name The name of the effect.
  121679. * @param refractionTextureUrl Url of the refraction texture to use
  121680. * @param color the base color of the refraction (used to taint the rendering)
  121681. * @param depth simulated refraction depth
  121682. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121683. * @param camera The camera to apply the render pass to.
  121684. * @param options The required width/height ratio to downsize to before computing the render pass.
  121685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121686. * @param engine The engine which the post process will be applied. (default: current engine)
  121687. * @param reusable If the post process can be reused on the same frame. (default: false)
  121688. */
  121689. constructor(name: string, refractionTextureUrl: string,
  121690. /** the base color of the refraction (used to taint the rendering) */
  121691. color: Color3,
  121692. /** simulated refraction depth */
  121693. depth: number,
  121694. /** the coefficient of the base color (0 to remove base color tainting) */
  121695. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121696. /**
  121697. * Disposes of the post process
  121698. * @param camera Camera to dispose post process on
  121699. */
  121700. dispose(camera: Camera): void;
  121701. }
  121702. }
  121703. declare module BABYLON {
  121704. /** @hidden */
  121705. export var sharpenPixelShader: {
  121706. name: string;
  121707. shader: string;
  121708. };
  121709. }
  121710. declare module BABYLON {
  121711. /**
  121712. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121713. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121714. */
  121715. export class SharpenPostProcess extends PostProcess {
  121716. /**
  121717. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121718. */
  121719. colorAmount: number;
  121720. /**
  121721. * How much sharpness should be applied (default: 0.3)
  121722. */
  121723. edgeAmount: number;
  121724. /**
  121725. * Creates a new instance ConvolutionPostProcess
  121726. * @param name The name of the effect.
  121727. * @param options The required width/height ratio to downsize to before computing the render pass.
  121728. * @param camera The camera to apply the render pass to.
  121729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121730. * @param engine The engine which the post process will be applied. (default: current engine)
  121731. * @param reusable If the post process can be reused on the same frame. (default: false)
  121732. * @param textureType Type of textures used when performing the post process. (default: 0)
  121733. * @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)
  121734. */
  121735. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121736. }
  121737. }
  121738. declare module BABYLON {
  121739. /**
  121740. * PostProcessRenderPipeline
  121741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121742. */
  121743. export class PostProcessRenderPipeline {
  121744. private engine;
  121745. private _renderEffects;
  121746. private _renderEffectsForIsolatedPass;
  121747. /**
  121748. * List of inspectable custom properties (used by the Inspector)
  121749. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121750. */
  121751. inspectableCustomProperties: IInspectable[];
  121752. /**
  121753. * @hidden
  121754. */
  121755. protected _cameras: Camera[];
  121756. /** @hidden */
  121757. _name: string;
  121758. /**
  121759. * Gets pipeline name
  121760. */
  121761. readonly name: string;
  121762. /**
  121763. * Initializes a PostProcessRenderPipeline
  121764. * @param engine engine to add the pipeline to
  121765. * @param name name of the pipeline
  121766. */
  121767. constructor(engine: Engine, name: string);
  121768. /**
  121769. * Gets the class name
  121770. * @returns "PostProcessRenderPipeline"
  121771. */
  121772. getClassName(): string;
  121773. /**
  121774. * If all the render effects in the pipeline are supported
  121775. */
  121776. readonly isSupported: boolean;
  121777. /**
  121778. * Adds an effect to the pipeline
  121779. * @param renderEffect the effect to add
  121780. */
  121781. addEffect(renderEffect: PostProcessRenderEffect): void;
  121782. /** @hidden */
  121783. _rebuild(): void;
  121784. /** @hidden */
  121785. _enableEffect(renderEffectName: string, cameras: Camera): void;
  121786. /** @hidden */
  121787. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  121788. /** @hidden */
  121789. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121790. /** @hidden */
  121791. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121792. /** @hidden */
  121793. _attachCameras(cameras: Camera, unique: boolean): void;
  121794. /** @hidden */
  121795. _attachCameras(cameras: Camera[], unique: boolean): void;
  121796. /** @hidden */
  121797. _detachCameras(cameras: Camera): void;
  121798. /** @hidden */
  121799. _detachCameras(cameras: Nullable<Camera[]>): void;
  121800. /** @hidden */
  121801. _update(): void;
  121802. /** @hidden */
  121803. _reset(): void;
  121804. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  121805. /**
  121806. * Disposes of the pipeline
  121807. */
  121808. dispose(): void;
  121809. }
  121810. }
  121811. declare module BABYLON {
  121812. /**
  121813. * PostProcessRenderPipelineManager class
  121814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121815. */
  121816. export class PostProcessRenderPipelineManager {
  121817. private _renderPipelines;
  121818. /**
  121819. * Initializes a PostProcessRenderPipelineManager
  121820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121821. */
  121822. constructor();
  121823. /**
  121824. * Gets the list of supported render pipelines
  121825. */
  121826. readonly supportedPipelines: PostProcessRenderPipeline[];
  121827. /**
  121828. * Adds a pipeline to the manager
  121829. * @param renderPipeline The pipeline to add
  121830. */
  121831. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  121832. /**
  121833. * Attaches a camera to the pipeline
  121834. * @param renderPipelineName The name of the pipeline to attach to
  121835. * @param cameras the camera to attach
  121836. * @param unique if the camera can be attached multiple times to the pipeline
  121837. */
  121838. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121839. /**
  121840. * Detaches a camera from the pipeline
  121841. * @param renderPipelineName The name of the pipeline to detach from
  121842. * @param cameras the camera to detach
  121843. */
  121844. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121845. /**
  121846. * Enables an effect by name on a pipeline
  121847. * @param renderPipelineName the name of the pipeline to enable the effect in
  121848. * @param renderEffectName the name of the effect to enable
  121849. * @param cameras the cameras that the effect should be enabled on
  121850. */
  121851. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121852. /**
  121853. * Disables an effect by name on a pipeline
  121854. * @param renderPipelineName the name of the pipeline to disable the effect in
  121855. * @param renderEffectName the name of the effect to disable
  121856. * @param cameras the cameras that the effect should be disabled on
  121857. */
  121858. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121859. /**
  121860. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121861. */
  121862. update(): void;
  121863. /** @hidden */
  121864. _rebuild(): void;
  121865. /**
  121866. * Disposes of the manager and pipelines
  121867. */
  121868. dispose(): void;
  121869. }
  121870. }
  121871. declare module BABYLON {
  121872. interface Scene {
  121873. /** @hidden (Backing field) */
  121874. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121875. /**
  121876. * Gets the postprocess render pipeline manager
  121877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121878. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121879. */
  121880. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121881. }
  121882. /**
  121883. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121884. */
  121885. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121886. /**
  121887. * The component name helpfull to identify the component in the list of scene components.
  121888. */
  121889. readonly name: string;
  121890. /**
  121891. * The scene the component belongs to.
  121892. */
  121893. scene: Scene;
  121894. /**
  121895. * Creates a new instance of the component for the given scene
  121896. * @param scene Defines the scene to register the component in
  121897. */
  121898. constructor(scene: Scene);
  121899. /**
  121900. * Registers the component in a given scene
  121901. */
  121902. register(): void;
  121903. /**
  121904. * Rebuilds the elements related to this component in case of
  121905. * context lost for instance.
  121906. */
  121907. rebuild(): void;
  121908. /**
  121909. * Disposes the component and the associated ressources
  121910. */
  121911. dispose(): void;
  121912. private _gatherRenderTargets;
  121913. }
  121914. }
  121915. declare module BABYLON {
  121916. /**
  121917. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121918. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121919. */
  121920. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121921. private _scene;
  121922. private _camerasToBeAttached;
  121923. /**
  121924. * ID of the sharpen post process,
  121925. */
  121926. private readonly SharpenPostProcessId;
  121927. /**
  121928. * @ignore
  121929. * ID of the image processing post process;
  121930. */
  121931. readonly ImageProcessingPostProcessId: string;
  121932. /**
  121933. * @ignore
  121934. * ID of the Fast Approximate Anti-Aliasing post process;
  121935. */
  121936. readonly FxaaPostProcessId: string;
  121937. /**
  121938. * ID of the chromatic aberration post process,
  121939. */
  121940. private readonly ChromaticAberrationPostProcessId;
  121941. /**
  121942. * ID of the grain post process
  121943. */
  121944. private readonly GrainPostProcessId;
  121945. /**
  121946. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121947. */
  121948. sharpen: SharpenPostProcess;
  121949. private _sharpenEffect;
  121950. private bloom;
  121951. /**
  121952. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121953. */
  121954. depthOfField: DepthOfFieldEffect;
  121955. /**
  121956. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121957. */
  121958. fxaa: FxaaPostProcess;
  121959. /**
  121960. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121961. */
  121962. imageProcessing: ImageProcessingPostProcess;
  121963. /**
  121964. * Chromatic aberration post process which will shift rgb colors in the image
  121965. */
  121966. chromaticAberration: ChromaticAberrationPostProcess;
  121967. private _chromaticAberrationEffect;
  121968. /**
  121969. * Grain post process which add noise to the image
  121970. */
  121971. grain: GrainPostProcess;
  121972. private _grainEffect;
  121973. /**
  121974. * Glow post process which adds a glow to emissive areas of the image
  121975. */
  121976. private _glowLayer;
  121977. /**
  121978. * Animations which can be used to tweak settings over a period of time
  121979. */
  121980. animations: Animation[];
  121981. private _imageProcessingConfigurationObserver;
  121982. private _sharpenEnabled;
  121983. private _bloomEnabled;
  121984. private _depthOfFieldEnabled;
  121985. private _depthOfFieldBlurLevel;
  121986. private _fxaaEnabled;
  121987. private _imageProcessingEnabled;
  121988. private _defaultPipelineTextureType;
  121989. private _bloomScale;
  121990. private _chromaticAberrationEnabled;
  121991. private _grainEnabled;
  121992. private _buildAllowed;
  121993. /**
  121994. * Gets active scene
  121995. */
  121996. readonly scene: Scene;
  121997. /**
  121998. * Enable or disable the sharpen process from the pipeline
  121999. */
  122000. sharpenEnabled: boolean;
  122001. private _resizeObserver;
  122002. private _hardwareScaleLevel;
  122003. private _bloomKernel;
  122004. /**
  122005. * Specifies the size of the bloom blur kernel, relative to the final output size
  122006. */
  122007. bloomKernel: number;
  122008. /**
  122009. * Specifies the weight of the bloom in the final rendering
  122010. */
  122011. private _bloomWeight;
  122012. /**
  122013. * Specifies the luma threshold for the area that will be blurred by the bloom
  122014. */
  122015. private _bloomThreshold;
  122016. private _hdr;
  122017. /**
  122018. * The strength of the bloom.
  122019. */
  122020. bloomWeight: number;
  122021. /**
  122022. * The strength of the bloom.
  122023. */
  122024. bloomThreshold: number;
  122025. /**
  122026. * The scale of the bloom, lower value will provide better performance.
  122027. */
  122028. bloomScale: number;
  122029. /**
  122030. * Enable or disable the bloom from the pipeline
  122031. */
  122032. bloomEnabled: boolean;
  122033. private _rebuildBloom;
  122034. /**
  122035. * If the depth of field is enabled.
  122036. */
  122037. depthOfFieldEnabled: boolean;
  122038. /**
  122039. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122040. */
  122041. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122042. /**
  122043. * If the anti aliasing is enabled.
  122044. */
  122045. fxaaEnabled: boolean;
  122046. private _samples;
  122047. /**
  122048. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122049. */
  122050. samples: number;
  122051. /**
  122052. * If image processing is enabled.
  122053. */
  122054. imageProcessingEnabled: boolean;
  122055. /**
  122056. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122057. */
  122058. glowLayerEnabled: boolean;
  122059. /**
  122060. * Gets the glow layer (or null if not defined)
  122061. */
  122062. readonly glowLayer: Nullable<GlowLayer>;
  122063. /**
  122064. * Enable or disable the chromaticAberration process from the pipeline
  122065. */
  122066. chromaticAberrationEnabled: boolean;
  122067. /**
  122068. * Enable or disable the grain process from the pipeline
  122069. */
  122070. grainEnabled: boolean;
  122071. /**
  122072. * @constructor
  122073. * @param name - The rendering pipeline name (default: "")
  122074. * @param hdr - If high dynamic range textures should be used (default: true)
  122075. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122076. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122077. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122078. */
  122079. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122080. /**
  122081. * Get the class name
  122082. * @returns "DefaultRenderingPipeline"
  122083. */
  122084. getClassName(): string;
  122085. /**
  122086. * Force the compilation of the entire pipeline.
  122087. */
  122088. prepare(): void;
  122089. private _hasCleared;
  122090. private _prevPostProcess;
  122091. private _prevPrevPostProcess;
  122092. private _setAutoClearAndTextureSharing;
  122093. private _depthOfFieldSceneObserver;
  122094. private _buildPipeline;
  122095. private _disposePostProcesses;
  122096. /**
  122097. * Adds a camera to the pipeline
  122098. * @param camera the camera to be added
  122099. */
  122100. addCamera(camera: Camera): void;
  122101. /**
  122102. * Removes a camera from the pipeline
  122103. * @param camera the camera to remove
  122104. */
  122105. removeCamera(camera: Camera): void;
  122106. /**
  122107. * Dispose of the pipeline and stop all post processes
  122108. */
  122109. dispose(): void;
  122110. /**
  122111. * Serialize the rendering pipeline (Used when exporting)
  122112. * @returns the serialized object
  122113. */
  122114. serialize(): any;
  122115. /**
  122116. * Parse the serialized pipeline
  122117. * @param source Source pipeline.
  122118. * @param scene The scene to load the pipeline to.
  122119. * @param rootUrl The URL of the serialized pipeline.
  122120. * @returns An instantiated pipeline from the serialized object.
  122121. */
  122122. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122123. }
  122124. }
  122125. declare module BABYLON {
  122126. /** @hidden */
  122127. export var lensHighlightsPixelShader: {
  122128. name: string;
  122129. shader: string;
  122130. };
  122131. }
  122132. declare module BABYLON {
  122133. /** @hidden */
  122134. export var depthOfFieldPixelShader: {
  122135. name: string;
  122136. shader: string;
  122137. };
  122138. }
  122139. declare module BABYLON {
  122140. /**
  122141. * BABYLON.JS Chromatic Aberration GLSL Shader
  122142. * Author: Olivier Guyot
  122143. * Separates very slightly R, G and B colors on the edges of the screen
  122144. * Inspired by Francois Tarlier & Martins Upitis
  122145. */
  122146. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  122147. /**
  122148. * @ignore
  122149. * The chromatic aberration PostProcess id in the pipeline
  122150. */
  122151. LensChromaticAberrationEffect: string;
  122152. /**
  122153. * @ignore
  122154. * The highlights enhancing PostProcess id in the pipeline
  122155. */
  122156. HighlightsEnhancingEffect: string;
  122157. /**
  122158. * @ignore
  122159. * The depth-of-field PostProcess id in the pipeline
  122160. */
  122161. LensDepthOfFieldEffect: string;
  122162. private _scene;
  122163. private _depthTexture;
  122164. private _grainTexture;
  122165. private _chromaticAberrationPostProcess;
  122166. private _highlightsPostProcess;
  122167. private _depthOfFieldPostProcess;
  122168. private _edgeBlur;
  122169. private _grainAmount;
  122170. private _chromaticAberration;
  122171. private _distortion;
  122172. private _highlightsGain;
  122173. private _highlightsThreshold;
  122174. private _dofDistance;
  122175. private _dofAperture;
  122176. private _dofDarken;
  122177. private _dofPentagon;
  122178. private _blurNoise;
  122179. /**
  122180. * @constructor
  122181. *
  122182. * Effect parameters are as follow:
  122183. * {
  122184. * chromatic_aberration: number; // from 0 to x (1 for realism)
  122185. * edge_blur: number; // from 0 to x (1 for realism)
  122186. * distortion: number; // from 0 to x (1 for realism)
  122187. * grain_amount: number; // from 0 to 1
  122188. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  122189. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  122190. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  122191. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  122192. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  122193. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  122194. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  122195. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  122196. * }
  122197. * Note: if an effect parameter is unset, effect is disabled
  122198. *
  122199. * @param name The rendering pipeline name
  122200. * @param parameters - An object containing all parameters (see above)
  122201. * @param scene The scene linked to this pipeline
  122202. * @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)
  122203. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122204. */
  122205. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  122206. /**
  122207. * Get the class name
  122208. * @returns "LensRenderingPipeline"
  122209. */
  122210. getClassName(): string;
  122211. /**
  122212. * Gets associated scene
  122213. */
  122214. readonly scene: Scene;
  122215. /**
  122216. * Gets or sets the edge blur
  122217. */
  122218. edgeBlur: number;
  122219. /**
  122220. * Gets or sets the grain amount
  122221. */
  122222. grainAmount: number;
  122223. /**
  122224. * Gets or sets the chromatic aberration amount
  122225. */
  122226. chromaticAberration: number;
  122227. /**
  122228. * Gets or sets the depth of field aperture
  122229. */
  122230. dofAperture: number;
  122231. /**
  122232. * Gets or sets the edge distortion
  122233. */
  122234. edgeDistortion: number;
  122235. /**
  122236. * Gets or sets the depth of field distortion
  122237. */
  122238. dofDistortion: number;
  122239. /**
  122240. * Gets or sets the darken out of focus amount
  122241. */
  122242. darkenOutOfFocus: number;
  122243. /**
  122244. * Gets or sets a boolean indicating if blur noise is enabled
  122245. */
  122246. blurNoise: boolean;
  122247. /**
  122248. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  122249. */
  122250. pentagonBokeh: boolean;
  122251. /**
  122252. * Gets or sets the highlight grain amount
  122253. */
  122254. highlightsGain: number;
  122255. /**
  122256. * Gets or sets the highlight threshold
  122257. */
  122258. highlightsThreshold: number;
  122259. /**
  122260. * Sets the amount of blur at the edges
  122261. * @param amount blur amount
  122262. */
  122263. setEdgeBlur(amount: number): void;
  122264. /**
  122265. * Sets edge blur to 0
  122266. */
  122267. disableEdgeBlur(): void;
  122268. /**
  122269. * Sets the amout of grain
  122270. * @param amount Amount of grain
  122271. */
  122272. setGrainAmount(amount: number): void;
  122273. /**
  122274. * Set grain amount to 0
  122275. */
  122276. disableGrain(): void;
  122277. /**
  122278. * Sets the chromatic aberration amount
  122279. * @param amount amount of chromatic aberration
  122280. */
  122281. setChromaticAberration(amount: number): void;
  122282. /**
  122283. * Sets chromatic aberration amount to 0
  122284. */
  122285. disableChromaticAberration(): void;
  122286. /**
  122287. * Sets the EdgeDistortion amount
  122288. * @param amount amount of EdgeDistortion
  122289. */
  122290. setEdgeDistortion(amount: number): void;
  122291. /**
  122292. * Sets edge distortion to 0
  122293. */
  122294. disableEdgeDistortion(): void;
  122295. /**
  122296. * Sets the FocusDistance amount
  122297. * @param amount amount of FocusDistance
  122298. */
  122299. setFocusDistance(amount: number): void;
  122300. /**
  122301. * Disables depth of field
  122302. */
  122303. disableDepthOfField(): void;
  122304. /**
  122305. * Sets the Aperture amount
  122306. * @param amount amount of Aperture
  122307. */
  122308. setAperture(amount: number): void;
  122309. /**
  122310. * Sets the DarkenOutOfFocus amount
  122311. * @param amount amount of DarkenOutOfFocus
  122312. */
  122313. setDarkenOutOfFocus(amount: number): void;
  122314. private _pentagonBokehIsEnabled;
  122315. /**
  122316. * Creates a pentagon bokeh effect
  122317. */
  122318. enablePentagonBokeh(): void;
  122319. /**
  122320. * Disables the pentagon bokeh effect
  122321. */
  122322. disablePentagonBokeh(): void;
  122323. /**
  122324. * Enables noise blur
  122325. */
  122326. enableNoiseBlur(): void;
  122327. /**
  122328. * Disables noise blur
  122329. */
  122330. disableNoiseBlur(): void;
  122331. /**
  122332. * Sets the HighlightsGain amount
  122333. * @param amount amount of HighlightsGain
  122334. */
  122335. setHighlightsGain(amount: number): void;
  122336. /**
  122337. * Sets the HighlightsThreshold amount
  122338. * @param amount amount of HighlightsThreshold
  122339. */
  122340. setHighlightsThreshold(amount: number): void;
  122341. /**
  122342. * Disables highlights
  122343. */
  122344. disableHighlights(): void;
  122345. /**
  122346. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122347. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122348. */
  122349. dispose(disableDepthRender?: boolean): void;
  122350. private _createChromaticAberrationPostProcess;
  122351. private _createHighlightsPostProcess;
  122352. private _createDepthOfFieldPostProcess;
  122353. private _createGrainTexture;
  122354. }
  122355. }
  122356. declare module BABYLON {
  122357. /** @hidden */
  122358. export var ssao2PixelShader: {
  122359. name: string;
  122360. shader: string;
  122361. };
  122362. }
  122363. declare module BABYLON {
  122364. /** @hidden */
  122365. export var ssaoCombinePixelShader: {
  122366. name: string;
  122367. shader: string;
  122368. };
  122369. }
  122370. declare module BABYLON {
  122371. /**
  122372. * Render pipeline to produce ssao effect
  122373. */
  122374. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  122375. /**
  122376. * @ignore
  122377. * The PassPostProcess id in the pipeline that contains the original scene color
  122378. */
  122379. SSAOOriginalSceneColorEffect: string;
  122380. /**
  122381. * @ignore
  122382. * The SSAO PostProcess id in the pipeline
  122383. */
  122384. SSAORenderEffect: string;
  122385. /**
  122386. * @ignore
  122387. * The horizontal blur PostProcess id in the pipeline
  122388. */
  122389. SSAOBlurHRenderEffect: string;
  122390. /**
  122391. * @ignore
  122392. * The vertical blur PostProcess id in the pipeline
  122393. */
  122394. SSAOBlurVRenderEffect: string;
  122395. /**
  122396. * @ignore
  122397. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122398. */
  122399. SSAOCombineRenderEffect: string;
  122400. /**
  122401. * The output strength of the SSAO post-process. Default value is 1.0.
  122402. */
  122403. totalStrength: number;
  122404. /**
  122405. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  122406. */
  122407. maxZ: number;
  122408. /**
  122409. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  122410. */
  122411. minZAspect: number;
  122412. private _samples;
  122413. /**
  122414. * Number of samples used for the SSAO calculations. Default value is 8
  122415. */
  122416. samples: number;
  122417. private _textureSamples;
  122418. /**
  122419. * Number of samples to use for antialiasing
  122420. */
  122421. textureSamples: number;
  122422. /**
  122423. * Ratio object used for SSAO ratio and blur ratio
  122424. */
  122425. private _ratio;
  122426. /**
  122427. * Dynamically generated sphere sampler.
  122428. */
  122429. private _sampleSphere;
  122430. /**
  122431. * Blur filter offsets
  122432. */
  122433. private _samplerOffsets;
  122434. private _expensiveBlur;
  122435. /**
  122436. * If bilateral blur should be used
  122437. */
  122438. expensiveBlur: boolean;
  122439. /**
  122440. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  122441. */
  122442. radius: number;
  122443. /**
  122444. * The base color of the SSAO post-process
  122445. * The final result is "base + ssao" between [0, 1]
  122446. */
  122447. base: number;
  122448. /**
  122449. * Support test.
  122450. */
  122451. static readonly IsSupported: boolean;
  122452. private _scene;
  122453. private _depthTexture;
  122454. private _normalTexture;
  122455. private _randomTexture;
  122456. private _originalColorPostProcess;
  122457. private _ssaoPostProcess;
  122458. private _blurHPostProcess;
  122459. private _blurVPostProcess;
  122460. private _ssaoCombinePostProcess;
  122461. private _firstUpdate;
  122462. /**
  122463. * Gets active scene
  122464. */
  122465. readonly scene: Scene;
  122466. /**
  122467. * @constructor
  122468. * @param name The rendering pipeline name
  122469. * @param scene The scene linked to this pipeline
  122470. * @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 }
  122471. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122472. */
  122473. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122474. /**
  122475. * Get the class name
  122476. * @returns "SSAO2RenderingPipeline"
  122477. */
  122478. getClassName(): string;
  122479. /**
  122480. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122481. */
  122482. dispose(disableGeometryBufferRenderer?: boolean): void;
  122483. private _createBlurPostProcess;
  122484. /** @hidden */
  122485. _rebuild(): void;
  122486. private _bits;
  122487. private _radicalInverse_VdC;
  122488. private _hammersley;
  122489. private _hemisphereSample_uniform;
  122490. private _generateHemisphere;
  122491. private _createSSAOPostProcess;
  122492. private _createSSAOCombinePostProcess;
  122493. private _createRandomTexture;
  122494. /**
  122495. * Serialize the rendering pipeline (Used when exporting)
  122496. * @returns the serialized object
  122497. */
  122498. serialize(): any;
  122499. /**
  122500. * Parse the serialized pipeline
  122501. * @param source Source pipeline.
  122502. * @param scene The scene to load the pipeline to.
  122503. * @param rootUrl The URL of the serialized pipeline.
  122504. * @returns An instantiated pipeline from the serialized object.
  122505. */
  122506. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  122507. }
  122508. }
  122509. declare module BABYLON {
  122510. /** @hidden */
  122511. export var ssaoPixelShader: {
  122512. name: string;
  122513. shader: string;
  122514. };
  122515. }
  122516. declare module BABYLON {
  122517. /**
  122518. * Render pipeline to produce ssao effect
  122519. */
  122520. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  122521. /**
  122522. * @ignore
  122523. * The PassPostProcess id in the pipeline that contains the original scene color
  122524. */
  122525. SSAOOriginalSceneColorEffect: string;
  122526. /**
  122527. * @ignore
  122528. * The SSAO PostProcess id in the pipeline
  122529. */
  122530. SSAORenderEffect: string;
  122531. /**
  122532. * @ignore
  122533. * The horizontal blur PostProcess id in the pipeline
  122534. */
  122535. SSAOBlurHRenderEffect: string;
  122536. /**
  122537. * @ignore
  122538. * The vertical blur PostProcess id in the pipeline
  122539. */
  122540. SSAOBlurVRenderEffect: string;
  122541. /**
  122542. * @ignore
  122543. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122544. */
  122545. SSAOCombineRenderEffect: string;
  122546. /**
  122547. * The output strength of the SSAO post-process. Default value is 1.0.
  122548. */
  122549. totalStrength: number;
  122550. /**
  122551. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122552. */
  122553. radius: number;
  122554. /**
  122555. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122556. * Must not be equal to fallOff and superior to fallOff.
  122557. * Default value is 0.0075
  122558. */
  122559. area: number;
  122560. /**
  122561. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122562. * Must not be equal to area and inferior to area.
  122563. * Default value is 0.000001
  122564. */
  122565. fallOff: number;
  122566. /**
  122567. * The base color of the SSAO post-process
  122568. * The final result is "base + ssao" between [0, 1]
  122569. */
  122570. base: number;
  122571. private _scene;
  122572. private _depthTexture;
  122573. private _randomTexture;
  122574. private _originalColorPostProcess;
  122575. private _ssaoPostProcess;
  122576. private _blurHPostProcess;
  122577. private _blurVPostProcess;
  122578. private _ssaoCombinePostProcess;
  122579. private _firstUpdate;
  122580. /**
  122581. * Gets active scene
  122582. */
  122583. readonly scene: Scene;
  122584. /**
  122585. * @constructor
  122586. * @param name - The rendering pipeline name
  122587. * @param scene - The scene linked to this pipeline
  122588. * @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 }
  122589. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122590. */
  122591. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122592. /**
  122593. * Get the class name
  122594. * @returns "SSAORenderingPipeline"
  122595. */
  122596. getClassName(): string;
  122597. /**
  122598. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122599. */
  122600. dispose(disableDepthRender?: boolean): void;
  122601. private _createBlurPostProcess;
  122602. /** @hidden */
  122603. _rebuild(): void;
  122604. private _createSSAOPostProcess;
  122605. private _createSSAOCombinePostProcess;
  122606. private _createRandomTexture;
  122607. }
  122608. }
  122609. declare module BABYLON {
  122610. /** @hidden */
  122611. export var standardPixelShader: {
  122612. name: string;
  122613. shader: string;
  122614. };
  122615. }
  122616. declare module BABYLON {
  122617. /**
  122618. * Standard rendering pipeline
  122619. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122620. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122621. */
  122622. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122623. /**
  122624. * Public members
  122625. */
  122626. /**
  122627. * Post-process which contains the original scene color before the pipeline applies all the effects
  122628. */
  122629. originalPostProcess: Nullable<PostProcess>;
  122630. /**
  122631. * Post-process used to down scale an image x4
  122632. */
  122633. downSampleX4PostProcess: Nullable<PostProcess>;
  122634. /**
  122635. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122636. */
  122637. brightPassPostProcess: Nullable<PostProcess>;
  122638. /**
  122639. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122640. */
  122641. blurHPostProcesses: PostProcess[];
  122642. /**
  122643. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122644. */
  122645. blurVPostProcesses: PostProcess[];
  122646. /**
  122647. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122648. */
  122649. textureAdderPostProcess: Nullable<PostProcess>;
  122650. /**
  122651. * Post-process used to create volumetric lighting effect
  122652. */
  122653. volumetricLightPostProcess: Nullable<PostProcess>;
  122654. /**
  122655. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122656. */
  122657. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122658. /**
  122659. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122660. */
  122661. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  122662. /**
  122663. * Post-process used to merge the volumetric light effect and the real scene color
  122664. */
  122665. volumetricLightMergePostProces: Nullable<PostProcess>;
  122666. /**
  122667. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122668. */
  122669. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  122670. /**
  122671. * Base post-process used to calculate the average luminance of the final image for HDR
  122672. */
  122673. luminancePostProcess: Nullable<PostProcess>;
  122674. /**
  122675. * Post-processes used to create down sample post-processes in order to get
  122676. * the average luminance of the final image for HDR
  122677. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122678. */
  122679. luminanceDownSamplePostProcesses: PostProcess[];
  122680. /**
  122681. * Post-process used to create a HDR effect (light adaptation)
  122682. */
  122683. hdrPostProcess: Nullable<PostProcess>;
  122684. /**
  122685. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122686. */
  122687. textureAdderFinalPostProcess: Nullable<PostProcess>;
  122688. /**
  122689. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122690. */
  122691. lensFlareFinalPostProcess: Nullable<PostProcess>;
  122692. /**
  122693. * Post-process used to merge the final HDR post-process and the real scene color
  122694. */
  122695. hdrFinalPostProcess: Nullable<PostProcess>;
  122696. /**
  122697. * Post-process used to create a lens flare effect
  122698. */
  122699. lensFlarePostProcess: Nullable<PostProcess>;
  122700. /**
  122701. * Post-process that merges the result of the lens flare post-process and the real scene color
  122702. */
  122703. lensFlareComposePostProcess: Nullable<PostProcess>;
  122704. /**
  122705. * Post-process used to create a motion blur effect
  122706. */
  122707. motionBlurPostProcess: Nullable<PostProcess>;
  122708. /**
  122709. * Post-process used to create a depth of field effect
  122710. */
  122711. depthOfFieldPostProcess: Nullable<PostProcess>;
  122712. /**
  122713. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122714. */
  122715. fxaaPostProcess: Nullable<FxaaPostProcess>;
  122716. /**
  122717. * Represents the brightness threshold in order to configure the illuminated surfaces
  122718. */
  122719. brightThreshold: number;
  122720. /**
  122721. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122722. */
  122723. blurWidth: number;
  122724. /**
  122725. * Sets if the blur for highlighted surfaces must be only horizontal
  122726. */
  122727. horizontalBlur: boolean;
  122728. /**
  122729. * Gets the overall exposure used by the pipeline
  122730. */
  122731. /**
  122732. * Sets the overall exposure used by the pipeline
  122733. */
  122734. exposure: number;
  122735. /**
  122736. * Texture used typically to simulate "dirty" on camera lens
  122737. */
  122738. lensTexture: Nullable<Texture>;
  122739. /**
  122740. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122741. */
  122742. volumetricLightCoefficient: number;
  122743. /**
  122744. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122745. */
  122746. volumetricLightPower: number;
  122747. /**
  122748. * Used the set the blur intensity to smooth the volumetric lights
  122749. */
  122750. volumetricLightBlurScale: number;
  122751. /**
  122752. * Light (spot or directional) used to generate the volumetric lights rays
  122753. * The source light must have a shadow generate so the pipeline can get its
  122754. * depth map
  122755. */
  122756. sourceLight: Nullable<SpotLight | DirectionalLight>;
  122757. /**
  122758. * For eye adaptation, represents the minimum luminance the eye can see
  122759. */
  122760. hdrMinimumLuminance: number;
  122761. /**
  122762. * For eye adaptation, represents the decrease luminance speed
  122763. */
  122764. hdrDecreaseRate: number;
  122765. /**
  122766. * For eye adaptation, represents the increase luminance speed
  122767. */
  122768. hdrIncreaseRate: number;
  122769. /**
  122770. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122771. */
  122772. /**
  122773. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122774. */
  122775. hdrAutoExposure: boolean;
  122776. /**
  122777. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  122778. */
  122779. lensColorTexture: Nullable<Texture>;
  122780. /**
  122781. * The overall strengh for the lens flare effect
  122782. */
  122783. lensFlareStrength: number;
  122784. /**
  122785. * Dispersion coefficient for lens flare ghosts
  122786. */
  122787. lensFlareGhostDispersal: number;
  122788. /**
  122789. * Main lens flare halo width
  122790. */
  122791. lensFlareHaloWidth: number;
  122792. /**
  122793. * Based on the lens distortion effect, defines how much the lens flare result
  122794. * is distorted
  122795. */
  122796. lensFlareDistortionStrength: number;
  122797. /**
  122798. * Lens star texture must be used to simulate rays on the flares and is available
  122799. * in the documentation
  122800. */
  122801. lensStarTexture: Nullable<Texture>;
  122802. /**
  122803. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  122804. * flare effect by taking account of the dirt texture
  122805. */
  122806. lensFlareDirtTexture: Nullable<Texture>;
  122807. /**
  122808. * Represents the focal length for the depth of field effect
  122809. */
  122810. depthOfFieldDistance: number;
  122811. /**
  122812. * Represents the blur intensity for the blurred part of the depth of field effect
  122813. */
  122814. depthOfFieldBlurWidth: number;
  122815. /**
  122816. * Gets how much the image is blurred by the movement while using the motion blur post-process
  122817. */
  122818. /**
  122819. * Sets how much the image is blurred by the movement while using the motion blur post-process
  122820. */
  122821. motionStrength: number;
  122822. /**
  122823. * Gets wether or not the motion blur post-process is object based or screen based.
  122824. */
  122825. /**
  122826. * Sets wether or not the motion blur post-process should be object based or screen based
  122827. */
  122828. objectBasedMotionBlur: boolean;
  122829. /**
  122830. * List of animations for the pipeline (IAnimatable implementation)
  122831. */
  122832. animations: Animation[];
  122833. /**
  122834. * Private members
  122835. */
  122836. private _scene;
  122837. private _currentDepthOfFieldSource;
  122838. private _basePostProcess;
  122839. private _fixedExposure;
  122840. private _currentExposure;
  122841. private _hdrAutoExposure;
  122842. private _hdrCurrentLuminance;
  122843. private _motionStrength;
  122844. private _isObjectBasedMotionBlur;
  122845. private _floatTextureType;
  122846. private _ratio;
  122847. private _bloomEnabled;
  122848. private _depthOfFieldEnabled;
  122849. private _vlsEnabled;
  122850. private _lensFlareEnabled;
  122851. private _hdrEnabled;
  122852. private _motionBlurEnabled;
  122853. private _fxaaEnabled;
  122854. private _motionBlurSamples;
  122855. private _volumetricLightStepsCount;
  122856. private _samples;
  122857. /**
  122858. * @ignore
  122859. * Specifies if the bloom pipeline is enabled
  122860. */
  122861. BloomEnabled: boolean;
  122862. /**
  122863. * @ignore
  122864. * Specifies if the depth of field pipeline is enabed
  122865. */
  122866. DepthOfFieldEnabled: boolean;
  122867. /**
  122868. * @ignore
  122869. * Specifies if the lens flare pipeline is enabed
  122870. */
  122871. LensFlareEnabled: boolean;
  122872. /**
  122873. * @ignore
  122874. * Specifies if the HDR pipeline is enabled
  122875. */
  122876. HDREnabled: boolean;
  122877. /**
  122878. * @ignore
  122879. * Specifies if the volumetric lights scattering effect is enabled
  122880. */
  122881. VLSEnabled: boolean;
  122882. /**
  122883. * @ignore
  122884. * Specifies if the motion blur effect is enabled
  122885. */
  122886. MotionBlurEnabled: boolean;
  122887. /**
  122888. * Specifies if anti-aliasing is enabled
  122889. */
  122890. fxaaEnabled: boolean;
  122891. /**
  122892. * Specifies the number of steps used to calculate the volumetric lights
  122893. * Typically in interval [50, 200]
  122894. */
  122895. volumetricLightStepsCount: number;
  122896. /**
  122897. * Specifies the number of samples used for the motion blur effect
  122898. * Typically in interval [16, 64]
  122899. */
  122900. motionBlurSamples: number;
  122901. /**
  122902. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122903. */
  122904. samples: number;
  122905. /**
  122906. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122907. * @constructor
  122908. * @param name The rendering pipeline name
  122909. * @param scene The scene linked to this pipeline
  122910. * @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)
  122911. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122912. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122913. */
  122914. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122915. private _buildPipeline;
  122916. private _createDownSampleX4PostProcess;
  122917. private _createBrightPassPostProcess;
  122918. private _createBlurPostProcesses;
  122919. private _createTextureAdderPostProcess;
  122920. private _createVolumetricLightPostProcess;
  122921. private _createLuminancePostProcesses;
  122922. private _createHdrPostProcess;
  122923. private _createLensFlarePostProcess;
  122924. private _createDepthOfFieldPostProcess;
  122925. private _createMotionBlurPostProcess;
  122926. private _getDepthTexture;
  122927. private _disposePostProcesses;
  122928. /**
  122929. * Dispose of the pipeline and stop all post processes
  122930. */
  122931. dispose(): void;
  122932. /**
  122933. * Serialize the rendering pipeline (Used when exporting)
  122934. * @returns the serialized object
  122935. */
  122936. serialize(): any;
  122937. /**
  122938. * Parse the serialized pipeline
  122939. * @param source Source pipeline.
  122940. * @param scene The scene to load the pipeline to.
  122941. * @param rootUrl The URL of the serialized pipeline.
  122942. * @returns An instantiated pipeline from the serialized object.
  122943. */
  122944. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122945. /**
  122946. * Luminance steps
  122947. */
  122948. static LuminanceSteps: number;
  122949. }
  122950. }
  122951. declare module BABYLON {
  122952. /** @hidden */
  122953. export var tonemapPixelShader: {
  122954. name: string;
  122955. shader: string;
  122956. };
  122957. }
  122958. declare module BABYLON {
  122959. /** Defines operator used for tonemapping */
  122960. export enum TonemappingOperator {
  122961. /** Hable */
  122962. Hable = 0,
  122963. /** Reinhard */
  122964. Reinhard = 1,
  122965. /** HejiDawson */
  122966. HejiDawson = 2,
  122967. /** Photographic */
  122968. Photographic = 3
  122969. }
  122970. /**
  122971. * Defines a post process to apply tone mapping
  122972. */
  122973. export class TonemapPostProcess extends PostProcess {
  122974. private _operator;
  122975. /** Defines the required exposure adjustement */
  122976. exposureAdjustment: number;
  122977. /**
  122978. * Creates a new TonemapPostProcess
  122979. * @param name defines the name of the postprocess
  122980. * @param _operator defines the operator to use
  122981. * @param exposureAdjustment defines the required exposure adjustement
  122982. * @param camera defines the camera to use (can be null)
  122983. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122984. * @param engine defines the hosting engine (can be ignore if camera is set)
  122985. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122986. */
  122987. constructor(name: string, _operator: TonemappingOperator,
  122988. /** Defines the required exposure adjustement */
  122989. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122990. }
  122991. }
  122992. declare module BABYLON {
  122993. /** @hidden */
  122994. export var depthVertexShader: {
  122995. name: string;
  122996. shader: string;
  122997. };
  122998. }
  122999. declare module BABYLON {
  123000. /** @hidden */
  123001. export var volumetricLightScatteringPixelShader: {
  123002. name: string;
  123003. shader: string;
  123004. };
  123005. }
  123006. declare module BABYLON {
  123007. /** @hidden */
  123008. export var volumetricLightScatteringPassVertexShader: {
  123009. name: string;
  123010. shader: string;
  123011. };
  123012. }
  123013. declare module BABYLON {
  123014. /** @hidden */
  123015. export var volumetricLightScatteringPassPixelShader: {
  123016. name: string;
  123017. shader: string;
  123018. };
  123019. }
  123020. declare module BABYLON {
  123021. /**
  123022. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123023. */
  123024. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123025. private _volumetricLightScatteringPass;
  123026. private _volumetricLightScatteringRTT;
  123027. private _viewPort;
  123028. private _screenCoordinates;
  123029. private _cachedDefines;
  123030. /**
  123031. * If not undefined, the mesh position is computed from the attached node position
  123032. */
  123033. attachedNode: {
  123034. position: Vector3;
  123035. };
  123036. /**
  123037. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123038. */
  123039. customMeshPosition: Vector3;
  123040. /**
  123041. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123042. */
  123043. useCustomMeshPosition: boolean;
  123044. /**
  123045. * If the post-process should inverse the light scattering direction
  123046. */
  123047. invert: boolean;
  123048. /**
  123049. * The internal mesh used by the post-process
  123050. */
  123051. mesh: Mesh;
  123052. /**
  123053. * @hidden
  123054. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123055. */
  123056. useDiffuseColor: boolean;
  123057. /**
  123058. * Array containing the excluded meshes not rendered in the internal pass
  123059. */
  123060. excludedMeshes: AbstractMesh[];
  123061. /**
  123062. * Controls the overall intensity of the post-process
  123063. */
  123064. exposure: number;
  123065. /**
  123066. * Dissipates each sample's contribution in range [0, 1]
  123067. */
  123068. decay: number;
  123069. /**
  123070. * Controls the overall intensity of each sample
  123071. */
  123072. weight: number;
  123073. /**
  123074. * Controls the density of each sample
  123075. */
  123076. density: number;
  123077. /**
  123078. * @constructor
  123079. * @param name The post-process name
  123080. * @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)
  123081. * @param camera The camera that the post-process will be attached to
  123082. * @param mesh The mesh used to create the light scattering
  123083. * @param samples The post-process quality, default 100
  123084. * @param samplingModeThe post-process filtering mode
  123085. * @param engine The babylon engine
  123086. * @param reusable If the post-process is reusable
  123087. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123088. */
  123089. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123090. /**
  123091. * Returns the string "VolumetricLightScatteringPostProcess"
  123092. * @returns "VolumetricLightScatteringPostProcess"
  123093. */
  123094. getClassName(): string;
  123095. private _isReady;
  123096. /**
  123097. * Sets the new light position for light scattering effect
  123098. * @param position The new custom light position
  123099. */
  123100. setCustomMeshPosition(position: Vector3): void;
  123101. /**
  123102. * Returns the light position for light scattering effect
  123103. * @return Vector3 The custom light position
  123104. */
  123105. getCustomMeshPosition(): Vector3;
  123106. /**
  123107. * Disposes the internal assets and detaches the post-process from the camera
  123108. */
  123109. dispose(camera: Camera): void;
  123110. /**
  123111. * Returns the render target texture used by the post-process
  123112. * @return the render target texture used by the post-process
  123113. */
  123114. getPass(): RenderTargetTexture;
  123115. private _meshExcluded;
  123116. private _createPass;
  123117. private _updateMeshScreenCoordinates;
  123118. /**
  123119. * Creates a default mesh for the Volumeric Light Scattering post-process
  123120. * @param name The mesh name
  123121. * @param scene The scene where to create the mesh
  123122. * @return the default mesh
  123123. */
  123124. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. interface Scene {
  123129. /** @hidden (Backing field) */
  123130. _boundingBoxRenderer: BoundingBoxRenderer;
  123131. /** @hidden (Backing field) */
  123132. _forceShowBoundingBoxes: boolean;
  123133. /**
  123134. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123135. */
  123136. forceShowBoundingBoxes: boolean;
  123137. /**
  123138. * Gets the bounding box renderer associated with the scene
  123139. * @returns a BoundingBoxRenderer
  123140. */
  123141. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123142. }
  123143. interface AbstractMesh {
  123144. /** @hidden (Backing field) */
  123145. _showBoundingBox: boolean;
  123146. /**
  123147. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  123148. */
  123149. showBoundingBox: boolean;
  123150. }
  123151. /**
  123152. * Component responsible of rendering the bounding box of the meshes in a scene.
  123153. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  123154. */
  123155. export class BoundingBoxRenderer implements ISceneComponent {
  123156. /**
  123157. * The component name helpfull to identify the component in the list of scene components.
  123158. */
  123159. readonly name: string;
  123160. /**
  123161. * The scene the component belongs to.
  123162. */
  123163. scene: Scene;
  123164. /**
  123165. * Color of the bounding box lines placed in front of an object
  123166. */
  123167. frontColor: Color3;
  123168. /**
  123169. * Color of the bounding box lines placed behind an object
  123170. */
  123171. backColor: Color3;
  123172. /**
  123173. * Defines if the renderer should show the back lines or not
  123174. */
  123175. showBackLines: boolean;
  123176. /**
  123177. * @hidden
  123178. */
  123179. renderList: SmartArray<BoundingBox>;
  123180. private _colorShader;
  123181. private _vertexBuffers;
  123182. private _indexBuffer;
  123183. private _fillIndexBuffer;
  123184. private _fillIndexData;
  123185. /**
  123186. * Instantiates a new bounding box renderer in a scene.
  123187. * @param scene the scene the renderer renders in
  123188. */
  123189. constructor(scene: Scene);
  123190. /**
  123191. * Registers the component in a given scene
  123192. */
  123193. register(): void;
  123194. private _evaluateSubMesh;
  123195. private _activeMesh;
  123196. private _prepareRessources;
  123197. private _createIndexBuffer;
  123198. /**
  123199. * Rebuilds the elements related to this component in case of
  123200. * context lost for instance.
  123201. */
  123202. rebuild(): void;
  123203. /**
  123204. * @hidden
  123205. */
  123206. reset(): void;
  123207. /**
  123208. * Render the bounding boxes of a specific rendering group
  123209. * @param renderingGroupId defines the rendering group to render
  123210. */
  123211. render(renderingGroupId: number): void;
  123212. /**
  123213. * In case of occlusion queries, we can render the occlusion bounding box through this method
  123214. * @param mesh Define the mesh to render the occlusion bounding box for
  123215. */
  123216. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  123217. /**
  123218. * Dispose and release the resources attached to this renderer.
  123219. */
  123220. dispose(): void;
  123221. }
  123222. }
  123223. declare module BABYLON {
  123224. /** @hidden */
  123225. export var depthPixelShader: {
  123226. name: string;
  123227. shader: string;
  123228. };
  123229. }
  123230. declare module BABYLON {
  123231. /**
  123232. * This represents a depth renderer in Babylon.
  123233. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  123234. */
  123235. export class DepthRenderer {
  123236. private _scene;
  123237. private _depthMap;
  123238. private _effect;
  123239. private readonly _storeNonLinearDepth;
  123240. private readonly _clearColor;
  123241. /** Get if the depth renderer is using packed depth or not */
  123242. readonly isPacked: boolean;
  123243. private _cachedDefines;
  123244. private _camera;
  123245. /**
  123246. * Specifiess that the depth renderer will only be used within
  123247. * the camera it is created for.
  123248. * This can help forcing its rendering during the camera processing.
  123249. */
  123250. useOnlyInActiveCamera: boolean;
  123251. /** @hidden */
  123252. static _SceneComponentInitialization: (scene: Scene) => void;
  123253. /**
  123254. * Instantiates a depth renderer
  123255. * @param scene The scene the renderer belongs to
  123256. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  123257. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  123258. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123259. */
  123260. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  123261. /**
  123262. * Creates the depth rendering effect and checks if the effect is ready.
  123263. * @param subMesh The submesh to be used to render the depth map of
  123264. * @param useInstances If multiple world instances should be used
  123265. * @returns if the depth renderer is ready to render the depth map
  123266. */
  123267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123268. /**
  123269. * Gets the texture which the depth map will be written to.
  123270. * @returns The depth map texture
  123271. */
  123272. getDepthMap(): RenderTargetTexture;
  123273. /**
  123274. * Disposes of the depth renderer.
  123275. */
  123276. dispose(): void;
  123277. }
  123278. }
  123279. declare module BABYLON {
  123280. interface Scene {
  123281. /** @hidden (Backing field) */
  123282. _depthRenderer: {
  123283. [id: string]: DepthRenderer;
  123284. };
  123285. /**
  123286. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  123287. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  123288. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123289. * @returns the created depth renderer
  123290. */
  123291. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  123292. /**
  123293. * Disables a depth renderer for a given camera
  123294. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  123295. */
  123296. disableDepthRenderer(camera?: Nullable<Camera>): void;
  123297. }
  123298. /**
  123299. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  123300. * in several rendering techniques.
  123301. */
  123302. export class DepthRendererSceneComponent implements ISceneComponent {
  123303. /**
  123304. * The component name helpfull to identify the component in the list of scene components.
  123305. */
  123306. readonly name: string;
  123307. /**
  123308. * The scene the component belongs to.
  123309. */
  123310. scene: Scene;
  123311. /**
  123312. * Creates a new instance of the component for the given scene
  123313. * @param scene Defines the scene to register the component in
  123314. */
  123315. constructor(scene: Scene);
  123316. /**
  123317. * Registers the component in a given scene
  123318. */
  123319. register(): void;
  123320. /**
  123321. * Rebuilds the elements related to this component in case of
  123322. * context lost for instance.
  123323. */
  123324. rebuild(): void;
  123325. /**
  123326. * Disposes the component and the associated ressources
  123327. */
  123328. dispose(): void;
  123329. private _gatherRenderTargets;
  123330. private _gatherActiveCameraRenderTargets;
  123331. }
  123332. }
  123333. declare module BABYLON {
  123334. /** @hidden */
  123335. export var outlinePixelShader: {
  123336. name: string;
  123337. shader: string;
  123338. };
  123339. }
  123340. declare module BABYLON {
  123341. /** @hidden */
  123342. export var outlineVertexShader: {
  123343. name: string;
  123344. shader: string;
  123345. };
  123346. }
  123347. declare module BABYLON {
  123348. interface Scene {
  123349. /** @hidden */
  123350. _outlineRenderer: OutlineRenderer;
  123351. /**
  123352. * Gets the outline renderer associated with the scene
  123353. * @returns a OutlineRenderer
  123354. */
  123355. getOutlineRenderer(): OutlineRenderer;
  123356. }
  123357. interface AbstractMesh {
  123358. /** @hidden (Backing field) */
  123359. _renderOutline: boolean;
  123360. /**
  123361. * Gets or sets a boolean indicating if the outline must be rendered as well
  123362. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  123363. */
  123364. renderOutline: boolean;
  123365. /** @hidden (Backing field) */
  123366. _renderOverlay: boolean;
  123367. /**
  123368. * Gets or sets a boolean indicating if the overlay must be rendered as well
  123369. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  123370. */
  123371. renderOverlay: boolean;
  123372. }
  123373. /**
  123374. * This class is responsible to draw bothe outline/overlay of meshes.
  123375. * It should not be used directly but through the available method on mesh.
  123376. */
  123377. export class OutlineRenderer implements ISceneComponent {
  123378. /**
  123379. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  123380. */
  123381. private static _StencilReference;
  123382. /**
  123383. * The name of the component. Each component must have a unique name.
  123384. */
  123385. name: string;
  123386. /**
  123387. * The scene the component belongs to.
  123388. */
  123389. scene: Scene;
  123390. /**
  123391. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123392. */
  123393. zOffset: number;
  123394. private _engine;
  123395. private _effect;
  123396. private _cachedDefines;
  123397. private _savedDepthWrite;
  123398. /**
  123399. * Instantiates a new outline renderer. (There could be only one per scene).
  123400. * @param scene Defines the scene it belongs to
  123401. */
  123402. constructor(scene: Scene);
  123403. /**
  123404. * Register the component to one instance of a scene.
  123405. */
  123406. register(): void;
  123407. /**
  123408. * Rebuilds the elements related to this component in case of
  123409. * context lost for instance.
  123410. */
  123411. rebuild(): void;
  123412. /**
  123413. * Disposes the component and the associated ressources.
  123414. */
  123415. dispose(): void;
  123416. /**
  123417. * Renders the outline in the canvas.
  123418. * @param subMesh Defines the sumesh to render
  123419. * @param batch Defines the batch of meshes in case of instances
  123420. * @param useOverlay Defines if the rendering is for the overlay or the outline
  123421. */
  123422. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  123423. /**
  123424. * Returns whether or not the outline renderer is ready for a given submesh.
  123425. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  123426. * @param subMesh Defines the submesh to check readyness for
  123427. * @param useInstances Defines wheter wee are trying to render instances or not
  123428. * @returns true if ready otherwise false
  123429. */
  123430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123431. private _beforeRenderingMesh;
  123432. private _afterRenderingMesh;
  123433. }
  123434. }
  123435. declare module BABYLON {
  123436. /**
  123437. * Defines the list of states available for a task inside a AssetsManager
  123438. */
  123439. export enum AssetTaskState {
  123440. /**
  123441. * Initialization
  123442. */
  123443. INIT = 0,
  123444. /**
  123445. * Running
  123446. */
  123447. RUNNING = 1,
  123448. /**
  123449. * Done
  123450. */
  123451. DONE = 2,
  123452. /**
  123453. * Error
  123454. */
  123455. ERROR = 3
  123456. }
  123457. /**
  123458. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  123459. */
  123460. export abstract class AbstractAssetTask {
  123461. /**
  123462. * Task name
  123463. */ name: string;
  123464. /**
  123465. * Callback called when the task is successful
  123466. */
  123467. onSuccess: (task: any) => void;
  123468. /**
  123469. * Callback called when the task is not successful
  123470. */
  123471. onError: (task: any, message?: string, exception?: any) => void;
  123472. /**
  123473. * Creates a new AssetsManager
  123474. * @param name defines the name of the task
  123475. */
  123476. constructor(
  123477. /**
  123478. * Task name
  123479. */ name: string);
  123480. private _isCompleted;
  123481. private _taskState;
  123482. private _errorObject;
  123483. /**
  123484. * Get if the task is completed
  123485. */
  123486. readonly isCompleted: boolean;
  123487. /**
  123488. * Gets the current state of the task
  123489. */
  123490. readonly taskState: AssetTaskState;
  123491. /**
  123492. * Gets the current error object (if task is in error)
  123493. */
  123494. readonly errorObject: {
  123495. message?: string;
  123496. exception?: any;
  123497. };
  123498. /**
  123499. * Internal only
  123500. * @hidden
  123501. */
  123502. _setErrorObject(message?: string, exception?: any): void;
  123503. /**
  123504. * Execute the current task
  123505. * @param scene defines the scene where you want your assets to be loaded
  123506. * @param onSuccess is a callback called when the task is successfully executed
  123507. * @param onError is a callback called if an error occurs
  123508. */
  123509. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123510. /**
  123511. * Execute the current task
  123512. * @param scene defines the scene where you want your assets to be loaded
  123513. * @param onSuccess is a callback called when the task is successfully executed
  123514. * @param onError is a callback called if an error occurs
  123515. */
  123516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123517. /**
  123518. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  123519. * This can be used with failed tasks that have the reason for failure fixed.
  123520. */
  123521. reset(): void;
  123522. private onErrorCallback;
  123523. private onDoneCallback;
  123524. }
  123525. /**
  123526. * Define the interface used by progress events raised during assets loading
  123527. */
  123528. export interface IAssetsProgressEvent {
  123529. /**
  123530. * Defines the number of remaining tasks to process
  123531. */
  123532. remainingCount: number;
  123533. /**
  123534. * Defines the total number of tasks
  123535. */
  123536. totalCount: number;
  123537. /**
  123538. * Defines the task that was just processed
  123539. */
  123540. task: AbstractAssetTask;
  123541. }
  123542. /**
  123543. * Class used to share progress information about assets loading
  123544. */
  123545. export class AssetsProgressEvent implements IAssetsProgressEvent {
  123546. /**
  123547. * Defines the number of remaining tasks to process
  123548. */
  123549. remainingCount: number;
  123550. /**
  123551. * Defines the total number of tasks
  123552. */
  123553. totalCount: number;
  123554. /**
  123555. * Defines the task that was just processed
  123556. */
  123557. task: AbstractAssetTask;
  123558. /**
  123559. * Creates a AssetsProgressEvent
  123560. * @param remainingCount defines the number of remaining tasks to process
  123561. * @param totalCount defines the total number of tasks
  123562. * @param task defines the task that was just processed
  123563. */
  123564. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  123565. }
  123566. /**
  123567. * Define a task used by AssetsManager to load meshes
  123568. */
  123569. export class MeshAssetTask extends AbstractAssetTask {
  123570. /**
  123571. * Defines the name of the task
  123572. */
  123573. name: string;
  123574. /**
  123575. * Defines the list of mesh's names you want to load
  123576. */
  123577. meshesNames: any;
  123578. /**
  123579. * Defines the root url to use as a base to load your meshes and associated resources
  123580. */
  123581. rootUrl: string;
  123582. /**
  123583. * Defines the filename of the scene to load from
  123584. */
  123585. sceneFilename: string;
  123586. /**
  123587. * Gets the list of loaded meshes
  123588. */
  123589. loadedMeshes: Array<AbstractMesh>;
  123590. /**
  123591. * Gets the list of loaded particle systems
  123592. */
  123593. loadedParticleSystems: Array<IParticleSystem>;
  123594. /**
  123595. * Gets the list of loaded skeletons
  123596. */
  123597. loadedSkeletons: Array<Skeleton>;
  123598. /**
  123599. * Gets the list of loaded animation groups
  123600. */
  123601. loadedAnimationGroups: Array<AnimationGroup>;
  123602. /**
  123603. * Callback called when the task is successful
  123604. */
  123605. onSuccess: (task: MeshAssetTask) => void;
  123606. /**
  123607. * Callback called when the task is successful
  123608. */
  123609. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123610. /**
  123611. * Creates a new MeshAssetTask
  123612. * @param name defines the name of the task
  123613. * @param meshesNames defines the list of mesh's names you want to load
  123614. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123615. * @param sceneFilename defines the filename of the scene to load from
  123616. */
  123617. constructor(
  123618. /**
  123619. * Defines the name of the task
  123620. */
  123621. name: string,
  123622. /**
  123623. * Defines the list of mesh's names you want to load
  123624. */
  123625. meshesNames: any,
  123626. /**
  123627. * Defines the root url to use as a base to load your meshes and associated resources
  123628. */
  123629. rootUrl: string,
  123630. /**
  123631. * Defines the filename of the scene to load from
  123632. */
  123633. sceneFilename: string);
  123634. /**
  123635. * Execute the current task
  123636. * @param scene defines the scene where you want your assets to be loaded
  123637. * @param onSuccess is a callback called when the task is successfully executed
  123638. * @param onError is a callback called if an error occurs
  123639. */
  123640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123641. }
  123642. /**
  123643. * Define a task used by AssetsManager to load text content
  123644. */
  123645. export class TextFileAssetTask extends AbstractAssetTask {
  123646. /**
  123647. * Defines the name of the task
  123648. */
  123649. name: string;
  123650. /**
  123651. * Defines the location of the file to load
  123652. */
  123653. url: string;
  123654. /**
  123655. * Gets the loaded text string
  123656. */
  123657. text: string;
  123658. /**
  123659. * Callback called when the task is successful
  123660. */
  123661. onSuccess: (task: TextFileAssetTask) => void;
  123662. /**
  123663. * Callback called when the task is successful
  123664. */
  123665. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  123666. /**
  123667. * Creates a new TextFileAssetTask object
  123668. * @param name defines the name of the task
  123669. * @param url defines the location of the file to load
  123670. */
  123671. constructor(
  123672. /**
  123673. * Defines the name of the task
  123674. */
  123675. name: string,
  123676. /**
  123677. * Defines the location of the file to load
  123678. */
  123679. url: string);
  123680. /**
  123681. * Execute the current task
  123682. * @param scene defines the scene where you want your assets to be loaded
  123683. * @param onSuccess is a callback called when the task is successfully executed
  123684. * @param onError is a callback called if an error occurs
  123685. */
  123686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123687. }
  123688. /**
  123689. * Define a task used by AssetsManager to load binary data
  123690. */
  123691. export class BinaryFileAssetTask extends AbstractAssetTask {
  123692. /**
  123693. * Defines the name of the task
  123694. */
  123695. name: string;
  123696. /**
  123697. * Defines the location of the file to load
  123698. */
  123699. url: string;
  123700. /**
  123701. * Gets the lodaded data (as an array buffer)
  123702. */
  123703. data: ArrayBuffer;
  123704. /**
  123705. * Callback called when the task is successful
  123706. */
  123707. onSuccess: (task: BinaryFileAssetTask) => void;
  123708. /**
  123709. * Callback called when the task is successful
  123710. */
  123711. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  123712. /**
  123713. * Creates a new BinaryFileAssetTask object
  123714. * @param name defines the name of the new task
  123715. * @param url defines the location of the file to load
  123716. */
  123717. constructor(
  123718. /**
  123719. * Defines the name of the task
  123720. */
  123721. name: string,
  123722. /**
  123723. * Defines the location of the file to load
  123724. */
  123725. url: string);
  123726. /**
  123727. * Execute the current task
  123728. * @param scene defines the scene where you want your assets to be loaded
  123729. * @param onSuccess is a callback called when the task is successfully executed
  123730. * @param onError is a callback called if an error occurs
  123731. */
  123732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123733. }
  123734. /**
  123735. * Define a task used by AssetsManager to load images
  123736. */
  123737. export class ImageAssetTask extends AbstractAssetTask {
  123738. /**
  123739. * Defines the name of the task
  123740. */
  123741. name: string;
  123742. /**
  123743. * Defines the location of the image to load
  123744. */
  123745. url: string;
  123746. /**
  123747. * Gets the loaded images
  123748. */
  123749. image: HTMLImageElement;
  123750. /**
  123751. * Callback called when the task is successful
  123752. */
  123753. onSuccess: (task: ImageAssetTask) => void;
  123754. /**
  123755. * Callback called when the task is successful
  123756. */
  123757. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  123758. /**
  123759. * Creates a new ImageAssetTask
  123760. * @param name defines the name of the task
  123761. * @param url defines the location of the image to load
  123762. */
  123763. constructor(
  123764. /**
  123765. * Defines the name of the task
  123766. */
  123767. name: string,
  123768. /**
  123769. * Defines the location of the image to load
  123770. */
  123771. url: string);
  123772. /**
  123773. * Execute the current task
  123774. * @param scene defines the scene where you want your assets to be loaded
  123775. * @param onSuccess is a callback called when the task is successfully executed
  123776. * @param onError is a callback called if an error occurs
  123777. */
  123778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123779. }
  123780. /**
  123781. * Defines the interface used by texture loading tasks
  123782. */
  123783. export interface ITextureAssetTask<TEX extends BaseTexture> {
  123784. /**
  123785. * Gets the loaded texture
  123786. */
  123787. texture: TEX;
  123788. }
  123789. /**
  123790. * Define a task used by AssetsManager to load 2D textures
  123791. */
  123792. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  123793. /**
  123794. * Defines the name of the task
  123795. */
  123796. name: string;
  123797. /**
  123798. * Defines the location of the file to load
  123799. */
  123800. url: string;
  123801. /**
  123802. * Defines if mipmap should not be generated (default is false)
  123803. */
  123804. noMipmap?: boolean | undefined;
  123805. /**
  123806. * Defines if texture must be inverted on Y axis (default is false)
  123807. */
  123808. invertY?: boolean | undefined;
  123809. /**
  123810. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123811. */
  123812. samplingMode: number;
  123813. /**
  123814. * Gets the loaded texture
  123815. */
  123816. texture: Texture;
  123817. /**
  123818. * Callback called when the task is successful
  123819. */
  123820. onSuccess: (task: TextureAssetTask) => void;
  123821. /**
  123822. * Callback called when the task is successful
  123823. */
  123824. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  123825. /**
  123826. * Creates a new TextureAssetTask object
  123827. * @param name defines the name of the task
  123828. * @param url defines the location of the file to load
  123829. * @param noMipmap defines if mipmap should not be generated (default is false)
  123830. * @param invertY defines if texture must be inverted on Y axis (default is false)
  123831. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123832. */
  123833. constructor(
  123834. /**
  123835. * Defines the name of the task
  123836. */
  123837. name: string,
  123838. /**
  123839. * Defines the location of the file to load
  123840. */
  123841. url: string,
  123842. /**
  123843. * Defines if mipmap should not be generated (default is false)
  123844. */
  123845. noMipmap?: boolean | undefined,
  123846. /**
  123847. * Defines if texture must be inverted on Y axis (default is false)
  123848. */
  123849. invertY?: boolean | undefined,
  123850. /**
  123851. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123852. */
  123853. samplingMode?: number);
  123854. /**
  123855. * Execute the current task
  123856. * @param scene defines the scene where you want your assets to be loaded
  123857. * @param onSuccess is a callback called when the task is successfully executed
  123858. * @param onError is a callback called if an error occurs
  123859. */
  123860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123861. }
  123862. /**
  123863. * Define a task used by AssetsManager to load cube textures
  123864. */
  123865. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123866. /**
  123867. * Defines the name of the task
  123868. */
  123869. name: string;
  123870. /**
  123871. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123872. */
  123873. url: string;
  123874. /**
  123875. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123876. */
  123877. extensions?: string[] | undefined;
  123878. /**
  123879. * Defines if mipmaps should not be generated (default is false)
  123880. */
  123881. noMipmap?: boolean | undefined;
  123882. /**
  123883. * Defines the explicit list of files (undefined by default)
  123884. */
  123885. files?: string[] | undefined;
  123886. /**
  123887. * Gets the loaded texture
  123888. */
  123889. texture: CubeTexture;
  123890. /**
  123891. * Callback called when the task is successful
  123892. */
  123893. onSuccess: (task: CubeTextureAssetTask) => void;
  123894. /**
  123895. * Callback called when the task is successful
  123896. */
  123897. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123898. /**
  123899. * Creates a new CubeTextureAssetTask
  123900. * @param name defines the name of the task
  123901. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123902. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123903. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123904. * @param files defines the explicit list of files (undefined by default)
  123905. */
  123906. constructor(
  123907. /**
  123908. * Defines the name of the task
  123909. */
  123910. name: string,
  123911. /**
  123912. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123913. */
  123914. url: string,
  123915. /**
  123916. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123917. */
  123918. extensions?: string[] | undefined,
  123919. /**
  123920. * Defines if mipmaps should not be generated (default is false)
  123921. */
  123922. noMipmap?: boolean | undefined,
  123923. /**
  123924. * Defines the explicit list of files (undefined by default)
  123925. */
  123926. files?: string[] | undefined);
  123927. /**
  123928. * Execute the current task
  123929. * @param scene defines the scene where you want your assets to be loaded
  123930. * @param onSuccess is a callback called when the task is successfully executed
  123931. * @param onError is a callback called if an error occurs
  123932. */
  123933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123934. }
  123935. /**
  123936. * Define a task used by AssetsManager to load HDR cube textures
  123937. */
  123938. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123939. /**
  123940. * Defines the name of the task
  123941. */
  123942. name: string;
  123943. /**
  123944. * Defines the location of the file to load
  123945. */
  123946. url: string;
  123947. /**
  123948. * Defines the desired size (the more it increases the longer the generation will be)
  123949. */
  123950. size: number;
  123951. /**
  123952. * Defines if mipmaps should not be generated (default is false)
  123953. */
  123954. noMipmap: boolean;
  123955. /**
  123956. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123957. */
  123958. generateHarmonics: boolean;
  123959. /**
  123960. * 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)
  123961. */
  123962. gammaSpace: boolean;
  123963. /**
  123964. * Internal Use Only
  123965. */
  123966. reserved: boolean;
  123967. /**
  123968. * Gets the loaded texture
  123969. */
  123970. texture: HDRCubeTexture;
  123971. /**
  123972. * Callback called when the task is successful
  123973. */
  123974. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123975. /**
  123976. * Callback called when the task is successful
  123977. */
  123978. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123979. /**
  123980. * Creates a new HDRCubeTextureAssetTask object
  123981. * @param name defines the name of the task
  123982. * @param url defines the location of the file to load
  123983. * @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.
  123984. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123985. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123986. * @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)
  123987. * @param reserved Internal use only
  123988. */
  123989. constructor(
  123990. /**
  123991. * Defines the name of the task
  123992. */
  123993. name: string,
  123994. /**
  123995. * Defines the location of the file to load
  123996. */
  123997. url: string,
  123998. /**
  123999. * Defines the desired size (the more it increases the longer the generation will be)
  124000. */
  124001. size: number,
  124002. /**
  124003. * Defines if mipmaps should not be generated (default is false)
  124004. */
  124005. noMipmap?: boolean,
  124006. /**
  124007. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124008. */
  124009. generateHarmonics?: boolean,
  124010. /**
  124011. * 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)
  124012. */
  124013. gammaSpace?: boolean,
  124014. /**
  124015. * Internal Use Only
  124016. */
  124017. reserved?: boolean);
  124018. /**
  124019. * Execute the current task
  124020. * @param scene defines the scene where you want your assets to be loaded
  124021. * @param onSuccess is a callback called when the task is successfully executed
  124022. * @param onError is a callback called if an error occurs
  124023. */
  124024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124025. }
  124026. /**
  124027. * Define a task used by AssetsManager to load Equirectangular cube textures
  124028. */
  124029. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124030. /**
  124031. * Defines the name of the task
  124032. */
  124033. name: string;
  124034. /**
  124035. * Defines the location of the file to load
  124036. */
  124037. url: string;
  124038. /**
  124039. * Defines the desired size (the more it increases the longer the generation will be)
  124040. */
  124041. size: number;
  124042. /**
  124043. * Defines if mipmaps should not be generated (default is false)
  124044. */
  124045. noMipmap: boolean;
  124046. /**
  124047. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124048. * but the standard material would require them in Gamma space) (default is true)
  124049. */
  124050. gammaSpace: boolean;
  124051. /**
  124052. * Gets the loaded texture
  124053. */
  124054. texture: EquiRectangularCubeTexture;
  124055. /**
  124056. * Callback called when the task is successful
  124057. */
  124058. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124059. /**
  124060. * Callback called when the task is successful
  124061. */
  124062. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124063. /**
  124064. * Creates a new EquiRectangularCubeTextureAssetTask object
  124065. * @param name defines the name of the task
  124066. * @param url defines the location of the file to load
  124067. * @param size defines the desired size (the more it increases the longer the generation will be)
  124068. * If the size is omitted this implies you are using a preprocessed cubemap.
  124069. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124070. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124071. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124072. * (default is true)
  124073. */
  124074. constructor(
  124075. /**
  124076. * Defines the name of the task
  124077. */
  124078. name: string,
  124079. /**
  124080. * Defines the location of the file to load
  124081. */
  124082. url: string,
  124083. /**
  124084. * Defines the desired size (the more it increases the longer the generation will be)
  124085. */
  124086. size: number,
  124087. /**
  124088. * Defines if mipmaps should not be generated (default is false)
  124089. */
  124090. noMipmap?: boolean,
  124091. /**
  124092. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124093. * but the standard material would require them in Gamma space) (default is true)
  124094. */
  124095. gammaSpace?: boolean);
  124096. /**
  124097. * Execute the current task
  124098. * @param scene defines the scene where you want your assets to be loaded
  124099. * @param onSuccess is a callback called when the task is successfully executed
  124100. * @param onError is a callback called if an error occurs
  124101. */
  124102. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124103. }
  124104. /**
  124105. * This class can be used to easily import assets into a scene
  124106. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124107. */
  124108. export class AssetsManager {
  124109. private _scene;
  124110. private _isLoading;
  124111. protected _tasks: AbstractAssetTask[];
  124112. protected _waitingTasksCount: number;
  124113. protected _totalTasksCount: number;
  124114. /**
  124115. * Callback called when all tasks are processed
  124116. */
  124117. onFinish: (tasks: AbstractAssetTask[]) => void;
  124118. /**
  124119. * Callback called when a task is successful
  124120. */
  124121. onTaskSuccess: (task: AbstractAssetTask) => void;
  124122. /**
  124123. * Callback called when a task had an error
  124124. */
  124125. onTaskError: (task: AbstractAssetTask) => void;
  124126. /**
  124127. * Callback called when a task is done (whatever the result is)
  124128. */
  124129. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  124130. /**
  124131. * Observable called when all tasks are processed
  124132. */
  124133. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  124134. /**
  124135. * Observable called when a task had an error
  124136. */
  124137. onTaskErrorObservable: Observable<AbstractAssetTask>;
  124138. /**
  124139. * Observable called when all tasks were executed
  124140. */
  124141. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  124142. /**
  124143. * Observable called when a task is done (whatever the result is)
  124144. */
  124145. onProgressObservable: Observable<IAssetsProgressEvent>;
  124146. /**
  124147. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  124148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  124149. */
  124150. useDefaultLoadingScreen: boolean;
  124151. /**
  124152. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  124153. * when all assets have been downloaded.
  124154. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  124155. */
  124156. autoHideLoadingUI: boolean;
  124157. /**
  124158. * Creates a new AssetsManager
  124159. * @param scene defines the scene to work on
  124160. */
  124161. constructor(scene: Scene);
  124162. /**
  124163. * Add a MeshAssetTask to the list of active tasks
  124164. * @param taskName defines the name of the new task
  124165. * @param meshesNames defines the name of meshes to load
  124166. * @param rootUrl defines the root url to use to locate files
  124167. * @param sceneFilename defines the filename of the scene file
  124168. * @returns a new MeshAssetTask object
  124169. */
  124170. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  124171. /**
  124172. * Add a TextFileAssetTask to the list of active tasks
  124173. * @param taskName defines the name of the new task
  124174. * @param url defines the url of the file to load
  124175. * @returns a new TextFileAssetTask object
  124176. */
  124177. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  124178. /**
  124179. * Add a BinaryFileAssetTask to the list of active tasks
  124180. * @param taskName defines the name of the new task
  124181. * @param url defines the url of the file to load
  124182. * @returns a new BinaryFileAssetTask object
  124183. */
  124184. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  124185. /**
  124186. * Add a ImageAssetTask to the list of active tasks
  124187. * @param taskName defines the name of the new task
  124188. * @param url defines the url of the file to load
  124189. * @returns a new ImageAssetTask object
  124190. */
  124191. addImageTask(taskName: string, url: string): ImageAssetTask;
  124192. /**
  124193. * Add a TextureAssetTask to the list of active tasks
  124194. * @param taskName defines the name of the new task
  124195. * @param url defines the url of the file to load
  124196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124197. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  124198. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124199. * @returns a new TextureAssetTask object
  124200. */
  124201. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  124202. /**
  124203. * Add a CubeTextureAssetTask to the list of active tasks
  124204. * @param taskName defines the name of the new task
  124205. * @param url defines the url of the file to load
  124206. * @param extensions defines the extension to use to load the cube map (can be null)
  124207. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124208. * @param files defines the list of files to load (can be null)
  124209. * @returns a new CubeTextureAssetTask object
  124210. */
  124211. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  124212. /**
  124213. *
  124214. * Add a HDRCubeTextureAssetTask to the list of active tasks
  124215. * @param taskName defines the name of the new task
  124216. * @param url defines the url of the file to load
  124217. * @param size defines the size you want for the cubemap (can be null)
  124218. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124219. * @param generateHarmonics defines if you want to automatically generate (true by default)
  124220. * @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)
  124221. * @param reserved Internal use only
  124222. * @returns a new HDRCubeTextureAssetTask object
  124223. */
  124224. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  124225. /**
  124226. *
  124227. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  124228. * @param taskName defines the name of the new task
  124229. * @param url defines the url of the file to load
  124230. * @param size defines the size you want for the cubemap (can be null)
  124231. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124232. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124233. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124234. * @returns a new EquiRectangularCubeTextureAssetTask object
  124235. */
  124236. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  124237. /**
  124238. * Remove a task from the assets manager.
  124239. * @param task the task to remove
  124240. */
  124241. removeTask(task: AbstractAssetTask): void;
  124242. private _decreaseWaitingTasksCount;
  124243. private _runTask;
  124244. /**
  124245. * Reset the AssetsManager and remove all tasks
  124246. * @return the current instance of the AssetsManager
  124247. */
  124248. reset(): AssetsManager;
  124249. /**
  124250. * Start the loading process
  124251. * @return the current instance of the AssetsManager
  124252. */
  124253. load(): AssetsManager;
  124254. /**
  124255. * Start the loading process as an async operation
  124256. * @return a promise returning the list of failed tasks
  124257. */
  124258. loadAsync(): Promise<void>;
  124259. }
  124260. }
  124261. declare module BABYLON {
  124262. /**
  124263. * Wrapper class for promise with external resolve and reject.
  124264. */
  124265. export class Deferred<T> {
  124266. /**
  124267. * The promise associated with this deferred object.
  124268. */
  124269. readonly promise: Promise<T>;
  124270. private _resolve;
  124271. private _reject;
  124272. /**
  124273. * The resolve method of the promise associated with this deferred object.
  124274. */
  124275. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  124276. /**
  124277. * The reject method of the promise associated with this deferred object.
  124278. */
  124279. readonly reject: (reason?: any) => void;
  124280. /**
  124281. * Constructor for this deferred object.
  124282. */
  124283. constructor();
  124284. }
  124285. }
  124286. declare module BABYLON {
  124287. /**
  124288. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  124289. */
  124290. export class MeshExploder {
  124291. private _centerMesh;
  124292. private _meshes;
  124293. private _meshesOrigins;
  124294. private _toCenterVectors;
  124295. private _scaledDirection;
  124296. private _newPosition;
  124297. private _centerPosition;
  124298. /**
  124299. * Explodes meshes from a center mesh.
  124300. * @param meshes The meshes to explode.
  124301. * @param centerMesh The mesh to be center of explosion.
  124302. */
  124303. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  124304. private _setCenterMesh;
  124305. /**
  124306. * Get class name
  124307. * @returns "MeshExploder"
  124308. */
  124309. getClassName(): string;
  124310. /**
  124311. * "Exploded meshes"
  124312. * @returns Array of meshes with the centerMesh at index 0.
  124313. */
  124314. getMeshes(): Array<Mesh>;
  124315. /**
  124316. * Explodes meshes giving a specific direction
  124317. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  124318. */
  124319. explode(direction?: number): void;
  124320. }
  124321. }
  124322. declare module BABYLON {
  124323. /**
  124324. * Class used to help managing file picking and drag'n'drop
  124325. */
  124326. export class FilesInput {
  124327. /**
  124328. * List of files ready to be loaded
  124329. */
  124330. static readonly FilesToLoad: {
  124331. [key: string]: File;
  124332. };
  124333. /**
  124334. * Callback called when a file is processed
  124335. */
  124336. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  124337. private _engine;
  124338. private _currentScene;
  124339. private _sceneLoadedCallback;
  124340. private _progressCallback;
  124341. private _additionalRenderLoopLogicCallback;
  124342. private _textureLoadingCallback;
  124343. private _startingProcessingFilesCallback;
  124344. private _onReloadCallback;
  124345. private _errorCallback;
  124346. private _elementToMonitor;
  124347. private _sceneFileToLoad;
  124348. private _filesToLoad;
  124349. /**
  124350. * Creates a new FilesInput
  124351. * @param engine defines the rendering engine
  124352. * @param scene defines the hosting scene
  124353. * @param sceneLoadedCallback callback called when scene is loaded
  124354. * @param progressCallback callback called to track progress
  124355. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  124356. * @param textureLoadingCallback callback called when a texture is loading
  124357. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  124358. * @param onReloadCallback callback called when a reload is requested
  124359. * @param errorCallback callback call if an error occurs
  124360. */
  124361. 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);
  124362. private _dragEnterHandler;
  124363. private _dragOverHandler;
  124364. private _dropHandler;
  124365. /**
  124366. * Calls this function to listen to drag'n'drop events on a specific DOM element
  124367. * @param elementToMonitor defines the DOM element to track
  124368. */
  124369. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  124370. /**
  124371. * Release all associated resources
  124372. */
  124373. dispose(): void;
  124374. private renderFunction;
  124375. private drag;
  124376. private drop;
  124377. private _traverseFolder;
  124378. private _processFiles;
  124379. /**
  124380. * Load files from a drop event
  124381. * @param event defines the drop event to use as source
  124382. */
  124383. loadFiles(event: any): void;
  124384. private _processReload;
  124385. /**
  124386. * Reload the current scene from the loaded files
  124387. */
  124388. reload(): void;
  124389. }
  124390. }
  124391. declare module BABYLON {
  124392. /**
  124393. * Defines the root class used to create scene optimization to use with SceneOptimizer
  124394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124395. */
  124396. export class SceneOptimization {
  124397. /**
  124398. * Defines the priority of this optimization (0 by default which means first in the list)
  124399. */
  124400. priority: number;
  124401. /**
  124402. * Gets a string describing the action executed by the current optimization
  124403. * @returns description string
  124404. */
  124405. getDescription(): string;
  124406. /**
  124407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124408. * @param scene defines the current scene where to apply this optimization
  124409. * @param optimizer defines the current optimizer
  124410. * @returns true if everything that can be done was applied
  124411. */
  124412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124413. /**
  124414. * Creates the SceneOptimization object
  124415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124416. * @param desc defines the description associated with the optimization
  124417. */
  124418. constructor(
  124419. /**
  124420. * Defines the priority of this optimization (0 by default which means first in the list)
  124421. */
  124422. priority?: number);
  124423. }
  124424. /**
  124425. * Defines an optimization used to reduce the size of render target textures
  124426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124427. */
  124428. export class TextureOptimization extends SceneOptimization {
  124429. /**
  124430. * Defines the priority of this optimization (0 by default which means first in the list)
  124431. */
  124432. priority: number;
  124433. /**
  124434. * 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
  124435. */
  124436. maximumSize: number;
  124437. /**
  124438. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124439. */
  124440. step: number;
  124441. /**
  124442. * Gets a string describing the action executed by the current optimization
  124443. * @returns description string
  124444. */
  124445. getDescription(): string;
  124446. /**
  124447. * Creates the TextureOptimization object
  124448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124449. * @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
  124450. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124451. */
  124452. constructor(
  124453. /**
  124454. * Defines the priority of this optimization (0 by default which means first in the list)
  124455. */
  124456. priority?: number,
  124457. /**
  124458. * 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
  124459. */
  124460. maximumSize?: number,
  124461. /**
  124462. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124463. */
  124464. step?: number);
  124465. /**
  124466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124467. * @param scene defines the current scene where to apply this optimization
  124468. * @param optimizer defines the current optimizer
  124469. * @returns true if everything that can be done was applied
  124470. */
  124471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124472. }
  124473. /**
  124474. * Defines an optimization used to increase or decrease the rendering resolution
  124475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124476. */
  124477. export class HardwareScalingOptimization extends SceneOptimization {
  124478. /**
  124479. * Defines the priority of this optimization (0 by default which means first in the list)
  124480. */
  124481. priority: number;
  124482. /**
  124483. * Defines the maximum scale to use (2 by default)
  124484. */
  124485. maximumScale: number;
  124486. /**
  124487. * Defines the step to use between two passes (0.5 by default)
  124488. */
  124489. step: number;
  124490. private _currentScale;
  124491. private _directionOffset;
  124492. /**
  124493. * Gets a string describing the action executed by the current optimization
  124494. * @return description string
  124495. */
  124496. getDescription(): string;
  124497. /**
  124498. * Creates the HardwareScalingOptimization object
  124499. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124500. * @param maximumScale defines the maximum scale to use (2 by default)
  124501. * @param step defines the step to use between two passes (0.5 by default)
  124502. */
  124503. constructor(
  124504. /**
  124505. * Defines the priority of this optimization (0 by default which means first in the list)
  124506. */
  124507. priority?: number,
  124508. /**
  124509. * Defines the maximum scale to use (2 by default)
  124510. */
  124511. maximumScale?: number,
  124512. /**
  124513. * Defines the step to use between two passes (0.5 by default)
  124514. */
  124515. step?: number);
  124516. /**
  124517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124518. * @param scene defines the current scene where to apply this optimization
  124519. * @param optimizer defines the current optimizer
  124520. * @returns true if everything that can be done was applied
  124521. */
  124522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124523. }
  124524. /**
  124525. * Defines an optimization used to remove shadows
  124526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124527. */
  124528. export class ShadowsOptimization extends SceneOptimization {
  124529. /**
  124530. * Gets a string describing the action executed by the current optimization
  124531. * @return description string
  124532. */
  124533. getDescription(): string;
  124534. /**
  124535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124536. * @param scene defines the current scene where to apply this optimization
  124537. * @param optimizer defines the current optimizer
  124538. * @returns true if everything that can be done was applied
  124539. */
  124540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124541. }
  124542. /**
  124543. * Defines an optimization used to turn post-processes off
  124544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124545. */
  124546. export class PostProcessesOptimization extends SceneOptimization {
  124547. /**
  124548. * Gets a string describing the action executed by the current optimization
  124549. * @return description string
  124550. */
  124551. getDescription(): string;
  124552. /**
  124553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124554. * @param scene defines the current scene where to apply this optimization
  124555. * @param optimizer defines the current optimizer
  124556. * @returns true if everything that can be done was applied
  124557. */
  124558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124559. }
  124560. /**
  124561. * Defines an optimization used to turn lens flares off
  124562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124563. */
  124564. export class LensFlaresOptimization extends SceneOptimization {
  124565. /**
  124566. * Gets a string describing the action executed by the current optimization
  124567. * @return description string
  124568. */
  124569. getDescription(): string;
  124570. /**
  124571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124572. * @param scene defines the current scene where to apply this optimization
  124573. * @param optimizer defines the current optimizer
  124574. * @returns true if everything that can be done was applied
  124575. */
  124576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124577. }
  124578. /**
  124579. * Defines an optimization based on user defined callback.
  124580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124581. */
  124582. export class CustomOptimization extends SceneOptimization {
  124583. /**
  124584. * Callback called to apply the custom optimization.
  124585. */
  124586. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124587. /**
  124588. * Callback called to get custom description
  124589. */
  124590. onGetDescription: () => string;
  124591. /**
  124592. * Gets a string describing the action executed by the current optimization
  124593. * @returns description string
  124594. */
  124595. getDescription(): string;
  124596. /**
  124597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124598. * @param scene defines the current scene where to apply this optimization
  124599. * @param optimizer defines the current optimizer
  124600. * @returns true if everything that can be done was applied
  124601. */
  124602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124603. }
  124604. /**
  124605. * Defines an optimization used to turn particles off
  124606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124607. */
  124608. export class ParticlesOptimization extends SceneOptimization {
  124609. /**
  124610. * Gets a string describing the action executed by the current optimization
  124611. * @return description string
  124612. */
  124613. getDescription(): string;
  124614. /**
  124615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124616. * @param scene defines the current scene where to apply this optimization
  124617. * @param optimizer defines the current optimizer
  124618. * @returns true if everything that can be done was applied
  124619. */
  124620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124621. }
  124622. /**
  124623. * Defines an optimization used to turn render targets off
  124624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124625. */
  124626. export class RenderTargetsOptimization extends SceneOptimization {
  124627. /**
  124628. * Gets a string describing the action executed by the current optimization
  124629. * @return description string
  124630. */
  124631. getDescription(): string;
  124632. /**
  124633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124634. * @param scene defines the current scene where to apply this optimization
  124635. * @param optimizer defines the current optimizer
  124636. * @returns true if everything that can be done was applied
  124637. */
  124638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124639. }
  124640. /**
  124641. * Defines an optimization used to merge meshes with compatible materials
  124642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124643. */
  124644. export class MergeMeshesOptimization extends SceneOptimization {
  124645. private static _UpdateSelectionTree;
  124646. /**
  124647. * Gets or sets a boolean which defines if optimization octree has to be updated
  124648. */
  124649. /**
  124650. * Gets or sets a boolean which defines if optimization octree has to be updated
  124651. */
  124652. static UpdateSelectionTree: boolean;
  124653. /**
  124654. * Gets a string describing the action executed by the current optimization
  124655. * @return description string
  124656. */
  124657. getDescription(): string;
  124658. private _canBeMerged;
  124659. /**
  124660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124661. * @param scene defines the current scene where to apply this optimization
  124662. * @param optimizer defines the current optimizer
  124663. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  124664. * @returns true if everything that can be done was applied
  124665. */
  124666. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  124667. }
  124668. /**
  124669. * Defines a list of options used by SceneOptimizer
  124670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124671. */
  124672. export class SceneOptimizerOptions {
  124673. /**
  124674. * Defines the target frame rate to reach (60 by default)
  124675. */
  124676. targetFrameRate: number;
  124677. /**
  124678. * Defines the interval between two checkes (2000ms by default)
  124679. */
  124680. trackerDuration: number;
  124681. /**
  124682. * Gets the list of optimizations to apply
  124683. */
  124684. optimizations: SceneOptimization[];
  124685. /**
  124686. * Creates a new list of options used by SceneOptimizer
  124687. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  124688. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  124689. */
  124690. constructor(
  124691. /**
  124692. * Defines the target frame rate to reach (60 by default)
  124693. */
  124694. targetFrameRate?: number,
  124695. /**
  124696. * Defines the interval between two checkes (2000ms by default)
  124697. */
  124698. trackerDuration?: number);
  124699. /**
  124700. * Add a new optimization
  124701. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  124702. * @returns the current SceneOptimizerOptions
  124703. */
  124704. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  124705. /**
  124706. * Add a new custom optimization
  124707. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  124708. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  124709. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124710. * @returns the current SceneOptimizerOptions
  124711. */
  124712. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  124713. /**
  124714. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  124715. * @param targetFrameRate defines the target frame rate (60 by default)
  124716. * @returns a SceneOptimizerOptions object
  124717. */
  124718. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124719. /**
  124720. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  124721. * @param targetFrameRate defines the target frame rate (60 by default)
  124722. * @returns a SceneOptimizerOptions object
  124723. */
  124724. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124725. /**
  124726. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  124727. * @param targetFrameRate defines the target frame rate (60 by default)
  124728. * @returns a SceneOptimizerOptions object
  124729. */
  124730. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124731. }
  124732. /**
  124733. * Class used to run optimizations in order to reach a target frame rate
  124734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124735. */
  124736. export class SceneOptimizer implements IDisposable {
  124737. private _isRunning;
  124738. private _options;
  124739. private _scene;
  124740. private _currentPriorityLevel;
  124741. private _targetFrameRate;
  124742. private _trackerDuration;
  124743. private _currentFrameRate;
  124744. private _sceneDisposeObserver;
  124745. private _improvementMode;
  124746. /**
  124747. * Defines an observable called when the optimizer reaches the target frame rate
  124748. */
  124749. onSuccessObservable: Observable<SceneOptimizer>;
  124750. /**
  124751. * Defines an observable called when the optimizer enables an optimization
  124752. */
  124753. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  124754. /**
  124755. * Defines an observable called when the optimizer is not able to reach the target frame rate
  124756. */
  124757. onFailureObservable: Observable<SceneOptimizer>;
  124758. /**
  124759. * Gets a boolean indicating if the optimizer is in improvement mode
  124760. */
  124761. readonly isInImprovementMode: boolean;
  124762. /**
  124763. * Gets the current priority level (0 at start)
  124764. */
  124765. readonly currentPriorityLevel: number;
  124766. /**
  124767. * Gets the current frame rate checked by the SceneOptimizer
  124768. */
  124769. readonly currentFrameRate: number;
  124770. /**
  124771. * Gets or sets the current target frame rate (60 by default)
  124772. */
  124773. /**
  124774. * Gets or sets the current target frame rate (60 by default)
  124775. */
  124776. targetFrameRate: number;
  124777. /**
  124778. * Gets or sets the current interval between two checks (every 2000ms by default)
  124779. */
  124780. /**
  124781. * Gets or sets the current interval between two checks (every 2000ms by default)
  124782. */
  124783. trackerDuration: number;
  124784. /**
  124785. * Gets the list of active optimizations
  124786. */
  124787. readonly optimizations: SceneOptimization[];
  124788. /**
  124789. * Creates a new SceneOptimizer
  124790. * @param scene defines the scene to work on
  124791. * @param options defines the options to use with the SceneOptimizer
  124792. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  124793. * @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)
  124794. */
  124795. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  124796. /**
  124797. * Stops the current optimizer
  124798. */
  124799. stop(): void;
  124800. /**
  124801. * Reset the optimizer to initial step (current priority level = 0)
  124802. */
  124803. reset(): void;
  124804. /**
  124805. * Start the optimizer. By default it will try to reach a specific framerate
  124806. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  124807. */
  124808. start(): void;
  124809. private _checkCurrentState;
  124810. /**
  124811. * Release all resources
  124812. */
  124813. dispose(): void;
  124814. /**
  124815. * Helper function to create a SceneOptimizer with one single line of code
  124816. * @param scene defines the scene to work on
  124817. * @param options defines the options to use with the SceneOptimizer
  124818. * @param onSuccess defines a callback to call on success
  124819. * @param onFailure defines a callback to call on failure
  124820. * @returns the new SceneOptimizer object
  124821. */
  124822. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  124823. }
  124824. }
  124825. declare module BABYLON {
  124826. /**
  124827. * Class used to serialize a scene into a string
  124828. */
  124829. export class SceneSerializer {
  124830. /**
  124831. * Clear cache used by a previous serialization
  124832. */
  124833. static ClearCache(): void;
  124834. /**
  124835. * Serialize a scene into a JSON compatible object
  124836. * @param scene defines the scene to serialize
  124837. * @returns a JSON compatible object
  124838. */
  124839. static Serialize(scene: Scene): any;
  124840. /**
  124841. * Serialize a mesh into a JSON compatible object
  124842. * @param toSerialize defines the mesh to serialize
  124843. * @param withParents defines if parents must be serialized as well
  124844. * @param withChildren defines if children must be serialized as well
  124845. * @returns a JSON compatible object
  124846. */
  124847. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124848. }
  124849. }
  124850. declare module BABYLON {
  124851. /**
  124852. * Class used to host texture specific utilities
  124853. */
  124854. export class TextureTools {
  124855. /**
  124856. * Uses the GPU to create a copy texture rescaled at a given size
  124857. * @param texture Texture to copy from
  124858. * @param width defines the desired width
  124859. * @param height defines the desired height
  124860. * @param useBilinearMode defines if bilinear mode has to be used
  124861. * @return the generated texture
  124862. */
  124863. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124864. }
  124865. }
  124866. declare module BABYLON {
  124867. /**
  124868. * This represents the different options available for the video capture.
  124869. */
  124870. export interface VideoRecorderOptions {
  124871. /** Defines the mime type of the video. */
  124872. mimeType: string;
  124873. /** Defines the FPS the video should be recorded at. */
  124874. fps: number;
  124875. /** Defines the chunk size for the recording data. */
  124876. recordChunckSize: number;
  124877. /** The audio tracks to attach to the recording. */
  124878. audioTracks?: MediaStreamTrack[];
  124879. }
  124880. /**
  124881. * This can help with recording videos from BabylonJS.
  124882. * This is based on the available WebRTC functionalities of the browser.
  124883. *
  124884. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124885. */
  124886. export class VideoRecorder {
  124887. private static readonly _defaultOptions;
  124888. /**
  124889. * Returns whether or not the VideoRecorder is available in your browser.
  124890. * @param engine Defines the Babylon Engine.
  124891. * @returns true if supported otherwise false.
  124892. */
  124893. static IsSupported(engine: Engine): boolean;
  124894. private readonly _options;
  124895. private _canvas;
  124896. private _mediaRecorder;
  124897. private _recordedChunks;
  124898. private _fileName;
  124899. private _resolve;
  124900. private _reject;
  124901. /**
  124902. * True when a recording is already in progress.
  124903. */
  124904. readonly isRecording: boolean;
  124905. /**
  124906. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124907. * @param engine Defines the BabylonJS Engine you wish to record.
  124908. * @param options Defines options that can be used to customize the capture.
  124909. */
  124910. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124911. /**
  124912. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124913. */
  124914. stopRecording(): void;
  124915. /**
  124916. * Starts recording the canvas for a max duration specified in parameters.
  124917. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124918. * If null no automatic download will start and you can rely on the promise to get the data back.
  124919. * @param maxDuration Defines the maximum recording time in seconds.
  124920. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124921. * @return A promise callback at the end of the recording with the video data in Blob.
  124922. */
  124923. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124924. /**
  124925. * Releases internal resources used during the recording.
  124926. */
  124927. dispose(): void;
  124928. private _handleDataAvailable;
  124929. private _handleError;
  124930. private _handleStop;
  124931. }
  124932. }
  124933. declare module BABYLON {
  124934. /**
  124935. * Class containing a set of static utilities functions for screenshots
  124936. */
  124937. export class ScreenshotTools {
  124938. /**
  124939. * Captures a screenshot of the current rendering
  124940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124941. * @param engine defines the rendering engine
  124942. * @param camera defines the source camera
  124943. * @param size This parameter can be set to a single number or to an object with the
  124944. * following (optional) properties: precision, width, height. If a single number is passed,
  124945. * it will be used for both width and height. If an object is passed, the screenshot size
  124946. * will be derived from the parameters. The precision property is a multiplier allowing
  124947. * rendering at a higher or lower resolution
  124948. * @param successCallback defines the callback receives a single parameter which contains the
  124949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124950. * src parameter of an <img> to display it
  124951. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124952. * Check your browser for supported MIME types
  124953. */
  124954. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  124955. /**
  124956. * Captures a screenshot of the current rendering
  124957. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124958. * @param engine defines the rendering engine
  124959. * @param camera defines the source camera
  124960. * @param size This parameter can be set to a single number or to an object with the
  124961. * following (optional) properties: precision, width, height. If a single number is passed,
  124962. * it will be used for both width and height. If an object is passed, the screenshot size
  124963. * will be derived from the parameters. The precision property is a multiplier allowing
  124964. * rendering at a higher or lower resolution
  124965. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124966. * Check your browser for supported MIME types
  124967. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124968. * to the src parameter of an <img> to display it
  124969. */
  124970. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124971. /**
  124972. * Generates an image screenshot from the specified camera.
  124973. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124974. * @param engine The engine to use for rendering
  124975. * @param camera The camera to use for rendering
  124976. * @param size This parameter can be set to a single number or to an object with the
  124977. * following (optional) properties: precision, width, height. If a single number is passed,
  124978. * it will be used for both width and height. If an object is passed, the screenshot size
  124979. * will be derived from the parameters. The precision property is a multiplier allowing
  124980. * rendering at a higher or lower resolution
  124981. * @param successCallback The callback receives a single parameter which contains the
  124982. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124983. * src parameter of an <img> to display it
  124984. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124985. * Check your browser for supported MIME types
  124986. * @param samples Texture samples (default: 1)
  124987. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124988. * @param fileName A name for for the downloaded file.
  124989. */
  124990. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124991. /**
  124992. * Generates an image screenshot from the specified camera.
  124993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124994. * @param engine The engine to use for rendering
  124995. * @param camera The camera to use for rendering
  124996. * @param size This parameter can be set to a single number or to an object with the
  124997. * following (optional) properties: precision, width, height. If a single number is passed,
  124998. * it will be used for both width and height. If an object is passed, the screenshot size
  124999. * will be derived from the parameters. The precision property is a multiplier allowing
  125000. * rendering at a higher or lower resolution
  125001. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125002. * Check your browser for supported MIME types
  125003. * @param samples Texture samples (default: 1)
  125004. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125005. * @param fileName A name for for the downloaded file.
  125006. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125007. * to the src parameter of an <img> to display it
  125008. */
  125009. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125010. /**
  125011. * Gets height and width for screenshot size
  125012. * @private
  125013. */
  125014. private static _getScreenshotSize;
  125015. }
  125016. }
  125017. declare module BABYLON {
  125018. /**
  125019. * A cursor which tracks a point on a path
  125020. */
  125021. export class PathCursor {
  125022. private path;
  125023. /**
  125024. * Stores path cursor callbacks for when an onchange event is triggered
  125025. */
  125026. private _onchange;
  125027. /**
  125028. * The value of the path cursor
  125029. */
  125030. value: number;
  125031. /**
  125032. * The animation array of the path cursor
  125033. */
  125034. animations: Animation[];
  125035. /**
  125036. * Initializes the path cursor
  125037. * @param path The path to track
  125038. */
  125039. constructor(path: Path2);
  125040. /**
  125041. * Gets the cursor point on the path
  125042. * @returns A point on the path cursor at the cursor location
  125043. */
  125044. getPoint(): Vector3;
  125045. /**
  125046. * Moves the cursor ahead by the step amount
  125047. * @param step The amount to move the cursor forward
  125048. * @returns This path cursor
  125049. */
  125050. moveAhead(step?: number): PathCursor;
  125051. /**
  125052. * Moves the cursor behind by the step amount
  125053. * @param step The amount to move the cursor back
  125054. * @returns This path cursor
  125055. */
  125056. moveBack(step?: number): PathCursor;
  125057. /**
  125058. * Moves the cursor by the step amount
  125059. * If the step amount is greater than one, an exception is thrown
  125060. * @param step The amount to move the cursor
  125061. * @returns This path cursor
  125062. */
  125063. move(step: number): PathCursor;
  125064. /**
  125065. * Ensures that the value is limited between zero and one
  125066. * @returns This path cursor
  125067. */
  125068. private ensureLimits;
  125069. /**
  125070. * Runs onchange callbacks on change (used by the animation engine)
  125071. * @returns This path cursor
  125072. */
  125073. private raiseOnChange;
  125074. /**
  125075. * Executes a function on change
  125076. * @param f A path cursor onchange callback
  125077. * @returns This path cursor
  125078. */
  125079. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125080. }
  125081. }
  125082. declare module BABYLON {
  125083. /** @hidden */
  125084. export var blurPixelShader: {
  125085. name: string;
  125086. shader: string;
  125087. };
  125088. }
  125089. declare module BABYLON {
  125090. /** @hidden */
  125091. export var pointCloudVertexDeclaration: {
  125092. name: string;
  125093. shader: string;
  125094. };
  125095. }
  125096. // Mixins
  125097. interface Window {
  125098. mozIndexedDB: IDBFactory;
  125099. webkitIndexedDB: IDBFactory;
  125100. msIndexedDB: IDBFactory;
  125101. webkitURL: typeof URL;
  125102. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125103. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125104. WebGLRenderingContext: WebGLRenderingContext;
  125105. MSGesture: MSGesture;
  125106. CANNON: any;
  125107. AudioContext: AudioContext;
  125108. webkitAudioContext: AudioContext;
  125109. PointerEvent: any;
  125110. Math: Math;
  125111. Uint8Array: Uint8ArrayConstructor;
  125112. Float32Array: Float32ArrayConstructor;
  125113. mozURL: typeof URL;
  125114. msURL: typeof URL;
  125115. VRFrameData: any; // WebVR, from specs 1.1
  125116. DracoDecoderModule: any;
  125117. setImmediate(handler: (...args: any[]) => void): number;
  125118. }
  125119. interface HTMLCanvasElement {
  125120. requestPointerLock(): void;
  125121. msRequestPointerLock?(): void;
  125122. mozRequestPointerLock?(): void;
  125123. webkitRequestPointerLock?(): void;
  125124. /** Track wether a record is in progress */
  125125. isRecording: boolean;
  125126. /** Capture Stream method defined by some browsers */
  125127. captureStream(fps?: number): MediaStream;
  125128. }
  125129. interface CanvasRenderingContext2D {
  125130. msImageSmoothingEnabled: boolean;
  125131. }
  125132. interface MouseEvent {
  125133. mozMovementX: number;
  125134. mozMovementY: number;
  125135. webkitMovementX: number;
  125136. webkitMovementY: number;
  125137. msMovementX: number;
  125138. msMovementY: number;
  125139. }
  125140. interface Navigator {
  125141. mozGetVRDevices: (any: any) => any;
  125142. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125143. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125144. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125145. webkitGetGamepads(): Gamepad[];
  125146. msGetGamepads(): Gamepad[];
  125147. webkitGamepads(): Gamepad[];
  125148. }
  125149. interface HTMLVideoElement {
  125150. mozSrcObject: any;
  125151. }
  125152. interface Math {
  125153. fround(x: number): number;
  125154. imul(a: number, b: number): number;
  125155. }
  125156. interface WebGLRenderingContext {
  125157. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  125158. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  125159. vertexAttribDivisor(index: number, divisor: number): void;
  125160. createVertexArray(): any;
  125161. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  125162. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  125163. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  125164. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  125165. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  125166. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  125167. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  125168. // Queries
  125169. createQuery(): WebGLQuery;
  125170. deleteQuery(query: WebGLQuery): void;
  125171. beginQuery(target: number, query: WebGLQuery): void;
  125172. endQuery(target: number): void;
  125173. getQueryParameter(query: WebGLQuery, pname: number): any;
  125174. getQuery(target: number, pname: number): any;
  125175. MAX_SAMPLES: number;
  125176. RGBA8: number;
  125177. READ_FRAMEBUFFER: number;
  125178. DRAW_FRAMEBUFFER: number;
  125179. UNIFORM_BUFFER: number;
  125180. HALF_FLOAT_OES: number;
  125181. RGBA16F: number;
  125182. RGBA32F: number;
  125183. R32F: number;
  125184. RG32F: number;
  125185. RGB32F: number;
  125186. R16F: number;
  125187. RG16F: number;
  125188. RGB16F: number;
  125189. RED: number;
  125190. RG: number;
  125191. R8: number;
  125192. RG8: number;
  125193. UNSIGNED_INT_24_8: number;
  125194. DEPTH24_STENCIL8: number;
  125195. /* Multiple Render Targets */
  125196. drawBuffers(buffers: number[]): void;
  125197. readBuffer(src: number): void;
  125198. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  125199. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  125200. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  125201. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  125202. // Occlusion Query
  125203. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  125204. ANY_SAMPLES_PASSED: number;
  125205. QUERY_RESULT_AVAILABLE: number;
  125206. QUERY_RESULT: number;
  125207. }
  125208. interface WebGLProgram {
  125209. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  125210. }
  125211. interface EXT_disjoint_timer_query {
  125212. QUERY_COUNTER_BITS_EXT: number;
  125213. TIME_ELAPSED_EXT: number;
  125214. TIMESTAMP_EXT: number;
  125215. GPU_DISJOINT_EXT: number;
  125216. QUERY_RESULT_EXT: number;
  125217. QUERY_RESULT_AVAILABLE_EXT: number;
  125218. queryCounterEXT(query: WebGLQuery, target: number): void;
  125219. createQueryEXT(): WebGLQuery;
  125220. beginQueryEXT(target: number, query: WebGLQuery): void;
  125221. endQueryEXT(target: number): void;
  125222. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  125223. deleteQueryEXT(query: WebGLQuery): void;
  125224. }
  125225. interface WebGLUniformLocation {
  125226. _currentState: any;
  125227. }
  125228. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  125229. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  125230. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  125231. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125232. interface WebGLRenderingContext {
  125233. readonly RASTERIZER_DISCARD: number;
  125234. readonly DEPTH_COMPONENT24: number;
  125235. readonly TEXTURE_3D: number;
  125236. readonly TEXTURE_2D_ARRAY: number;
  125237. readonly TEXTURE_COMPARE_FUNC: number;
  125238. readonly TEXTURE_COMPARE_MODE: number;
  125239. readonly COMPARE_REF_TO_TEXTURE: number;
  125240. readonly TEXTURE_WRAP_R: number;
  125241. readonly HALF_FLOAT: number;
  125242. readonly RGB8: number;
  125243. readonly RED_INTEGER: number;
  125244. readonly RG_INTEGER: number;
  125245. readonly RGB_INTEGER: number;
  125246. readonly RGBA_INTEGER: number;
  125247. readonly R8_SNORM: number;
  125248. readonly RG8_SNORM: number;
  125249. readonly RGB8_SNORM: number;
  125250. readonly RGBA8_SNORM: number;
  125251. readonly R8I: number;
  125252. readonly RG8I: number;
  125253. readonly RGB8I: number;
  125254. readonly RGBA8I: number;
  125255. readonly R8UI: number;
  125256. readonly RG8UI: number;
  125257. readonly RGB8UI: number;
  125258. readonly RGBA8UI: number;
  125259. readonly R16I: number;
  125260. readonly RG16I: number;
  125261. readonly RGB16I: number;
  125262. readonly RGBA16I: number;
  125263. readonly R16UI: number;
  125264. readonly RG16UI: number;
  125265. readonly RGB16UI: number;
  125266. readonly RGBA16UI: number;
  125267. readonly R32I: number;
  125268. readonly RG32I: number;
  125269. readonly RGB32I: number;
  125270. readonly RGBA32I: number;
  125271. readonly R32UI: number;
  125272. readonly RG32UI: number;
  125273. readonly RGB32UI: number;
  125274. readonly RGBA32UI: number;
  125275. readonly RGB10_A2UI: number;
  125276. readonly R11F_G11F_B10F: number;
  125277. readonly RGB9_E5: number;
  125278. readonly RGB10_A2: number;
  125279. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  125280. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  125281. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  125282. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  125283. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  125284. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  125285. 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;
  125286. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  125287. readonly TRANSFORM_FEEDBACK: number;
  125288. readonly INTERLEAVED_ATTRIBS: number;
  125289. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  125290. createTransformFeedback(): WebGLTransformFeedback;
  125291. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  125292. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  125293. beginTransformFeedback(primitiveMode: number): void;
  125294. endTransformFeedback(): void;
  125295. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  125296. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125297. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125298. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125299. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  125300. }
  125301. interface ImageBitmap {
  125302. readonly width: number;
  125303. readonly height: number;
  125304. close(): void;
  125305. }
  125306. interface WebGLQuery extends WebGLObject {
  125307. }
  125308. declare var WebGLQuery: {
  125309. prototype: WebGLQuery;
  125310. new(): WebGLQuery;
  125311. };
  125312. interface WebGLSampler extends WebGLObject {
  125313. }
  125314. declare var WebGLSampler: {
  125315. prototype: WebGLSampler;
  125316. new(): WebGLSampler;
  125317. };
  125318. interface WebGLSync extends WebGLObject {
  125319. }
  125320. declare var WebGLSync: {
  125321. prototype: WebGLSync;
  125322. new(): WebGLSync;
  125323. };
  125324. interface WebGLTransformFeedback extends WebGLObject {
  125325. }
  125326. declare var WebGLTransformFeedback: {
  125327. prototype: WebGLTransformFeedback;
  125328. new(): WebGLTransformFeedback;
  125329. };
  125330. interface WebGLVertexArrayObject extends WebGLObject {
  125331. }
  125332. declare var WebGLVertexArrayObject: {
  125333. prototype: WebGLVertexArrayObject;
  125334. new(): WebGLVertexArrayObject;
  125335. };
  125336. // Type definitions for WebVR API
  125337. // Project: https://w3c.github.io/webvr/
  125338. // Definitions by: six a <https://github.com/lostfictions>
  125339. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125340. interface VRDisplay extends EventTarget {
  125341. /**
  125342. * Dictionary of capabilities describing the VRDisplay.
  125343. */
  125344. readonly capabilities: VRDisplayCapabilities;
  125345. /**
  125346. * z-depth defining the far plane of the eye view frustum
  125347. * enables mapping of values in the render target depth
  125348. * attachment to scene coordinates. Initially set to 10000.0.
  125349. */
  125350. depthFar: number;
  125351. /**
  125352. * z-depth defining the near plane of the eye view frustum
  125353. * enables mapping of values in the render target depth
  125354. * attachment to scene coordinates. Initially set to 0.01.
  125355. */
  125356. depthNear: number;
  125357. /**
  125358. * An identifier for this distinct VRDisplay. Used as an
  125359. * association point in the Gamepad API.
  125360. */
  125361. readonly displayId: number;
  125362. /**
  125363. * A display name, a user-readable name identifying it.
  125364. */
  125365. readonly displayName: string;
  125366. readonly isConnected: boolean;
  125367. readonly isPresenting: boolean;
  125368. /**
  125369. * If this VRDisplay supports room-scale experiences, the optional
  125370. * stage attribute contains details on the room-scale parameters.
  125371. */
  125372. readonly stageParameters: VRStageParameters | null;
  125373. /**
  125374. * Passing the value returned by `requestAnimationFrame` to
  125375. * `cancelAnimationFrame` will unregister the callback.
  125376. * @param handle Define the hanle of the request to cancel
  125377. */
  125378. cancelAnimationFrame(handle: number): void;
  125379. /**
  125380. * Stops presenting to the VRDisplay.
  125381. * @returns a promise to know when it stopped
  125382. */
  125383. exitPresent(): Promise<void>;
  125384. /**
  125385. * Return the current VREyeParameters for the given eye.
  125386. * @param whichEye Define the eye we want the parameter for
  125387. * @returns the eye parameters
  125388. */
  125389. getEyeParameters(whichEye: string): VREyeParameters;
  125390. /**
  125391. * Populates the passed VRFrameData with the information required to render
  125392. * the current frame.
  125393. * @param frameData Define the data structure to populate
  125394. * @returns true if ok otherwise false
  125395. */
  125396. getFrameData(frameData: VRFrameData): boolean;
  125397. /**
  125398. * Get the layers currently being presented.
  125399. * @returns the list of VR layers
  125400. */
  125401. getLayers(): VRLayer[];
  125402. /**
  125403. * Return a VRPose containing the future predicted pose of the VRDisplay
  125404. * when the current frame will be presented. The value returned will not
  125405. * change until JavaScript has returned control to the browser.
  125406. *
  125407. * The VRPose will contain the position, orientation, velocity,
  125408. * and acceleration of each of these properties.
  125409. * @returns the pose object
  125410. */
  125411. getPose(): VRPose;
  125412. /**
  125413. * Return the current instantaneous pose of the VRDisplay, with no
  125414. * prediction applied.
  125415. * @returns the current instantaneous pose
  125416. */
  125417. getImmediatePose(): VRPose;
  125418. /**
  125419. * The callback passed to `requestAnimationFrame` will be called
  125420. * any time a new frame should be rendered. When the VRDisplay is
  125421. * presenting the callback will be called at the native refresh
  125422. * rate of the HMD. When not presenting this function acts
  125423. * identically to how window.requestAnimationFrame acts. Content should
  125424. * make no assumptions of frame rate or vsync behavior as the HMD runs
  125425. * asynchronously from other displays and at differing refresh rates.
  125426. * @param callback Define the eaction to run next frame
  125427. * @returns the request handle it
  125428. */
  125429. requestAnimationFrame(callback: FrameRequestCallback): number;
  125430. /**
  125431. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  125432. * Repeat calls while already presenting will update the VRLayers being displayed.
  125433. * @param layers Define the list of layer to present
  125434. * @returns a promise to know when the request has been fulfilled
  125435. */
  125436. requestPresent(layers: VRLayer[]): Promise<void>;
  125437. /**
  125438. * Reset the pose for this display, treating its current position and
  125439. * orientation as the "origin/zero" values. VRPose.position,
  125440. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  125441. * updated when calling resetPose(). This should be called in only
  125442. * sitting-space experiences.
  125443. */
  125444. resetPose(): void;
  125445. /**
  125446. * The VRLayer provided to the VRDisplay will be captured and presented
  125447. * in the HMD. Calling this function has the same effect on the source
  125448. * canvas as any other operation that uses its source image, and canvases
  125449. * created without preserveDrawingBuffer set to true will be cleared.
  125450. * @param pose Define the pose to submit
  125451. */
  125452. submitFrame(pose?: VRPose): void;
  125453. }
  125454. declare var VRDisplay: {
  125455. prototype: VRDisplay;
  125456. new(): VRDisplay;
  125457. };
  125458. interface VRLayer {
  125459. leftBounds?: number[] | Float32Array | null;
  125460. rightBounds?: number[] | Float32Array | null;
  125461. source?: HTMLCanvasElement | null;
  125462. }
  125463. interface VRDisplayCapabilities {
  125464. readonly canPresent: boolean;
  125465. readonly hasExternalDisplay: boolean;
  125466. readonly hasOrientation: boolean;
  125467. readonly hasPosition: boolean;
  125468. readonly maxLayers: number;
  125469. }
  125470. interface VREyeParameters {
  125471. /** @deprecated */
  125472. readonly fieldOfView: VRFieldOfView;
  125473. readonly offset: Float32Array;
  125474. readonly renderHeight: number;
  125475. readonly renderWidth: number;
  125476. }
  125477. interface VRFieldOfView {
  125478. readonly downDegrees: number;
  125479. readonly leftDegrees: number;
  125480. readonly rightDegrees: number;
  125481. readonly upDegrees: number;
  125482. }
  125483. interface VRFrameData {
  125484. readonly leftProjectionMatrix: Float32Array;
  125485. readonly leftViewMatrix: Float32Array;
  125486. readonly pose: VRPose;
  125487. readonly rightProjectionMatrix: Float32Array;
  125488. readonly rightViewMatrix: Float32Array;
  125489. readonly timestamp: number;
  125490. }
  125491. interface VRPose {
  125492. readonly angularAcceleration: Float32Array | null;
  125493. readonly angularVelocity: Float32Array | null;
  125494. readonly linearAcceleration: Float32Array | null;
  125495. readonly linearVelocity: Float32Array | null;
  125496. readonly orientation: Float32Array | null;
  125497. readonly position: Float32Array | null;
  125498. readonly timestamp: number;
  125499. }
  125500. interface VRStageParameters {
  125501. sittingToStandingTransform?: Float32Array;
  125502. sizeX?: number;
  125503. sizeY?: number;
  125504. }
  125505. interface Navigator {
  125506. getVRDisplays(): Promise<VRDisplay[]>;
  125507. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  125508. }
  125509. interface Window {
  125510. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  125511. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  125512. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  125513. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125514. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125515. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  125516. }
  125517. interface Gamepad {
  125518. readonly displayId: number;
  125519. }
  125520. type XRSessionMode =
  125521. | "inline"
  125522. | "immersive-vr"
  125523. | "immersive-ar";
  125524. type XRReferenceSpaceType =
  125525. | "viewer"
  125526. | "local"
  125527. | "local-floor"
  125528. | "bounded-floor"
  125529. | "unbounded";
  125530. type XREnvironmentBlendMode =
  125531. | "opaque"
  125532. | "additive"
  125533. | "alpha-blend";
  125534. type XRVisibilityState =
  125535. | "visible"
  125536. | "visible-blurred"
  125537. | "hidden";
  125538. type XRHandedness =
  125539. | "none"
  125540. | "left"
  125541. | "right";
  125542. type XRTargetRayMode =
  125543. | "gaze"
  125544. | "tracked-pointer"
  125545. | "screen";
  125546. type XREye =
  125547. | "none"
  125548. | "left"
  125549. | "right";
  125550. interface XRSpace extends EventTarget {
  125551. }
  125552. interface XRRenderState {
  125553. depthNear?: number;
  125554. depthFar?: number;
  125555. inlineVerticalFieldOfView?: number;
  125556. baseLayer?: XRWebGLLayer;
  125557. }
  125558. interface XRInputSource {
  125559. handedness: XRHandedness;
  125560. targetRayMode: XRTargetRayMode;
  125561. targetRaySpace: XRSpace;
  125562. gripSpace: XRSpace | undefined;
  125563. gamepad: Gamepad | undefined;
  125564. profiles: Array<string>;
  125565. }
  125566. interface XRSession {
  125567. addEventListener: Function;
  125568. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125569. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  125570. requestAnimationFrame: Function;
  125571. end(): Promise<void>;
  125572. renderState: XRRenderState;
  125573. inputSources: Array<XRInputSource>;
  125574. }
  125575. interface XRReferenceSpace extends XRSpace {
  125576. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  125577. onreset: any;
  125578. }
  125579. interface XRFrame {
  125580. session: XRSession;
  125581. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  125582. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  125583. }
  125584. interface XRViewerPose extends XRPose {
  125585. views: Array<XRView>;
  125586. }
  125587. interface XRPose {
  125588. transform: XRRigidTransform;
  125589. emulatedPosition: boolean;
  125590. }
  125591. declare var XRWebGLLayer: {
  125592. prototype: XRWebGLLayer;
  125593. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125594. };
  125595. interface XRWebGLLayer {
  125596. framebuffer: WebGLFramebuffer;
  125597. framebufferWidth: number;
  125598. framebufferHeight: number;
  125599. getViewport: Function;
  125600. }
  125601. interface XRRigidTransform {
  125602. position: DOMPointReadOnly;
  125603. orientation: DOMPointReadOnly;
  125604. matrix: Float32Array;
  125605. inverse: XRRigidTransform;
  125606. }
  125607. interface XRView {
  125608. eye: XREye;
  125609. projectionMatrix: Float32Array;
  125610. transform: XRRigidTransform;
  125611. }
  125612. interface XRInputSourceChangeEvent {
  125613. session: XRSession;
  125614. removed: Array<XRInputSource>;
  125615. added: Array<XRInputSource>;
  125616. }